package defpackage;

import java.io.DataInputStream;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.zip.CRC32;
import java.util.zip.CheckedInputStream;
import org.tukaani.xz.CorruptedInputException;
import org.tukaani.xz.XZIOException;

/* JADX INFO: renamed from: ᵲᵬ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C4528 {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public long f17228;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public long f17229;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public long f17230;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final CorruptedInputException f17231;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public long f17232;

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final AbstractC3852 f17233;

    public C4528() {
        CorruptedInputException corruptedInputException = new CorruptedInputException();
        this.f17228 = 0L;
        this.f17229 = 0L;
        this.f17232 = 0L;
        this.f17230 = 0L;
        this.f17231 = corruptedInputException;
        try {
            this.f17233 = new C3406(1);
        } catch (NoSuchAlgorithmException unused) {
            this.f17233 = new C3406(0);
        }
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final void m9569(InputStream inputStream) throws CorruptedInputException {
        CRC32 crc32 = new CRC32();
        crc32.update(0);
        CheckedInputStream checkedInputStream = new CheckedInputStream(inputStream, crc32);
        if (ᵽˊᵘᵬ.ᵵᵽ(checkedInputStream) != this.f17230) {
            throw new CorruptedInputException("XZ Block Header or the start of XZ Index is corrupt");
        }
        C4528 c4528 = new C4528();
        for (long j = 0; j < this.f17230; j++) {
            try {
                c4528.m9570(ᵽˊᵘᵬ.ᵵᵽ(checkedInputStream), ᵽˊᵘᵬ.ᵵᵽ(checkedInputStream));
                if (c4528.f17228 > this.f17228 || c4528.f17229 > this.f17229 || c4528.f17232 > this.f17232) {
                    throw new CorruptedInputException("XZ Index is corrupt");
                }
            } catch (XZIOException unused) {
                throw new CorruptedInputException("XZ Index is corrupt");
            }
        }
        if (c4528.f17228 != this.f17228 || c4528.f17229 != this.f17229 || c4528.f17232 != this.f17232 || !Arrays.equals(c4528.f17233.mo4103(), this.f17233.mo4103())) {
            throw new CorruptedInputException("XZ Index is corrupt");
        }
        DataInputStream dataInputStream = new DataInputStream(checkedInputStream);
        for (int i = (int) (3 & (4 - ((((long) (ᵽˊᵘᵬ.ᵝᵶ(this.f17230) + 1)) + this.f17232) + 4))); i > 0; i--) {
            if (dataInputStream.readUnsignedByte() != 0) {
                throw new CorruptedInputException("XZ Index is corrupt");
            }
        }
        long value = crc32.getValue();
        for (int i2 = 0; i2 < 4; i2++) {
            if (((value >>> (i2 * 8)) & 255) != dataInputStream.readUnsignedByte()) {
                throw new CorruptedInputException("XZ Index is corrupt");
            }
        }
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final void m9570(long j, long j2) throws CorruptedInputException {
        this.f17228 += (3 + j) & (-4);
        this.f17229 += j2;
        this.f17232 += (long) (ᵽˊᵘᵬ.ᵝᵶ(j2) + ᵽˊᵘᵬ.ᵝᵶ(j));
        long j3 = this.f17230 + 1;
        this.f17230 = j3;
        if (this.f17228 >= 0 && this.f17229 >= 0 && ((((long) (ᵽˊᵘᵬ.ᵝᵶ(j3) + 1)) + this.f17232 + 7) & (-4)) <= 17179869184L) {
            if (((((long) (ᵽˊᵘᵬ.ᵝᵶ(this.f17230) + 1)) + this.f17232 + 7) & (-4)) + this.f17228 + 12 + 12 >= 0) {
                ByteBuffer byteBufferAllocate = ByteBuffer.allocate(16);
                byteBufferAllocate.putLong(j);
                byteBufferAllocate.putLong(j2);
                byte[] bArrArray = byteBufferAllocate.array();
                AbstractC3852 abstractC3852 = this.f17233;
                abstractC3852.getClass();
                abstractC3852.mo4104(bArrArray, 0, bArrArray.length);
                return;
            }
        }
        throw this.f17231;
    }
}
