package m4;

import java.io.IOException;
import java.io.InputStream;

/* JADX INFO: renamed from: m4.j, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1174j extends InputStream {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public int f14627q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public int f14628r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final /* synthetic */ C1176l f14629s;

    public C1174j(C1176l c1176l, C1173i c1173i) {
        this.f14629s = c1176l;
        this.f14627q = c1176l.O(c1173i.f14625a + 4);
        this.f14628r = c1173i.f14626b;
    }

    @Override // java.io.InputStream
    public final int read(byte[] bArr, int i, int i5) throws IOException {
        if (bArr == null) {
            throw new NullPointerException("buffer");
        }
        if ((i | i5) < 0 || i5 > bArr.length - i) {
            throw new ArrayIndexOutOfBoundsException();
        }
        int i8 = this.f14628r;
        if (i8 <= 0) {
            return -1;
        }
        if (i5 > i8) {
            i5 = i8;
        }
        int i9 = this.f14627q;
        C1176l c1176l = this.f14629s;
        c1176l.A(i9, i, i5, bArr);
        this.f14627q = c1176l.O(this.f14627q + i5);
        this.f14628r -= i5;
        return i5;
    }

    @Override // java.io.InputStream
    public final int read() throws IOException {
        if (this.f14628r == 0) {
            return -1;
        }
        C1176l c1176l = this.f14629s;
        c1176l.f14631q.seek(this.f14627q);
        int i = c1176l.f14631q.read();
        this.f14627q = c1176l.O(this.f14627q + 1);
        this.f14628r--;
        return i;
    }
}
