package defpackage;

import java.util.Arrays;
import org.tukaani.xz.CorruptedInputException;

/* renamed from: ᵭʢ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C4089 {

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public int f15279;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public int f15280;

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

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public byte[] f15282;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public int f15283;

    public C4089(int i) {
        this.f15281 = i;
        switch (i) {
            case 3:
                break;
            default:
                this.f15282 = AbstractC3558.f13330;
                break;
        }
    }

    public C4089(int i, int i2) {
        this.f15281 = 0;
        this.f15280 = i;
        this.f15283 = i2;
        this.f15282 = new byte[(i2 * 2) - 1];
        this.f15279 = 0;
    }

    public C4089(int i, byte[] bArr) {
        this.f15281 = 1;
        this.f15282 = bArr;
        this.f15279 = i;
    }

    public C4089(C0471 c0471) {
        this.f15281 = 2;
        this.f15280 = 0;
        this.f15283 = 0;
        byte[] bArrMo2066 = c0471.mo2066(65531);
        this.f15282 = bArrMo2066;
        this.f15279 = bArrMo2066.length;
    }

    public C4089(byte[] bArr) {
        this.f15281 = 4;
        this.f15282 = bArr;
        this.f15280 = bArr.length;
    }

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public static final void m8947(short[] sArr) {
        Arrays.fill(sArr, (short) 1024);
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public int m8948(short[] sArr) {
        int iM8967 = 1;
        do {
            iM8967 = m8967(sArr, iM8967) | (iM8967 << 1);
        } while (iM8967 < sArr.length);
        return iM8967 - sArr.length;
    }

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public void m8949(C3493 c3493) {
        m8962(c3493.f13081, c3493.f13082);
        m8957(c3493.f13083 * 8);
    }

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public void m8950(int i, byte[] bArr) {
        int i2 = i >> 3;
        for (int i3 = 0; i3 < i2; i3++) {
            byte[] bArr2 = this.f15282;
            int i4 = this.f15280;
            int i5 = i4 + 1;
            this.f15280 = i5;
            byte b = bArr2[i4];
            int i6 = this.f15283;
            byte b2 = (byte) (b << i6);
            bArr[i3] = b2;
            bArr[i3] = (byte) (((255 & bArr2[i5]) >> (8 - i6)) | b2);
        }
        int i7 = i & 7;
        if (i7 == 0) {
            return;
        }
        byte b3 = (byte) (bArr[i2] & (255 >> i7));
        bArr[i2] = b3;
        int i8 = this.f15283;
        if (i8 + i7 > 8) {
            byte[] bArr3 = this.f15282;
            int i9 = this.f15280;
            this.f15280 = i9 + 1;
            bArr[i2] = (byte) (b3 | ((bArr3[i9] & 255) << i8));
            this.f15283 = i8 - 8;
        }
        int i10 = this.f15283 + i7;
        this.f15283 = i10;
        byte[] bArr4 = this.f15282;
        int i11 = this.f15280;
        bArr[i2] = (byte) (((byte) (((255 & bArr4[i11]) >> (8 - i10)) << (8 - i7))) | bArr[i2]);
        if (i10 == 8) {
            this.f15283 = 0;
            this.f15280 = i11 + 1;
        }
        m8958();
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public int m8951() {
        return (this.f15280 * 8) + this.f15283;
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public int m8952() {
        ᵛᵾˏ.ᵿʗᵝʽ(this.f15283 == 0);
        return this.f15280;
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public void m8953() {
        if (this.f15283 == 0) {
            return;
        }
        this.f15283 = 0;
        this.f15280++;
        m8958();
    }

    /* renamed from: ˑᵱ, reason: contains not printable characters */
    public void m8954(byte[] bArr, int i, int i2) {
        byte[] bArr2 = this.f15282;
        if (bArr.length - i < i2) {
            ᵹˉᵞ.ˌᵜᵹᵩ("Bytes to write do not exist in source");
            return;
        }
        if (i2 > bArr2.length - this.f15279) {
            C2585.m6491("Size of bytes to be written is greater than available buffer space");
            return;
        }
        int i3 = this.f15280;
        if (i3 + i2 <= bArr2.length) {
            System.arraycopy(bArr, i, bArr2, i3, i2);
        } else {
            int length = bArr2.length - i3;
            System.arraycopy(bArr, i, bArr2, i3, length);
            System.arraycopy(bArr, i + length, bArr2, 0, i2 - length);
        }
        this.f15280 = (this.f15280 + i2) % bArr2.length;
        this.f15279 += i2;
    }

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public void m8955() throws CorruptedInputException {
        int i = this.f15280;
        if (((-16777216) & i) == 0) {
            try {
                int i2 = this.f15283 << 8;
                byte[] bArr = this.f15282;
                int i3 = this.f15279;
                this.f15279 = i3 + 1;
                this.f15283 = i2 | (bArr[i3] & 255);
                this.f15280 = i << 8;
            } catch (ArrayIndexOutOfBoundsException unused) {
                throw new CorruptedInputException();
            }
        }
    }

    /* renamed from: ᵞʡ, reason: contains not printable characters */
    public void m8956(int i) {
        int i2;
        switch (this.f15281) {
            case 1:
                int i3 = i / 8;
                int i4 = this.f15280 + i3;
                this.f15280 = i4;
                int i5 = (i - (i3 * 8)) + this.f15283;
                this.f15283 = i5;
                if (i5 > 7) {
                    this.f15280 = i4 + 1;
                    this.f15283 = i5 - 8;
                }
                m8958();
                break;
            default:
                int i6 = i / 8;
                int i7 = this.f15283 + i6;
                this.f15283 = i7;
                int i8 = (i - (i6 * 8)) + this.f15279;
                this.f15279 = i8;
                boolean z = true;
                if (i8 > 7) {
                    this.f15283 = i7 + 1;
                    this.f15279 = i8 - 8;
                }
                int i9 = this.f15283;
                if (i9 < 0 || (i9 >= (i2 = this.f15280) && (i9 != i2 || this.f15279 != 0))) {
                    z = false;
                }
                ᵛᵾˏ.ᵿʗᵝʽ(z);
                break;
        }
    }

    /* renamed from: ᵡʠ, reason: contains not printable characters */
    public void m8957(int i) {
        int i2 = i / 8;
        this.f15280 = i2;
        this.f15283 = i - (i2 * 8);
        m8958();
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public void m8958() {
        int i;
        int i2 = this.f15280;
        ᵛᵾˏ.ᵿʗᵝʽ(i2 >= 0 && (i2 < (i = this.f15279) || (i2 == i && this.f15283 == 0)));
    }

    /* renamed from: ᵨᵳʝ, reason: contains not printable characters */
    public void m8959(int i) {
        ᵛᵾˏ.ᵿʗᵝʽ(this.f15283 == 0);
        this.f15280 += i;
        m8958();
    }

    /* renamed from: ᵪʩ, reason: contains not printable characters */
    public void m8960(int i, byte[] bArr) {
        ᵛᵾˏ.ᵿʗᵝʽ(this.f15283 == 0);
        System.arraycopy(this.f15282, this.f15280, bArr, 0, i);
        this.f15280 += i;
        m8958();
    }

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public long m8961(int i) {
        if (i <= 32) {
            int iM8966 = m8966(i);
            String str = AbstractC3558.f13329;
            return iM8966 & 4294967295L;
        }
        int iM89662 = m8966(i - 32);
        int iM89663 = m8966(32);
        String str2 = AbstractC3558.f13329;
        return (iM89663 & 4294967295L) | ((iM89662 & 4294967295L) << 32);
    }

    /* renamed from: ᵳٴᵶ, reason: contains not printable characters */
    public void m8962(int i, byte[] bArr) {
        this.f15282 = bArr;
        this.f15280 = 0;
        this.f15283 = 0;
        this.f15279 = i;
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public int m8963() {
        return ((this.f15279 - this.f15280) * 8) - this.f15283;
    }

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public boolean m8964() {
        switch (this.f15281) {
            case 1:
                boolean z = (this.f15282[this.f15280] & (128 >> this.f15283)) != 0;
                m8965();
                return z;
            default:
                boolean z2 = (((this.f15282[this.f15283] & 255) >> this.f15279) & 1) == 1;
                m8956(1);
                return z2;
        }
    }

    /* renamed from: ᵸʓᵠ, reason: contains not printable characters */
    public void m8965() {
        int i = this.f15283 + 1;
        this.f15283 = i;
        if (i == 8) {
            this.f15283 = 0;
            this.f15280++;
        }
        m8958();
    }

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public int m8966(int i) {
        switch (this.f15281) {
            case 1:
                if (i == 0) {
                    return 0;
                }
                this.f15283 += i;
                int i2 = 0;
                while (true) {
                    int i3 = this.f15283;
                    if (i3 <= 8) {
                        byte[] bArr = this.f15282;
                        int i4 = this.f15280;
                        int i5 = ((-1) >>> (32 - i)) & (((255 & bArr[i4]) >> (8 - i3)) | i2);
                        if (i3 == 8) {
                            this.f15283 = 0;
                            this.f15280 = i4 + 1;
                        }
                        m8958();
                        return i5;
                    }
                    int i6 = i3 - 8;
                    this.f15283 = i6;
                    byte[] bArr2 = this.f15282;
                    int i7 = this.f15280;
                    this.f15280 = i7 + 1;
                    i2 |= (bArr2[i7] & 255) << i6;
                }
            default:
                int i8 = this.f15283;
                int iMin = Math.min(i, 8 - this.f15279);
                byte[] bArr3 = this.f15282;
                int i9 = i8 + 1;
                int i10 = ((bArr3[i8] & 255) >> this.f15279) & (255 >> (8 - iMin));
                while (iMin < i) {
                    i10 |= (bArr3[i9] & 255) << iMin;
                    iMin += 8;
                    i9++;
                }
                int i11 = i10 & ((-1) >>> (32 - i));
                m8956(i);
                return i11;
        }
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public int m8967(short[] sArr, int i) throws CorruptedInputException {
        m8955();
        short s = sArr[i];
        int i2 = (this.f15280 >>> 11) * s;
        if (Integer.compare(this.f15283 ^ Integer.MIN_VALUE, Integer.MIN_VALUE ^ i2) < 0) {
            this.f15280 = i2;
            sArr[i] = (short) (s + ((2048 - s) >>> 5));
            return 0;
        }
        this.f15280 -= i2;
        this.f15283 -= i2;
        sArr[i] = (short) (s - (s >>> 5));
        return 1;
    }
}
