package defpackage;

import java.io.IOException;
import java.io.InputStream;
import java.io.PushbackInputStream;
import java.util.Iterator;
import java.util.List;
import java.util.zip.CRC32;
import net.lingala.zip4j.exception.ZipException;

/* JADX INFO: renamed from: ⁱˑ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C5555 extends InputStream {

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final PushbackInputStream f20957;

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public final C3185 f20958;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public AbstractC4623 f20961;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final char[] f20962;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public C1184 f20963;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final ᵯᵨᵲ f20960 = new ᵯᵨᵲ(19);

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public final CRC32 f20964 = new CRC32();

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public boolean f20956 = false;

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public boolean f20965 = false;

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public boolean f20959 = false;

    public C5555(InputStream inputStream, char[] cArr, C3185 c3185) {
        int i = c3185.f12092;
        if (i < 512) {
            ᵕᵩʽᵲ.ᵮᵣᵗˈ("Buffer size cannot be less than 512 bytes");
            throw null;
        }
        this.f20957 = new PushbackInputStream(inputStream, i);
        this.f20962 = cArr;
        this.f20958 = c3185;
    }

    @Override // java.io.InputStream
    public final int available() {
        if (!this.f20965) {
            return !this.f20959 ? 1 : 0;
        }
        C1685.m4568("Stream closed");
        return 0;
    }

    @Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
    public final void close() throws IOException {
        if (this.f20965) {
            return;
        }
        AbstractC4623 abstractC4623 = this.f20961;
        if (abstractC4623 != null) {
            abstractC4623.close();
        }
        this.f20965 = true;
    }

    @Override // java.io.InputStream
    public final int read() {
        byte[] bArr = new byte[1];
        if (read(bArr, 0, 1) == -1) {
            return -1;
        }
        return bArr[0] & 255;
    }

    @Override // java.io.InputStream
    public final int read(byte[] bArr) {
        return read(bArr, 0, bArr.length);
    }

    @Override // java.io.InputStream
    public final int read(byte[] bArr, int i, int i2) throws IOException {
        if (this.f20965) {
            C1685.m4568("Stream closed");
            return 0;
        }
        if (i2 < 0) {
            ᵕᵩʽᵲ.ᵮᵣᵗˈ("Negative read length");
            return 0;
        }
        if (i2 == 0) {
            return 0;
        }
        if (this.f20963 == null) {
            return -1;
        }
        try {
            int i3 = this.f20961.read(bArr, i, i2);
            if (i3 == -1) {
                m11184();
                return i3;
            }
            this.f20964.update(bArr, i, i3);
            return i3;
        } catch (IOException e) {
            C1184 c1184 = this.f20963;
            if (c1184.f15135 && AbstractC3653.m8217(2, c1184.f15133)) {
                throw new ZipException(e.getMessage(), e.getCause());
            }
            throw e;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:18:0x0057  */
    /* JADX WARN: Removed duplicated region for block: B:20:0x0060  */
    /* JADX WARN: Removed duplicated region for block: B:21:0x0071  */
    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m11184() throws ZipException {
        boolean z;
        long jM7082;
        long jM7083;
        long jM70832;
        AbstractC4623 abstractC4623 = this.f20961;
        PushbackInputStream pushbackInputStream = this.f20957;
        this.f20961.mo3663(pushbackInputStream, abstractC4623.mo3662(pushbackInputStream));
        C1184 c1184 = this.f20963;
        if (c1184.f15132 && !this.f20956) {
            List list = c1184.f15146;
            if (list == null) {
                z = false;
                ᵯᵨᵲ r5 = this.f20960;
                r5.getClass();
                byte[] bArr = new byte[4];
                ᵺᵘ.ˉᵵᵜ(pushbackInputStream, bArr);
                C2994 c2994 = (C2994) r5.ᵔᵖᵹᵫ;
                byte[] bArr2 = (byte[]) c2994.f11536;
                jM7082 = c2994.m7082(0, bArr);
                if (jM7082 == 134695760) {
                    ᵺᵘ.ˉᵵᵜ(pushbackInputStream, bArr);
                    jM7082 = c2994.m7082(0, bArr);
                }
                if (z) {
                    jM7083 = c2994.m7083(pushbackInputStream);
                    jM70832 = c2994.m7083(pushbackInputStream);
                } else {
                    C2994.m7074(pushbackInputStream, bArr2, bArr2.length);
                    jM7083 = c2994.m7082(0, bArr2);
                    C2994.m7074(pushbackInputStream, bArr2, bArr2.length);
                    jM70832 = c2994.m7082(0, bArr2);
                }
                C1184 c11842 = this.f20963;
                c11842.f15138 = jM7083;
                c11842.f15148 = jM70832;
                c11842.f15134 = jM7082;
            } else {
                Iterator it = list.iterator();
                while (it.hasNext()) {
                    if (((C3922) it.next()).f14971 == 1) {
                        z = true;
                        break;
                    }
                }
                z = false;
                ᵯᵨᵲ r52 = this.f20960;
                r52.getClass();
                byte[] bArr3 = new byte[4];
                ᵺᵘ.ˉᵵᵜ(pushbackInputStream, bArr3);
                C2994 c29942 = (C2994) r52.ᵔᵖᵹᵫ;
                byte[] bArr22 = (byte[]) c29942.f11536;
                jM7082 = c29942.m7082(0, bArr3);
                if (jM7082 == 134695760) {
                }
                if (z) {
                }
                C1184 c118422 = this.f20963;
                c118422.f15138 = jM7083;
                c118422.f15148 = jM70832;
                c118422.f15134 = jM7082;
            }
        }
        C1184 c11843 = this.f20963;
        int i = c11843.f15133;
        CRC32 crc32 = this.f20964;
        if ((i == 4 && AbstractC3653.m8217(c11843.f15136.f18162, 2)) || this.f20963.f15134 == crc32.getValue()) {
            this.f20963 = null;
            crc32.reset();
            this.f20959 = true;
        } else {
            C1184 c11844 = this.f20963;
            if (c11844.f15135) {
                AbstractC3653.m8217(2, c11844.f15133);
            }
            throw new ZipException("Reached end of entry, but crc verification failed for " + this.f20963.f15143);
        }
    }
}
