discord-jadx/app/src/main/java/c/i/a/c/a2/f0/g.java

64 lines
1.6 KiB
Java

package c.i.a.c.a2.f0;
import c.i.a.c.a2.i;
import java.io.IOException;
/* compiled from: VarintReader */
public final class g {
public static final long[] a = {128, 64, 32, 16, 8, 4, 2, 1};
public final byte[] b = new byte[8];
/* renamed from: c reason: collision with root package name */
public int f675c;
public int d;
public static long a(byte[] bArr, int i, boolean z2) {
long j = ((long) bArr[0]) & 255;
if (z2) {
j &= ~a[i - 1];
}
for (int i2 = 1; i2 < i; i2++) {
j = (j << 8) | (((long) bArr[i2]) & 255);
}
return j;
}
public static int b(int i) {
int i2 = 0;
while (true) {
long[] jArr = a;
if (i2 >= jArr.length) {
return -1;
}
if ((jArr[i2] & ((long) i)) != 0) {
return i2 + 1;
}
i2++;
}
}
public long c(i iVar, boolean z2, boolean z3, int i) throws IOException {
if (this.f675c == 0) {
if (!iVar.c(this.b, 0, 1, z2)) {
return -1;
}
int b = b(this.b[0] & 255);
this.d = b;
if (b != -1) {
this.f675c = 1;
} else {
throw new IllegalStateException("No valid varint length mask found");
}
}
int i2 = this.d;
if (i2 > i) {
this.f675c = 0;
return -2;
}
if (i2 != 1) {
iVar.readFully(this.b, 1, i2 - 1);
}
this.f675c = 0;
return a(this.b, this.d, z3);
}
}