package o; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public final class goS extends goU { private boolean b; private boolean c; private int d; private int e; /* JADX INFO: Access modifiers changed from: package-private */ public goS(InputStream inputStream, int i) throws IOException { super(inputStream, i); this.b = false; this.c = true; this.e = inputStream.read(); int read = inputStream.read(); this.d = read; if (read < 0) { throw new EOFException(); } a(); } /* JADX INFO: Access modifiers changed from: package-private */ public final void b(boolean z) { this.c = z; a(); } private boolean a() { if (!this.b && this.c && this.e == 0 && this.d == 0) { this.b = true; c(); } return this.b; } @Override // java.io.InputStream public final int read(byte[] bArr, int i, int i2) throws IOException { if (this.c || i2 < 3) { return super.read(bArr, i, i2); } if (this.b) { return -1; } int read = this.a.read(bArr, i + 2, i2 - 2); if (read < 0) { throw new EOFException(); } bArr[i] = (byte) this.e; bArr[i + 1] = (byte) this.d; this.e = this.a.read(); int read2 = this.a.read(); this.d = read2; if (read2 >= 0) { return read + 2; } throw new EOFException(); } @Override // java.io.InputStream public final int read() throws IOException { if (a()) { return -1; } int read = this.a.read(); if (read < 0) { throw new EOFException(); } int i = this.e; this.e = this.d; this.d = read; return i; } }