package o; import com.google.common.primitives.UnsignedBytes; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.charset.Charset; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import net.sf.scuba.smartcards.ISO7816; import net.sf.scuba.smartcards.ISOFileInfo; import okhttp3.internal.connection.RealConnection; import org.jmrtd.PassportService; /* loaded from: classes6.dex */ public final class giM implements Cloneable, giO, InterfaceC15142giR { private static final byte[] d = {ISO7816.INS_DECREASE, 49, ISO7816.INS_INCREASE, 51, ISO7816.INS_DECREASE_STAMPED, 53, 54, 55, 56, 57, 97, ISOFileInfo.FCP_BYTE, 99, ISOFileInfo.FMD_BYTE, 101, 102}; public long a; C15186gjg c; @Override // o.giO, o.InterfaceC15142giR public final giM b() { return this; } @Override // o.giO public final /* bridge */ /* synthetic */ giO c() throws IOException { return this; } @Override // o.giX, java.io.Closeable, java.lang.AutoCloseable public final void close() { } @Override // o.giO public final giO e() { return this; } @Override // o.giX, java.io.Flushable public final void flush() { } @Override // o.giO public final OutputStream h() { return new OutputStream(this) { // from class: o.giM.4 private giM e; @Override // java.io.OutputStream, java.io.Closeable, java.lang.AutoCloseable public final void close() { } @Override // java.io.OutputStream, java.io.Flushable public final void flush() { } { this.e = this; } @Override // java.io.OutputStream public final void write(int i) { this.e.b((int) ((byte) i)); } @Override // java.io.OutputStream public final void write(byte[] bArr, int i, int i2) { this.e.a(bArr, i, i2); } public final String toString() { StringBuilder sb = new StringBuilder(); sb.append(this); sb.append(".outputStream()"); return sb.toString(); } }; } @Override // o.InterfaceC15142giR public final void j(long j) throws EOFException { if (this.a < j) { throw new EOFException(); } } /* renamed from: o.giM$3, reason: invalid class name */ /* loaded from: classes6.dex */ public class AnonymousClass3 extends InputStream { private giM e; @Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable public final void close() { } public AnonymousClass3(giM gim) { this.e = gim; } @Override // java.io.InputStream public final int read() { if (this.e.a > 0) { return this.e.i() & UnsignedBytes.MAX_VALUE; } return -1; } @Override // java.io.InputStream public final int read(byte[] bArr, int i, int i2) { return this.e.b(bArr, i, i2); } @Override // java.io.InputStream public final int available() { return (int) Math.min(this.e.a, 2147483647L); } public final String toString() { StringBuilder sb = new StringBuilder(); sb.append(this.e); sb.append(".inputStream()"); return sb.toString(); } } @Override // o.InterfaceC15142giR public final InputStream g() { return new AnonymousClass3(this); } public final giM d(giM gim, long j, long j2) { if (gim == null) { throw new IllegalArgumentException("out == null"); } C15183gjd.e(this.a, j, j2); if (j2 == 0) { return this; } gim.a += j2; C15186gjg c15186gjg = this.c; while (j >= c15186gjg.c - c15186gjg.g) { j -= c15186gjg.c - c15186gjg.g; c15186gjg = c15186gjg.b; } while (j2 > 0) { C15186gjg c15186gjg2 = new C15186gjg(c15186gjg); c15186gjg2.g = (int) (c15186gjg2.g + j); c15186gjg2.c = Math.min(c15186gjg2.g + ((int) j2), c15186gjg2.c); C15186gjg c15186gjg3 = gim.c; if (c15186gjg3 == null) { c15186gjg2.e = c15186gjg2; c15186gjg2.b = c15186gjg2; gim.c = c15186gjg2; } else { C15186gjg c15186gjg4 = c15186gjg3.e; c15186gjg2.e = c15186gjg4; c15186gjg2.b = c15186gjg4.b; c15186gjg4.b.e = c15186gjg2; c15186gjg4.b = c15186gjg2; } j2 -= c15186gjg2.c - c15186gjg2.g; c15186gjg = c15186gjg.b; j = 0; } return this; } @Override // o.InterfaceC15142giR public final byte i() { if (this.a == 0) { throw new IllegalStateException("size == 0"); } C15186gjg c15186gjg = this.c; int i = c15186gjg.g; int i2 = c15186gjg.c; int i3 = i + 1; byte b = c15186gjg.a[i]; this.a--; if (i3 == i2) { this.c = c15186gjg.b(); C15184gje.c(c15186gjg); } else { c15186gjg.g = i3; } return b; } public final byte b(long j) { C15183gjd.e(this.a, j, 1L); C15186gjg c15186gjg = this.c; while (true) { long j2 = c15186gjg.c - c15186gjg.g; if (j >= j2) { j -= j2; c15186gjg = c15186gjg.b; } else { return c15186gjg.a[c15186gjg.g + ((int) j)]; } } } @Override // o.InterfaceC15142giR public final short o() { int i; int i2; if (this.a < 2) { StringBuilder sb = new StringBuilder("size < 2: "); sb.append(this.a); throw new IllegalStateException(sb.toString()); } C15186gjg c15186gjg = this.c; int i3 = c15186gjg.g; int i4 = c15186gjg.c; if (i4 - i3 < 2) { i = (i() & UnsignedBytes.MAX_VALUE) << 8; i2 = i() & UnsignedBytes.MAX_VALUE; } else { byte[] bArr = c15186gjg.a; byte b = bArr[i3]; int i5 = i3 + 2; byte b2 = bArr[i3 + 1]; this.a -= 2; if (i5 == i4) { this.c = c15186gjg.b(); C15184gje.c(c15186gjg); } else { c15186gjg.g = i5; } i = b2 & UnsignedBytes.MAX_VALUE; i2 = (b & UnsignedBytes.MAX_VALUE) << 8; } return (short) (i | i2); } @Override // o.InterfaceC15142giR public final int k() { int i; int i2; if (this.a < 4) { StringBuilder sb = new StringBuilder("size < 4: "); sb.append(this.a); throw new IllegalStateException(sb.toString()); } C15186gjg c15186gjg = this.c; int i3 = c15186gjg.g; int i4 = c15186gjg.c; if (i4 - i3 < 4) { i = ((i() & UnsignedBytes.MAX_VALUE) << 24) | ((i() & UnsignedBytes.MAX_VALUE) << 16) | ((i() & UnsignedBytes.MAX_VALUE) << 8); i2 = i() & UnsignedBytes.MAX_VALUE; } else { byte[] bArr = c15186gjg.a; byte b = bArr[i3]; byte b2 = bArr[i3 + 1]; byte b3 = bArr[i3 + 2]; int i5 = i3 + 4; byte b4 = bArr[i3 + 3]; this.a -= 4; if (i5 == i4) { this.c = c15186gjg.b(); C15184gje.c(c15186gjg); } else { c15186gjg.g = i5; } i = b4 & UnsignedBytes.MAX_VALUE; i2 = ((b2 & UnsignedBytes.MAX_VALUE) << 16) | ((b & UnsignedBytes.MAX_VALUE) << 24) | ((b3 & UnsignedBytes.MAX_VALUE) << 8); } return i | i2; } @Override // o.InterfaceC15142giR public final short m() { return C15183gjd.c(o()); } @Override // o.InterfaceC15142giR public final int n() { return C15183gjd.c(k()); } /* JADX WARN: Removed duplicated region for block: B:35:0x0093 */ /* JADX WARN: Removed duplicated region for block: B:37:0x00a1 */ /* JADX WARN: Removed duplicated region for block: B:46:0x00a5 A[EDGE_INSN: B:46:0x00a5->B:40:0x00a5 BREAK A[LOOP:0: B:4:0x000f->B:45:?], SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:47:0x009d */ @Override // o.InterfaceC15142giR /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final long f() { /* r15 = this; long r0 = r15.a r2 = 0 int r0 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1)) if (r0 == 0) goto Laf r0 = 0 r4 = -7 r1 = r0 r5 = r4 r3 = r2 r2 = r1 Lf: o.gjg r7 = r15.c byte[] r8 = r7.a int r9 = r7.g int r10 = r7.c L17: if (r9 >= r10) goto L91 r11 = r8[r9] r12 = 48 if (r11 < r12) goto L65 r12 = 57 if (r11 > r12) goto L65 int r12 = 48 - r11 r13 = -922337203685477580(0xf333333333333334, double:-8.390303882365713E246) int r13 = (r3 > r13 ? 1 : (r3 == r13 ? 0 : -1)) if (r13 < 0) goto L3b if (r13 != 0) goto L35 long r13 = (long) r12 int r13 = (r13 > r5 ? 1 : (r13 == r5 ? 0 : -1)) if (r13 < 0) goto L3b L35: r13 = 10 long r3 = r3 * r13 long r11 = (long) r12 long r3 = r3 + r11 goto L70 L3b: o.giM r1 = new o.giM r1.() o.giM r1 = r1.i(r3) o.giM r1 = r1.b(r11) if (r0 != 0) goto L4d r1.i() L4d: java.lang.NumberFormatException r0 = new java.lang.NumberFormatException java.lang.StringBuilder r2 = new java.lang.StringBuilder java.lang.String r3 = "Number too large: " r2.(r3) java.lang.String r1 = r1.q() r2.append(r1) java.lang.String r1 = r2.toString() r0.(r1) throw r0 L65: r12 = 45 r13 = 1 if (r11 != r12) goto L75 if (r1 != 0) goto L75 r11 = 1 long r5 = r5 - r11 r0 = r13 L70: int r9 = r9 + 1 int r1 = r1 + 1 goto L17 L75: if (r1 == 0) goto L79 r2 = r13 goto L91 L79: java.lang.StringBuilder r0 = new java.lang.StringBuilder java.lang.String r1 = "Expected leading [0-9] or '-' character but was 0x" r0.(r1) java.lang.NumberFormatException r1 = new java.lang.NumberFormatException java.lang.String r2 = java.lang.Integer.toHexString(r11) r0.append(r2) java.lang.String r0 = r0.toString() r1.(r0) throw r1 L91: if (r9 != r10) goto L9d o.gjg r8 = r7.b() r15.c = r8 o.C15184gje.c(r7) goto L9f L9d: r7.g = r9 L9f: if (r2 != 0) goto La5 o.gjg r7 = r15.c if (r7 != 0) goto Lf La5: long r5 = r15.a long r1 = (long) r1 long r5 = r5 - r1 r15.a = r5 if (r0 != 0) goto Lae long r3 = -r3 Lae: return r3 Laf: java.lang.IllegalStateException r0 = new java.lang.IllegalStateException java.lang.String r1 = "size == 0" r0.(r1) throw r0 */ throw new UnsupportedOperationException("Method not decompiled: o.giM.f():long"); } /* JADX WARN: Removed duplicated region for block: B:32:0x008a */ /* JADX WARN: Removed duplicated region for block: B:34:0x0098 */ /* JADX WARN: Removed duplicated region for block: B:40:0x009c A[EDGE_INSN: B:40:0x009c->B:37:0x009c BREAK A[LOOP:0: B:4:0x000b->B:39:?], SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:41:0x0094 */ @Override // o.InterfaceC15142giR /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final long l() { /* r14 = this; long r0 = r14.a r2 = 0 int r0 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1)) if (r0 == 0) goto La3 r0 = 0 r1 = r0 r4 = r2 Lb: o.gjg r6 = r14.c byte[] r7 = r6.a int r8 = r6.g int r9 = r6.c L13: if (r8 >= r9) goto L88 r10 = r7[r8] r11 = 48 if (r10 < r11) goto L22 r11 = 57 if (r10 > r11) goto L22 int r11 = r10 + (-48) goto L37 L22: r11 = 97 if (r10 < r11) goto L2d r11 = 102(0x66, float:1.43E-43) if (r10 > r11) goto L2d int r11 = r10 + (-87) goto L37 L2d: r11 = 65 if (r10 < r11) goto L6c r11 = 70 if (r10 > r11) goto L6c int r11 = r10 + (-55) L37: r12 = -1152921504606846976(0xf000000000000000, double:-3.105036184601418E231) long r12 = r12 & r4 int r12 = (r12 > r2 ? 1 : (r12 == r2 ? 0 : -1)) if (r12 != 0) goto L47 r10 = 4 long r4 = r4 << r10 long r10 = (long) r11 long r4 = r4 | r10 int r8 = r8 + 1 int r0 = r0 + 1 goto L13 L47: o.giM r0 = new o.giM r0.() o.giM r0 = r0.k(r4) o.giM r0 = r0.b(r10) java.lang.NumberFormatException r1 = new java.lang.NumberFormatException java.lang.StringBuilder r2 = new java.lang.StringBuilder java.lang.String r3 = "Number too large: " r2.(r3) java.lang.String r0 = r0.q() r2.append(r0) java.lang.String r0 = r2.toString() r1.(r0) throw r1 L6c: if (r0 == 0) goto L70 r1 = 1 goto L88 L70: java.lang.StringBuilder r0 = new java.lang.StringBuilder java.lang.String r1 = "Expected leading [0-9a-fA-F] character but was 0x" r0.(r1) java.lang.NumberFormatException r1 = new java.lang.NumberFormatException java.lang.String r2 = java.lang.Integer.toHexString(r10) r0.append(r2) java.lang.String r0 = r0.toString() r1.(r0) throw r1 L88: if (r8 != r9) goto L94 o.gjg r7 = r6.b() r14.c = r7 o.C15184gje.c(r6) goto L96 L94: r6.g = r8 L96: if (r1 != 0) goto L9c o.gjg r6 = r14.c if (r6 != 0) goto Lb L9c: long r1 = r14.a long r6 = (long) r0 long r1 = r1 - r6 r14.a = r1 return r4 La3: java.lang.IllegalStateException r0 = new java.lang.IllegalStateException java.lang.String r1 = "size == 0" r0.(r1) throw r0 */ throw new UnsupportedOperationException("Method not decompiled: o.giM.l():long"); } @Override // o.InterfaceC15142giR public final giP e(long j) throws EOFException { return new giP(d(j)); } public final String q() { try { return a(this.a, C15183gjd.e); } catch (EOFException e) { throw new AssertionError(e); } } private String a(long j, Charset charset) throws EOFException { C15183gjd.e(this.a, 0L, j); if (charset == null) { throw new IllegalArgumentException("charset == null"); } if (j > 2147483647L) { throw new IllegalArgumentException("byteCount > Integer.MAX_VALUE: ".concat(String.valueOf(j))); } if (j == 0) { return ""; } C15186gjg c15186gjg = this.c; if (c15186gjg.g + j > c15186gjg.c) { return new String(d(j), charset); } String str = new String(c15186gjg.a, c15186gjg.g, (int) j, charset); c15186gjg.g = (int) (c15186gjg.g + j); this.a -= j; if (c15186gjg.g == c15186gjg.c) { this.c = c15186gjg.b(); C15184gje.c(c15186gjg); } return str; } /* JADX INFO: Access modifiers changed from: package-private */ public final String c(long j) throws EOFException { if (j > 0) { long j2 = j - 1; if (b(j2) == 13) { String a = a(j2, C15183gjd.e); f(2L); return a; } } String a2 = a(j, C15183gjd.e); f(1L); return a2; } @Override // o.InterfaceC15142giR public final byte[] j() { try { return d(this.a); } catch (EOFException e) { throw new AssertionError(e); } } @Override // o.InterfaceC15142giR public final byte[] d(long j) throws EOFException { C15183gjd.e(this.a, 0L, j); if (j > 2147483647L) { throw new IllegalArgumentException("byteCount > Integer.MAX_VALUE: ".concat(String.valueOf(j))); } byte[] bArr = new byte[(int) j]; d(bArr); return bArr; } private void d(byte[] bArr) throws EOFException { int i = 0; while (i < bArr.length) { int b = b(bArr, i, bArr.length - i); if (b == -1) { throw new EOFException(); } i += b; } } public final int b(byte[] bArr, int i, int i2) { C15183gjd.e(bArr.length, i, i2); C15186gjg c15186gjg = this.c; if (c15186gjg == null) { return -1; } int min = Math.min(i2, c15186gjg.c - c15186gjg.g); System.arraycopy(c15186gjg.a, c15186gjg.g, bArr, i, min); c15186gjg.g += min; this.a -= min; if (c15186gjg.g == c15186gjg.c) { this.c = c15186gjg.b(); C15184gje.c(c15186gjg); } return min; } @Override // o.InterfaceC15142giR public final void f(long j) throws EOFException { while (j > 0) { if (this.c == null) { throw new EOFException(); } int min = (int) Math.min(j, r0.c - this.c.g); long j2 = min; this.a -= j2; j -= j2; this.c.g += min; if (this.c.g == this.c.c) { C15186gjg c15186gjg = this.c; this.c = c15186gjg.b(); C15184gje.c(c15186gjg); } } } @Override // o.giO /* renamed from: c, reason: merged with bridge method [inline-methods] */ public final giM e(giP gip) { if (gip == null) { throw new IllegalArgumentException("byteString == null"); } byte[] bArr = gip.d; a(bArr, 0, bArr.length); return this; } public final giM b(String str, int i, int i2) { if (str == null) { throw new IllegalArgumentException("string == null"); } if (i < 0) { throw new IllegalAccessError("beginIndex < 0: ".concat(String.valueOf(i))); } if (i2 < i) { StringBuilder sb = new StringBuilder("endIndex < beginIndex: "); sb.append(i2); sb.append(" < "); sb.append(i); throw new IllegalArgumentException(sb.toString()); } if (i2 > str.length()) { StringBuilder sb2 = new StringBuilder("endIndex > string.length: "); sb2.append(i2); sb2.append(" > "); sb2.append(str.length()); throw new IllegalArgumentException(sb2.toString()); } while (i < i2) { char charAt = str.charAt(i); if (charAt < 128) { C15186gjg e = e(1); byte[] bArr = e.a; int i3 = e.c - i; int min = Math.min(i2, 2048 - i3); bArr[i + i3] = (byte) charAt; i++; while (i < min) { char charAt2 = str.charAt(i); if (charAt2 >= 128) { break; } bArr[i + i3] = (byte) charAt2; i++; } int i4 = (i3 + i) - e.c; e.c += i4; this.a += i4; } else { if (charAt < 2048) { b((charAt >> 6) | 192); b((charAt & '?') | 128); } else if (charAt < 55296 || charAt > 57343) { b((charAt >> '\f') | PassportService.DEFAULT_MAX_BLOCKSIZE); b(((charAt >> 6) & 63) | 128); b((charAt & '?') | 128); } else { int i5 = i + 1; char charAt3 = i5 < i2 ? str.charAt(i5) : (char) 0; if (charAt > 56319 || charAt3 < 56320 || charAt3 > 57343) { b(63); i = i5; } else { int i6 = (((charAt & 10239) << 10) | (9215 & charAt3)) + 65536; b((i6 >> 18) | 240); b(((i6 >> 12) & 63) | 128); b(((i6 >> 6) & 63) | 128); b((i6 & 63) | 128); i += 2; } } i++; } } return this; } public final giM i(int i) { if (i < 128) { b(i); } else if (i < 2048) { b((i >> 6) | 192); b((i & 63) | 128); } else if (i < 65536) { if (i >= 55296 && i <= 57343) { StringBuilder sb = new StringBuilder("Unexpected code point: "); sb.append(Integer.toHexString(i)); throw new IllegalArgumentException(sb.toString()); } b((i >> 12) | PassportService.DEFAULT_MAX_BLOCKSIZE); b(((i >> 6) & 63) | 128); b((i & 63) | 128); } else if (i <= 1114111) { b((i >> 18) | 240); b(((i >> 12) & 63) | 128); b(((i >> 6) & 63) | 128); b((i & 63) | 128); } else { StringBuilder sb2 = new StringBuilder("Unexpected code point: "); sb2.append(Integer.toHexString(i)); throw new IllegalArgumentException(sb2.toString()); } return this; } @Override // o.giO /* renamed from: e, reason: merged with bridge method [inline-methods] */ public final giM a(byte[] bArr, int i, int i2) { if (bArr == null) { throw new IllegalArgumentException("source == null"); } long j = i2; C15183gjd.e(bArr.length, i, j); int i3 = i2 + i; while (i < i3) { C15186gjg e = e(1); int min = Math.min(i3 - i, 2048 - e.c); System.arraycopy(bArr, i, e.a, e.c, min); i += min; e.c += min; } this.a += j; return this; } @Override // o.giO public final long d(giZ giz) throws IOException { if (giz == null) { throw new IllegalArgumentException("source == null"); } long j = 0; while (true) { long read = giz.read(this, 2048L); if (read == -1) { return j; } j += read; } } @Override // o.giO /* renamed from: c, reason: merged with bridge method [inline-methods] */ public final giM b(int i) { C15186gjg e = e(1); byte[] bArr = e.a; int i2 = e.c; e.c = i2 + 1; bArr[i2] = (byte) i; this.a++; return this; } @Override // o.giO /* renamed from: h, reason: merged with bridge method [inline-methods] */ public final giM g(int i) { C15186gjg e = e(2); byte[] bArr = e.a; int i2 = e.c; bArr[i2] = (byte) (i >>> 8); bArr[i2 + 1] = (byte) i; e.c = i2 + 2; this.a += 2; return this; } @Override // o.giO /* renamed from: a, reason: merged with bridge method [inline-methods] */ public final giM d(int i) { C15186gjg e = e(4); byte[] bArr = e.a; int i2 = e.c; bArr[i2] = (byte) (i >>> 24); bArr[i2 + 1] = (byte) (i >>> 16); bArr[i2 + 2] = (byte) (i >>> 8); bArr[i2 + 3] = (byte) i; e.c = i2 + 4; this.a += 4; return this; } @Override // o.giO /* renamed from: h, reason: merged with bridge method [inline-methods] */ public final giM i(long j) { if (j == 0) { return b(48); } boolean z = false; if (j < 0) { j = -j; if (j < 0) { return b("-9223372036854775808", 0, 20); } z = true; } int i = j < 100000000 ? j < 10000 ? j < 100 ? j >= 10 ? 2 : 1 : j < 1000 ? 3 : 4 : j < 1000000 ? j < 100000 ? 5 : 6 : j < 10000000 ? 7 : 8 : j < 1000000000000L ? j < RealConnection.IDLE_CONNECTION_HEALTHY_NS ? j < 1000000000 ? 9 : 10 : j < 100000000000L ? 11 : 12 : j < 1000000000000000L ? j < 10000000000000L ? 13 : j < 100000000000000L ? 14 : 15 : j < 100000000000000000L ? j < 10000000000000000L ? 16 : 17 : j < 1000000000000000000L ? 18 : 19; if (z) { i++; } C15186gjg e = e(i); byte[] bArr = e.a; int i2 = e.c + i; while (j != 0) { i2--; bArr[i2] = d[(int) (j % 10)]; j /= 10; } if (z) { bArr[i2 - 1] = 45; } e.c += i; this.a += i; return this; } @Override // o.giO /* renamed from: g, reason: merged with bridge method [inline-methods] */ public final giM k(long j) { if (j == 0) { return b(48); } int numberOfTrailingZeros = (Long.numberOfTrailingZeros(Long.highestOneBit(j)) / 4) + 1; C15186gjg e = e(numberOfTrailingZeros); byte[] bArr = e.a; int i = e.c; for (int i2 = (e.c + numberOfTrailingZeros) - 1; i2 >= i; i2--) { bArr[i2] = d[(int) (15 & j)]; j >>>= 4; } e.c += numberOfTrailingZeros; this.a += numberOfTrailingZeros; return this; } /* JADX INFO: Access modifiers changed from: package-private */ public final C15186gjg e(int i) { if (i <= 0 || i > 2048) { throw new IllegalArgumentException(); } C15186gjg c15186gjg = this.c; if (c15186gjg == null) { C15186gjg a = C15184gje.a(); this.c = a; a.e = a; a.b = a; return a; } C15186gjg c15186gjg2 = c15186gjg.e; if (c15186gjg2.c + i <= 2048 && c15186gjg2.d) { return c15186gjg2; } C15186gjg a2 = C15184gje.a(); a2.e = c15186gjg2; a2.b = c15186gjg2.b; c15186gjg2.b.e = a2; c15186gjg2.b = a2; return a2; } @Override // o.giX public final void write(giM gim, long j) { if (gim == null) { throw new IllegalArgumentException("source == null"); } if (gim == this) { throw new IllegalArgumentException("source == this"); } C15183gjd.e(gim.a, 0L, j); while (j > 0) { if (j < gim.c.c - gim.c.g) { C15186gjg c15186gjg = this.c; C15186gjg c15186gjg2 = c15186gjg != null ? c15186gjg.e : null; if (c15186gjg2 != null && c15186gjg2.d) { if ((c15186gjg2.c + j) - (c15186gjg2.h ? 0 : c15186gjg2.g) <= 2048) { gim.c.a(c15186gjg2, (int) j); gim.a -= j; this.a += j; return; } } C15186gjg c15186gjg3 = gim.c; int i = (int) j; if (i <= 0 || i > c15186gjg3.c - c15186gjg3.g) { throw new IllegalArgumentException(); } C15186gjg c15186gjg4 = new C15186gjg(c15186gjg3); c15186gjg4.c = c15186gjg4.g + i; c15186gjg3.g += i; C15186gjg c15186gjg5 = c15186gjg3.e; c15186gjg4.e = c15186gjg5; c15186gjg4.b = c15186gjg5.b; c15186gjg5.b.e = c15186gjg4; c15186gjg5.b = c15186gjg4; gim.c = c15186gjg4; } C15186gjg c15186gjg6 = gim.c; long j2 = c15186gjg6.c - c15186gjg6.g; gim.c = c15186gjg6.b(); C15186gjg c15186gjg7 = this.c; if (c15186gjg7 == null) { this.c = c15186gjg6; c15186gjg6.e = c15186gjg6; c15186gjg6.b = c15186gjg6; } else { C15186gjg c15186gjg8 = c15186gjg7.e; c15186gjg6.e = c15186gjg8; c15186gjg6.b = c15186gjg8.b; c15186gjg8.b.e = c15186gjg6; c15186gjg8.b = c15186gjg6; C15186gjg c15186gjg9 = c15186gjg6.e; if (c15186gjg9 == c15186gjg6) { throw new IllegalStateException(); } if (c15186gjg9.d) { int i2 = c15186gjg6.c - c15186gjg6.g; if (i2 <= (2048 - c15186gjg9.c) + (c15186gjg9.h ? 0 : c15186gjg9.g)) { c15186gjg6.a(c15186gjg9, i2); c15186gjg6.b(); C15184gje.c(c15186gjg6); } } } gim.a -= j2; this.a += j2; j -= j2; } } @Override // o.giZ public final long read(giM gim, long j) { if (gim == null) { throw new IllegalArgumentException("sink == null"); } if (j < 0) { throw new IllegalArgumentException("byteCount < 0: ".concat(String.valueOf(j))); } long j2 = this.a; if (j2 == 0) { return -1L; } if (j > j2) { j = j2; } gim.write(this, j); return j; } @Override // o.InterfaceC15142giR public final long c(byte b) { return a(b, 0L); } public final long a(byte b, long j) { if (j < 0) { throw new IllegalArgumentException("fromIndex < 0"); } C15186gjg c15186gjg = this.c; if (c15186gjg == null) { return -1L; } long j2 = 0; do { long j3 = c15186gjg.c - c15186gjg.g; if (j >= j3) { j -= j3; } else { byte[] bArr = c15186gjg.a; int i = c15186gjg.c; for (int i2 = (int) (c15186gjg.g + j); i2 < i; i2++) { if (bArr[i2] == b) { return (j2 + i2) - c15186gjg.g; } } j = 0; } j2 += j3; c15186gjg = c15186gjg.b; } while (c15186gjg != this.c); return -1L; } @Override // o.giX public final giY timeout() { return giY.NONE; } public final boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof giM)) { return false; } giM gim = (giM) obj; long j = this.a; if (j != gim.a) { return false; } long j2 = 0; if (j == 0) { return true; } C15186gjg c15186gjg = this.c; C15186gjg c15186gjg2 = gim.c; int i = c15186gjg.g; int i2 = c15186gjg2.g; while (j2 < this.a) { long min = Math.min(c15186gjg.c - i, c15186gjg2.c - i2); int i3 = 0; while (i3 < min) { if (c15186gjg.a[i] != c15186gjg2.a[i2]) { return false; } i3++; i++; i2++; } if (i == c15186gjg.c) { c15186gjg = c15186gjg.b; i = c15186gjg.g; } if (i2 == c15186gjg2.c) { c15186gjg2 = c15186gjg2.b; i2 = c15186gjg2.g; } j2 += min; } return true; } public final int hashCode() { C15186gjg c15186gjg = this.c; if (c15186gjg == null) { return 0; } int i = 1; do { int i2 = c15186gjg.c; for (int i3 = c15186gjg.g; i3 < i2; i3++) { i = (i * 31) + c15186gjg.a[i3]; } c15186gjg = c15186gjg.b; } while (c15186gjg != this.c); return i; } public final String toString() { long j = this.a; if (j == 0) { return "Buffer[size=0]"; } if (j > 16) { try { MessageDigest messageDigest = MessageDigest.getInstance("MD5"); messageDigest.update(this.c.a, this.c.g, this.c.c - this.c.g); C15186gjg c15186gjg = this.c; while (true) { c15186gjg = c15186gjg.b; if (c15186gjg != this.c) { messageDigest.update(c15186gjg.a, c15186gjg.g, c15186gjg.c - c15186gjg.g); } else { return String.format("Buffer[size=%s md5=%s]", Long.valueOf(this.a), giP.c(messageDigest.digest()).b()); } } } catch (NoSuchAlgorithmException unused) { throw new AssertionError(); } } else { giP gip = new giP(clone().j()); return String.format("Buffer[size=%s data=%s]", Long.valueOf(this.a), gip.b()); } } /* renamed from: d, reason: merged with bridge method [inline-methods] */ public final giM clone() { giM gim = new giM(); if (this.a == 0) { return gim; } C15186gjg c15186gjg = new C15186gjg(this.c); gim.c = c15186gjg; c15186gjg.e = c15186gjg; c15186gjg.b = c15186gjg; C15186gjg c15186gjg2 = this.c; while (true) { c15186gjg2 = c15186gjg2.b; if (c15186gjg2 != this.c) { C15186gjg c15186gjg3 = gim.c.e; C15186gjg c15186gjg4 = new C15186gjg(c15186gjg2); c15186gjg4.e = c15186gjg3; c15186gjg4.b = c15186gjg3.b; c15186gjg3.b.e = c15186gjg4; c15186gjg3.b = c15186gjg4; } else { gim.a = this.a; return gim; } } } @Override // o.InterfaceC15142giR public final String p() throws EOFException { long a = a((byte) 10, 0L); if (a == -1) { giM gim = new giM(); d(gim, 0L, Math.min(32L, this.a)); StringBuilder sb = new StringBuilder("\\n not found: size="); sb.append(this.a); sb.append(" content="); sb.append(new giP(gim.j()).b()); sb.append("..."); throw new EOFException(sb.toString()); } return c(a); } @Override // o.giO public final /* synthetic */ giO a(byte[] bArr) throws IOException { if (bArr == null) { throw new IllegalArgumentException("source == null"); } return a(bArr, 0, bArr.length); } @Override // o.giO public final /* synthetic */ giO c(String str) throws IOException { return b(str, 0, str.length()); } @Override // o.InterfaceC15142giR public final boolean a(long j) { return this.a >= j; } @Override // o.InterfaceC15142giR public final boolean a() { return this.a == 0; } }