package defpackage;

/* renamed from: ᵫᵦ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C3977 {

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public static final long[] f15005 = {128, 64, 32, 16, 8, 4, 2, 1};

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final byte[] f15006;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public int f15007;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public int f15008;

    public C3977() {
        this.f15006 = new byte[8];
    }

    public C3977(byte[] bArr, int i, int i2) {
        this.f15006 = bArr;
        this.f15007 = i;
        this.f15008 = i2;
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public static long m8804(int i, boolean z, byte[] bArr) {
        long j = bArr[0] & 255;
        if (z) {
            j &= ~f15005[i - 1];
        }
        for (int i2 = 1; i2 < i; i2++) {
            j = (j << 8) | (bArr[i2] & 255);
        }
        return j;
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public long m8805(InterfaceC1383 interfaceC1383, boolean z, boolean z2, int i) {
        int i2;
        int i3 = this.f15007;
        byte[] bArr = this.f15006;
        if (i3 == 0) {
            if (!interfaceC1383.mo4252(bArr, 0, 1, z)) {
                return -1L;
            }
            int i4 = bArr[0] & 255;
            int i5 = 0;
            while (true) {
                if (i5 >= 8) {
                    i2 = -1;
                    break;
                }
                if ((f15005[i5] & i4) != 0) {
                    i2 = i5 + 1;
                    break;
                }
                i5++;
            }
            this.f15008 = i2;
            if (i2 == -1) {
                ᵹˉᵞ.ᵳٴᵶ("No valid varint length mask found");
                return 0L;
            }
            this.f15007 = 1;
        }
        int i6 = this.f15008;
        if (i6 > i) {
            this.f15007 = 0;
            return -2L;
        }
        if (i6 != 1) {
            interfaceC1383.readFully(bArr, 1, i6 - 1);
        }
        this.f15007 = 0;
        return m8804(this.f15008, z2, bArr);
    }
}
