package com.appsflyer.internal;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public final class am extends FilterInputStream {

    /* renamed from: ˊ  reason: contains not printable characters */
    public long[] f2030 = new long[4];

    /* renamed from: ˋ  reason: contains not printable characters */
    public final int f2031;

    /* renamed from: ˎ  reason: contains not printable characters */
    public short f2032;

    /* renamed from: ˏ  reason: contains not printable characters */
    public int[] f2033;

    /* renamed from: ॱ  reason: contains not printable characters */
    public long[] f2034 = new long[4];

    /* renamed from: ॱॱ  reason: contains not printable characters */
    public int f2035;

    /* renamed from: ᐝ  reason: contains not printable characters */
    public int f2036;

    public am(InputStream inputStream, int i, int i2, short s, int i3, int i4) throws IOException {
        super(inputStream);
        this.f2031 = Math.min(Math.max((int) s, 4), 8);
        int i5 = this.f2031;
        this.f2033 = new int[i5];
        this.f2036 = i5;
        this.f2034 = al.m1201(i ^ i4, i5 ^ i4);
        this.f2030 = al.m1201(i2 ^ i4, i3 ^ i4);
        this.f2035 = ((FilterInputStream) this).in.read();
    }

    @Override // java.io.FilterInputStream, java.io.InputStream
    public final int available() throws IOException {
        return this.f2031 - this.f2036;
    }

    public final boolean markSupported() {
        return false;
    }

    @Override // java.io.FilterInputStream, java.io.InputStream
    public final int read(byte[] bArr, int i, int i2) throws IOException {
        if (i2 == 0) {
            return 0;
        }
        int read = read();
        if (read == -1) {
            return -1;
        }
        bArr[i] = (byte) read;
        int i3 = 1;
        while (i3 < i2) {
            int read2 = read();
            if (read2 == -1) {
                return i3;
            }
            bArr[i + i3] = (byte) read2;
            i3++;
        }
        return i3;
    }

    @Override // java.io.FilterInputStream, java.io.InputStream
    public final long skip(long j) throws IOException {
        long j2 = 0;
        while (j2 < j && read() != -1) {
            j2++;
        }
        return j2;
    }

    @Override // java.io.FilterInputStream, java.io.InputStream
    public final int read() throws IOException {
        if (this.f2036 == this.f2031) {
            int i = this.f2035;
            if (i == -1) {
                Arrays.fill(this.f2033, -1);
            } else {
                this.f2033[0] = i;
                for (int i2 = 1; i2 < this.f2031; i2++) {
                    this.f2033[i2] = ((FilterInputStream) this).in.read();
                }
                long[] jArr = this.f2034;
                long[] jArr2 = this.f2030;
                short s = this.f2032;
                int i3 = (s + 2) % 4;
                int i4 = (s + 3) % 4;
                jArr2[i4] = ((jArr[i4] * 2147483085) + jArr2[i3]) / 2147483647L;
                jArr[i4] = ((jArr[s % 4] * 2147483085) + jArr2[i3]) % 2147483647L;
                for (int i5 = 0; i5 < this.f2031; i5++) {
                    int[] iArr = this.f2033;
                    iArr[i5] = (int) (((long) iArr[i5]) ^ ((this.f2034[this.f2032] >> (i5 << 3)) & 255));
                }
                this.f2032 = (short) ((this.f2032 + 1) % 4);
                this.f2035 = ((FilterInputStream) this).in.read();
                if (this.f2035 == -1) {
                    int i6 = this.f2031;
                    int[] iArr2 = this.f2033;
                    Arrays.fill(iArr2, i6 - iArr2[i6 - 1], i6, -1);
                }
            }
            this.f2036 = 0;
        }
        int[] iArr3 = this.f2033;
        int i7 = this.f2036;
        this.f2036 = i7 + 1;
        return iArr3[i7];
    }
}
