package o;

import com.google.android.gms.common.api.Api;
import java.io.EOFException;
import java.util.Arrays;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.sF, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2415sF {
    public final C0732af a;
    public boolean c;
    public int g;
    public int h;
    public int b = Api.BaseClientBuilder.API_PRIORITY_OTHER;
    public int d = 4096;
    public JE[] e = new JE[8];
    public int f = 7;

    public C2415sF(C0732af c0732af) {
        this.a = c0732af;
    }

    public final void a(int i) {
        int i2;
        if (i > 0) {
            int length = this.e.length - 1;
            int i3 = 0;
            while (true) {
                i2 = this.f;
                if (length < i2 || i <= 0) {
                    break;
                }
                int i4 = this.e[length].c;
                i -= i4;
                this.h -= i4;
                this.g--;
                i3++;
                length--;
            }
            JE[] jeArr = this.e;
            int i5 = i2 + 1;
            System.arraycopy(jeArr, i5, jeArr, i5 + i3, this.g);
            JE[] jeArr2 = this.e;
            int i6 = this.f + 1;
            Arrays.fill(jeArr2, i6, i6 + i3, (Object) null);
            this.f += i3;
        }
    }

    public final void b(JE je) {
        int i = je.c;
        int i2 = this.d;
        if (i > i2) {
            JE[] jeArr = this.e;
            Arrays.fill(jeArr, 0, jeArr.length, (Object) null);
            this.f = this.e.length - 1;
            this.g = 0;
            this.h = 0;
            return;
        }
        a((this.h + i) - i2);
        int i3 = this.g + 1;
        JE[] jeArr2 = this.e;
        if (i3 > jeArr2.length) {
            JE[] jeArr3 = new JE[jeArr2.length * 2];
            System.arraycopy(jeArr2, 0, jeArr3, jeArr2.length, jeArr2.length);
            this.f = this.e.length - 1;
            this.e = jeArr3;
        }
        int i4 = this.f;
        this.f = i4 - 1;
        this.e[i4] = je;
        this.g++;
        this.h += i;
    }

    public final void c(C0135Ff c0135Ff) throws EOFException {
        int[] iArr = AbstractC0702aG.a;
        int iB = c0135Ff.b();
        long j = 0;
        long j2 = 0;
        for (int i = 0; i < iB; i++) {
            byte bG = c0135Ff.g(i);
            byte[] bArr = AbstractC2264qi0.a;
            j2 += AbstractC0702aG.b[bG & 255];
        }
        int i2 = (int) ((j2 + 7) >> 3);
        int iB2 = c0135Ff.b();
        C0732af c0732af = this.a;
        if (i2 >= iB2) {
            e(c0135Ff.b(), 127, 0);
            c0135Ff.o(c0732af, c0135Ff.b());
            return;
        }
        C0732af c0732af2 = new C0732af();
        int[] iArr2 = AbstractC0702aG.a;
        int iB3 = c0135Ff.b();
        int i3 = 0;
        for (int i4 = 0; i4 < iB3; i4++) {
            byte bG2 = c0135Ff.g(i4);
            byte[] bArr2 = AbstractC2264qi0.a;
            int i5 = bG2 & 255;
            int i6 = AbstractC0702aG.a[i5];
            byte b = AbstractC0702aG.b[i5];
            j = (j << b) | i6;
            i3 += b;
            while (i3 >= 8) {
                i3 -= 8;
                c0732af2.G((int) (j >> i3));
            }
        }
        if (i3 > 0) {
            c0732af2.G((int) ((j << (8 - i3)) | (255 >>> i3)));
        }
        C0135Ff c0135FfI = c0732af2.i(c0732af2.m);
        e(c0135FfI.b(), 127, 128);
        c0135FfI.o(c0732af, c0135FfI.b());
    }

    /* JADX WARN: Removed duplicated region for block: B:22:0x0069  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void d(java.util.ArrayList r14) throws java.io.EOFException {
        /*
            Method dump skipped, instructions count: 243
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C2415sF.d(java.util.ArrayList):void");
    }

    public final void e(int i, int i2, int i3) {
        C0732af c0732af = this.a;
        if (i < i2) {
            c0732af.G(i | i3);
            return;
        }
        c0732af.G(i3 | i2);
        int i4 = i - i2;
        while (i4 >= 128) {
            c0732af.G(128 | (i4 & 127));
            i4 >>>= 7;
        }
        c0732af.G(i4);
    }
}
