package l1;

import T0.j;
import java.io.EOFException;
import java.io.InterruptedIOException;

/* JADX INFO: renamed from: l1.e, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1124e {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final long[] f14372d = {128, 64, 32, 16, 8, 4, 2, 1};

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final byte[] f14373a = new byte[8];

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f14374b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f14375c;

    public static long a(int i, boolean z8, byte[] bArr) {
        long j8 = ((long) bArr[0]) & 255;
        if (z8) {
            j8 &= ~f14372d[i - 1];
        }
        for (int i5 = 1; i5 < i; i5++) {
            j8 = (j8 << 8) | (((long) bArr[i5]) & 255);
        }
        return j8;
    }

    public static int b(int i) {
        for (int i5 = 0; i5 < 8; i5++) {
            if ((f14372d[i5] & ((long) i)) != 0) {
                return i5 + 1;
            }
        }
        return -1;
    }

    public final long c(j jVar, boolean z8, boolean z9, int i) throws EOFException, InterruptedIOException {
        int i5 = this.f14374b;
        byte[] bArr = this.f14373a;
        if (i5 == 0) {
            if (!jVar.c(bArr, 0, 1, z8)) {
                return -1L;
            }
            int iB = b(bArr[0] & 255);
            this.f14375c = iB;
            if (iB == -1) {
                throw new IllegalStateException("No valid varint length mask found");
            }
            this.f14374b = 1;
        }
        int i8 = this.f14375c;
        if (i8 > i) {
            this.f14374b = 0;
            return -2L;
        }
        if (i8 != 1) {
            jVar.c(bArr, 1, i8 - 1, false);
        }
        this.f14374b = 0;
        return a(this.f14375c, z9, bArr);
    }
}
