package defpackage;

import java.io.EOFException;
import java.io.IOException;
import java.util.zip.CRC32;
import java.util.zip.Inflater;

/* JADX INFO: renamed from: ᵠᵿː, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C3179 implements InterfaceC3906 {

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public byte f12070;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final Inflater f12071;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final C1978 f12072;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final C0262 f12073;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public final CRC32 f12074;

    public C3179(InterfaceC2322 interfaceC2322) {
        C1978 c1978 = new C1978(interfaceC2322);
        this.f12072 = c1978;
        Inflater inflater = new Inflater(true);
        this.f12071 = inflater;
        this.f12073 = new C0262(c1978, inflater);
        this.f12074 = new CRC32();
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public static void m7283(int i, int i2, String str) throws IOException {
        if (i2 == i) {
            return;
        }
        throw new IOException(str + ": actual 0x" + AbstractC3801.m8494(8, ᵻᵪ.ˊᵡᵗʨ(i2)) + " != expected 0x" + AbstractC3801.m8494(8, ᵻᵪ.ˊᵡᵗʨ(i)));
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() throws IOException {
        this.f12073.close();
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final void m7284(C4903 c4903, long j, long j2) {
        C2131 c2131 = c4903.f18671;
        while (true) {
            int i = c2131.f8449;
            int i2 = c2131.f8448;
            if (j < i - i2) {
                break;
            }
            j -= (long) (i - i2);
            c2131 = c2131.f8454;
        }
        while (j2 > 0) {
            int i3 = (int) (((long) c2131.f8448) + j);
            int iMin = (int) Math.min(c2131.f8449 - i3, j2);
            this.f12074.update(c2131.f8451, i3, iMin);
            j2 -= (long) iMin;
            c2131 = c2131.f8454;
            j = 0;
        }
    }

    @Override // defpackage.InterfaceC3906
    /* JADX INFO: renamed from: ᵪᵹᵥᵻ */
    public final long mo1490(C4903 c4903, long j) throws IOException {
        C3179 c3179 = this;
        byte b = c3179.f12070;
        CRC32 crc32 = c3179.f12074;
        C1978 c1978 = c3179.f12072;
        if (b == 0) {
            c1978.mo5353(10L);
            C4903 c49032 = c1978.f7849;
            byte bM10213 = c49032.m10213(3L);
            boolean z = ((bM10213 >> 1) & 1) == 1;
            if (z) {
                c3179.m7284(c49032, 0L, 10L);
            }
            m7283(8075, c1978.readShort(), "ID1ID2");
            c1978.skip(8L);
            if (((bM10213 >> 2) & 1) == 1) {
                c1978.mo5353(2L);
                if (z) {
                    m7284(c49032, 0L, 2L);
                }
                long jM10205 = c49032.m10205() & 65535;
                c1978.mo5353(jM10205);
                if (z) {
                    m7284(c49032, 0L, jM10205);
                }
                c1978.skip(jM10205);
            }
            if (((bM10213 >> 3) & 1) == 1) {
                long jM5356 = c1978.m5356((byte) 0, 0L, Long.MAX_VALUE);
                if (jM5356 == -1) {
                    throw new EOFException();
                }
                if (z) {
                    m7284(c49032, 0L, jM5356 + 1);
                }
                c1978.skip(jM5356 + 1);
            }
            if (((bM10213 >> 4) & 1) == 1) {
                long jM53562 = c1978.m5356((byte) 0, 0L, Long.MAX_VALUE);
                if (jM53562 == -1) {
                    throw new EOFException();
                }
                if (z) {
                    c3179 = this;
                    c3179.m7284(c49032, 0L, jM53562 + 1);
                } else {
                    c3179 = this;
                }
                c1978.skip(jM53562 + 1);
            } else {
                c3179 = this;
            }
            if (z) {
                m7283(c1978.m5355(), (short) crc32.getValue(), "FHCRC");
                crc32.reset();
            }
            c3179.f12070 = (byte) 1;
        }
        if (c3179.f12070 == 1) {
            long j2 = c4903.f18672;
            long jMo1490 = c3179.f12073.mo1490(c4903, 8192L);
            if (jMo1490 != -1) {
                c3179.m7284(c4903, j2, jMo1490);
                return jMo1490;
            }
            c3179.f12070 = (byte) 2;
        }
        if (c3179.f12070 == 2) {
            m7283(c1978.m5350(), (int) crc32.getValue(), "CRC");
            m7283(c1978.m5350(), (int) c3179.f12071.getBytesWritten(), "ISIZE");
            c3179.f12070 = (byte) 3;
            if (!c1978.mo5344()) {
                C1685.m4568("gzip finished without exhausting source");
                return 0L;
            }
        }
        return -1L;
    }

    @Override // defpackage.InterfaceC3906
    /* JADX INFO: renamed from: ᵻʽᵯ */
    public final C2466 mo1491() {
        return this.f12072.f7847.mo1491();
    }
}
