package fl;

import com.google.firebase.perf.util.Constants;

/* loaded from: classes3.dex */
public final class c {

    /* renamed from: a, reason: collision with root package name */
    private final byte[] f18554a;

    /* renamed from: b, reason: collision with root package name */
    private int f18555b;

    /* renamed from: c, reason: collision with root package name */
    private int f18556c;

    public c(byte[] bArr) {
        this.f18554a = bArr;
    }

    public int a() {
        return ((this.f18554a.length - this.f18555b) * 8) - this.f18556c;
    }

    public int b() {
        return this.f18556c;
    }

    public int c() {
        return this.f18555b;
    }

    public int d(int i10) {
        if (i10 <= 0 || i10 > 32 || i10 > a()) {
            throw new IllegalArgumentException(String.valueOf(i10));
        }
        int i11 = this.f18556c;
        int i12 = 0;
        if (i11 > 0) {
            int i13 = 8 - i11;
            int min = Math.min(i10, i13);
            int i14 = i13 - min;
            int i15 = (Constants.MAX_HOST_LENGTH >> (8 - min)) << i14;
            byte[] bArr = this.f18554a;
            int i16 = this.f18555b;
            int i17 = (i15 & bArr[i16]) >> i14;
            i10 -= min;
            int i18 = this.f18556c + min;
            this.f18556c = i18;
            if (i18 == 8) {
                this.f18556c = 0;
                this.f18555b = i16 + 1;
            }
            i12 = i17;
        }
        if (i10 <= 0) {
            return i12;
        }
        while (i10 >= 8) {
            int i19 = i12 << 8;
            byte[] bArr2 = this.f18554a;
            int i20 = this.f18555b;
            i12 = (bArr2[i20] & 255) | i19;
            this.f18555b = i20 + 1;
            i10 -= 8;
        }
        if (i10 <= 0) {
            return i12;
        }
        int i21 = 8 - i10;
        int i22 = (i12 << i10) | ((((Constants.MAX_HOST_LENGTH >> i21) << i21) & this.f18554a[this.f18555b]) >> i21);
        this.f18556c += i10;
        return i22;
    }
}
