package o; import com.google.common.base.Ascii; import com.google.crypto.tink.shaded.protobuf.InvalidProtocolBufferException; import net.sf.scuba.smartcards.ISO7816; /* loaded from: classes2.dex */ public final class iEH { private static final IeS e; /* JADX INFO: Access modifiers changed from: private */ public static int a(int i, int i2, int i3) { if (i > -12 || i2 > -65 || i3 > -65) { return -1; } return (i ^ (i2 << 8)) ^ (i3 << 16); } static /* synthetic */ int d(int i) { if (i > -12) { return -1; } return i; } static /* synthetic */ int e(int i, int i2) { if (i > -12 || i2 > -65) { return -1; } return i ^ (i2 << 8); } public static boolean a(byte[] bArr) { return e.b(bArr, 0, bArr.length) == 0; } /* loaded from: classes2.dex */ public static class Sts extends IllegalArgumentException { /* JADX WARN: Illegal instructions before constructor call */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ Sts(int r3, int r4) { /* r2 = this; java.lang.StringBuilder r0 = new java.lang.StringBuilder java.lang.String r1 = "Unpaired surrogate at index " r0.(r1) r0.append(r3) java.lang.String r3 = " of " r0.append(r3) r0.append(r4) java.lang.String r3 = r0.toString() r2.(r3) return */ throw new UnsupportedOperationException("Method not decompiled: o.iEH.Sts.(int, int):void"); } } public static int d(CharSequence charSequence) { int length = charSequence.length(); int i = 0; int i2 = 0; while (i2 < length && charSequence.charAt(i2) < 128) { i2++; } int i3 = length; while (true) { if (i2 >= length) { break; } char charAt = charSequence.charAt(i2); if (charAt < 2048) { i3 += (127 - charAt) >>> 31; i2++; } else { int length2 = charSequence.length(); while (i2 < length2) { char charAt2 = charSequence.charAt(i2); if (charAt2 < 2048) { i += (127 - charAt2) >>> 31; } else { i += 2; if (55296 <= charAt2 && charAt2 <= 57343) { if (Character.codePointAt(charSequence, i2) < 65536) { throw new Sts(i2, length2); } i2++; } } i2++; } i3 += i; } } if (i3 >= length) { return i3; } StringBuilder sb = new StringBuilder("UTF-8 length does not fit in int: "); sb.append(i3 + 4294967296L); throw new IllegalArgumentException(sb.toString()); } public static int b(CharSequence charSequence, byte[] bArr, int i, int i2) { return e.e(charSequence, bArr, i, i2); } /* JADX INFO: Access modifiers changed from: package-private */ public static String c(byte[] bArr, int i, int i2) throws InvalidProtocolBufferException { return e.a(bArr, i, i2); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static abstract class IeS { abstract String a(byte[] bArr, int i, int i2) throws InvalidProtocolBufferException; abstract int b(byte[] bArr, int i, int i2); abstract int e(CharSequence charSequence, byte[] bArr, int i, int i2); IeS() { } } /* loaded from: classes2.dex */ static final class RVV extends IeS { RVV() { } @Override // o.iEH.IeS final String a(byte[] bArr, int i, int i2) throws InvalidProtocolBufferException { if ((i | i2 | ((bArr.length - i) - i2)) < 0) { throw new ArrayIndexOutOfBoundsException(String.format("buffer length=%d, index=%d, size=%d", Integer.valueOf(bArr.length), Integer.valueOf(i), Integer.valueOf(i2))); } int i3 = i + i2; char[] cArr = new char[i2]; int i4 = 0; while (i < i3) { byte b = bArr[i]; if (b < 0) { break; } i++; cArr[i4] = (char) b; i4++; } int i5 = i4; while (i < i3) { int i6 = i + 1; byte b2 = bArr[i]; if (b2 >= 0) { cArr[i5] = (char) b2; i5++; i = i6; while (i < i3) { byte b3 = bArr[i]; if (b3 >= 0) { i++; cArr[i5] = (char) b3; i5++; } } } else if (b2 < -32) { if (i6 >= i3) { throw InvalidProtocolBufferException.b(); } i += 2; LWm.b(b2, bArr[i6], cArr, i5); i5++; } else if (b2 < -16) { if (i6 >= i3 - 1) { throw InvalidProtocolBufferException.b(); } LWm.a(b2, bArr[i6], bArr[i + 2], cArr, i5); i5++; i += 3; } else { if (i6 >= i3 - 2) { throw InvalidProtocolBufferException.b(); } LWm.e(b2, bArr[i6], bArr[i + 2], bArr[i + 3], cArr, i5); i5 += 2; i += 4; } } return new String(cArr, 0, i5); } /* JADX WARN: Code restructure failed: missing block: B:12:0x001d, code lost: return r10 + r0; */ @Override // o.iEH.IeS /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ final int e(java.lang.CharSequence r8, byte[] r9, int r10, int r11) { /* Method dump skipped, instructions count: 252 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: o.iEH.RVV.e(java.lang.CharSequence, byte[], int, int):int"); } @Override // o.iEH.IeS final int b(byte[] bArr, int i, int i2) { while (i < i2 && bArr[i] >= 0) { i++; } if (i >= i2) { return 0; } while (i < i2) { int i3 = i + 1; byte b = bArr[i]; if (b < 0) { if (b < -32) { if (i3 >= i2) { return b; } if (b >= -62) { i += 2; if (bArr[i3] > -65) { } } return -1; } if (b >= -16) { if (i3 >= i2 - 2) { return iEH.a(bArr, i3, i2); } byte b2 = bArr[i3]; if (b2 <= -65 && (((b << 28) + (b2 + ISO7816.INS_MANAGE_CHANNEL)) >> 30) == 0 && bArr[i + 2] <= -65) { i3 = i + 4; if (bArr[i + 3] > -65) { } } return -1; } if (i3 >= i2 - 1) { return iEH.a(bArr, i3, i2); } byte b3 = bArr[i3]; if (b3 <= -65 && ((b != -32 || b3 >= -96) && (b != -19 || b3 < -96))) { i3 = i + 3; if (bArr[i + 2] > -65) { } } return -1; } i = i3; } return 0; } } /* loaded from: classes2.dex */ static final class HBt extends IeS { HBt() { } /* JADX WARN: Code restructure failed: missing block: B:73:0x0042, code lost: return -1; */ @Override // o.iEH.IeS /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ final int b(byte[] r12, int r13, int r14) { /* r11 = this; r0 = r13 | r14 int r1 = r12.length int r1 = r1 - r14 r0 = r0 | r1 if (r0 < 0) goto La1 long r0 = (long) r13 long r13 = (long) r14 long r13 = r13 - r0 int r13 = (int) r13 int r14 = c(r12, r0, r13) int r13 = r13 - r14 long r2 = (long) r14 long r0 = r0 + r2 L12: r14 = 0 r2 = r14 L14: r3 = 1 if (r13 <= 0) goto L25 long r5 = r0 + r3 byte r2 = o.C1609aJC.e(r12, r0) if (r2 < 0) goto L24 int r13 = r13 + (-1) r0 = r5 goto L14 L24: r0 = r5 L25: if (r13 != 0) goto L28 return r14 L28: int r14 = r13 + (-1) r5 = -32 r6 = -1 r7 = -65 if (r2 >= r5) goto L43 if (r14 != 0) goto L34 return r2 L34: int r13 = r13 + (-2) r14 = -62 if (r2 < r14) goto L42 byte r14 = o.C1609aJC.e(r12, r0) if (r14 > r7) goto L42 long r0 = r0 + r3 goto L12 L42: return r6 L43: r8 = -16 r9 = 2 if (r2 >= r8) goto L72 r8 = 2 if (r14 >= r8) goto L51 int r12 = e(r12, r2, r0, r14) return r12 L51: int r13 = r13 + (-3) byte r14 = o.C1609aJC.e(r12, r0) if (r14 > r7) goto L71 r8 = -96 if (r2 != r5) goto L5f if (r14 < r8) goto L71 L5f: r5 = -19 if (r2 != r5) goto L65 if (r14 >= r8) goto L71 L65: long r8 = r0 + r9 long r0 = r0 + r3 byte r14 = o.C1609aJC.e(r12, r0) if (r14 <= r7) goto L6f goto L71 L6f: r0 = r8 goto L12 L71: return r6 L72: r5 = 3 if (r14 >= r5) goto L7a int r12 = e(r12, r2, r0, r14) return r12 L7a: int r13 = r13 + (-4) byte r14 = o.C1609aJC.e(r12, r0) if (r14 > r7) goto La0 int r2 = r2 << 28 int r14 = r14 + 112 int r2 = r2 + r14 int r14 = r2 >> 30 if (r14 != 0) goto La0 long r3 = r3 + r0 byte r14 = o.C1609aJC.e(r12, r3) if (r14 > r7) goto La0 r2 = 3 long r2 = r2 + r0 long r0 = r0 + r9 byte r14 = o.C1609aJC.e(r12, r0) if (r14 <= r7) goto L9d goto La0 L9d: r0 = r2 goto L12 La0: return r6 La1: int r12 = r12.length java.lang.Integer r12 = java.lang.Integer.valueOf(r12) java.lang.Integer r13 = java.lang.Integer.valueOf(r13) java.lang.Integer r14 = java.lang.Integer.valueOf(r14) java.lang.Object[] r12 = new java.lang.Object[]{r12, r13, r14} java.lang.ArrayIndexOutOfBoundsException r13 = new java.lang.ArrayIndexOutOfBoundsException java.lang.String r14 = "Array length=%d, index=%d, limit=%d" java.lang.String r12 = java.lang.String.format(r14, r12) r13.(r12) throw r13 */ throw new UnsupportedOperationException("Method not decompiled: o.iEH.HBt.b(byte[], int, int):int"); } @Override // o.iEH.IeS final String a(byte[] bArr, int i, int i2) throws InvalidProtocolBufferException { if ((i | i2 | ((bArr.length - i) - i2)) < 0) { throw new ArrayIndexOutOfBoundsException(String.format("buffer length=%d, index=%d, size=%d", Integer.valueOf(bArr.length), Integer.valueOf(i), Integer.valueOf(i2))); } int c = c(bArr, i, i2) + i; int i3 = i + i2; while (c < i3 && C1609aJC.e(bArr, c) >= 0) { c++; } if (c == i3) { return new String(bArr, i, i2, oZe.c); } char[] cArr = new char[i2]; int i4 = 0; while (i < c) { cArr[i4] = (char) C1609aJC.e(bArr, i); i++; i4++; } int i5 = i4; while (c < i3) { int i6 = c + 1; byte e = C1609aJC.e(bArr, c); if (e >= 0) { cArr[i5] = (char) e; i5++; c = i6; while (c < i3) { byte e2 = C1609aJC.e(bArr, c); if (e2 >= 0) { c++; cArr[i5] = (char) e2; i5++; } } } else if (e < -32) { if (i6 >= i3) { throw InvalidProtocolBufferException.b(); } c += 2; LWm.b(e, C1609aJC.e(bArr, i6), cArr, i5); i5++; } else if (e < -16) { if (i6 >= i3 - 1) { throw InvalidProtocolBufferException.b(); } LWm.a(e, C1609aJC.e(bArr, i6), C1609aJC.e(bArr, c + 2), cArr, i5); i5++; c += 3; } else { if (i6 >= i3 - 2) { throw InvalidProtocolBufferException.b(); } LWm.e(e, C1609aJC.e(bArr, i6), C1609aJC.e(bArr, c + 2), C1609aJC.e(bArr, c + 3), cArr, i5); i5 += 2; c += 4; } } return new String(cArr, 0, i5); } @Override // o.iEH.IeS final int e(CharSequence charSequence, byte[] bArr, int i, int i2) { long j; String str; String str2; int i3; char charAt; long j2 = i; long j3 = i2 + j2; int length = charSequence.length(); String str3 = " at index "; String str4 = "Failed writing "; if (length > i2 || bArr.length - i2 < i) { StringBuilder sb = new StringBuilder("Failed writing "); sb.append(charSequence.charAt(length - 1)); sb.append(" at index "); sb.append(i + i2); throw new ArrayIndexOutOfBoundsException(sb.toString()); } int i4 = 0; while (true) { j = 1; if (i4 >= length || (charAt = charSequence.charAt(i4)) >= 128) { break; } C1609aJC.c(bArr, j2, (byte) charAt); i4++; j2++; } if (i4 == length) { return (int) j2; } while (i4 < length) { char charAt2 = charSequence.charAt(i4); if (charAt2 < 128 && j2 < j3) { C1609aJC.c(bArr, j2, (byte) charAt2); j2 += j; str = str3; str2 = str4; } else if (charAt2 < 2048 && j2 <= j3 - 2) { C1609aJC.c(bArr, j2, (byte) ((charAt2 >>> 6) | 960)); C1609aJC.c(bArr, j2 + j, (byte) ((charAt2 & '?') | 128)); str = str3; str2 = str4; j2 = 2 + j2; } else { if ((charAt2 >= 55296 && 57343 >= charAt2) || j2 > j3 - 3) { str = str3; str2 = str4; if (j2 <= j3 - 4) { int i5 = i4 + 1; if (i5 != length) { char charAt3 = charSequence.charAt(i5); if (Character.isSurrogatePair(charAt2, charAt3)) { int codePoint = Character.toCodePoint(charAt2, charAt3); C1609aJC.c(bArr, j2, (byte) ((codePoint >>> 18) | 240)); C1609aJC.c(bArr, j2 + j, (byte) (((codePoint >>> 12) & 63) | 128)); C1609aJC.c(bArr, j2 + 2, (byte) (((codePoint >>> 6) & 63) | 128)); C1609aJC.c(bArr, j2 + 3, (byte) ((codePoint & 63) | 128)); j2 = 4 + j2; i4 = i5; } else { i4 = i5; } } throw new Sts(i4 - 1, length); } if (55296 <= charAt2 && charAt2 <= 57343 && ((i3 = i4 + 1) == length || !Character.isSurrogatePair(charAt2, charSequence.charAt(i3)))) { throw new Sts(i4, length); } StringBuilder sb2 = new StringBuilder(str2); sb2.append(charAt2); sb2.append(str); sb2.append(j2); throw new ArrayIndexOutOfBoundsException(sb2.toString()); } C1609aJC.c(bArr, j2, (byte) ((charAt2 >>> '\f') | com.kofax.mobile.sdk._internal.impl.camera.h.Az)); str = str3; str2 = str4; C1609aJC.c(bArr, j2 + j, (byte) (((charAt2 >>> 6) & 63) | 128)); C1609aJC.c(bArr, j2 + 2, (byte) ((charAt2 & '?') | 128)); j2 += 3; } i4++; str3 = str; str4 = str2; j = 1; } return (int) j2; } private static int c(byte[] bArr, long j, int i) { int i2 = 0; if (i < 16) { return 0; } while (true) { int i3 = i2 + 8; if (i3 > i || (C1609aJC.j(bArr, C1609aJC.d + j) & (-9187201950435737472L)) != 0) { break; } j += 8; i2 = i3; } while (i2 < i) { if (C1609aJC.e(bArr, j) < 0) { return i2; } i2++; j++; } return i; } private static int e(byte[] bArr, int i, long j, int i2) { if (i2 == 0) { return iEH.d(i); } if (i2 == 1) { return iEH.e(i, C1609aJC.e(bArr, j)); } if (i2 == 2) { return iEH.a(i, C1609aJC.e(bArr, j), C1609aJC.e(bArr, j + 1)); } throw new AssertionError(); } } static { IeS rvv; if (C1609aJC.a() && C1609aJC.c() && !C3269auN.e()) { rvv = new HBt(); } else { rvv = new RVV(); } e = rvv; } /* loaded from: classes2.dex */ static class LWm { static /* synthetic */ void e(byte b, byte b2, byte b3, byte b4, char[] cArr, int i) throws InvalidProtocolBufferException { if (b2 > -65 || (((b << 28) + (b2 + ISO7816.INS_MANAGE_CHANNEL)) >> 30) != 0 || b3 > -65 || b4 > -65) { throw InvalidProtocolBufferException.b(); } int i2 = ((b & 7) << 18) | ((b2 & 63) << 12) | ((b3 & 63) << 6) | (b4 & 63); cArr[i] = (char) ((i2 >>> 10) + 55232); cArr[i + 1] = (char) ((i2 & 1023) + 56320); } static /* synthetic */ void b(byte b, byte b2, char[] cArr, int i) throws InvalidProtocolBufferException { if (b < -62 || b2 > -65) { throw InvalidProtocolBufferException.b(); } cArr[i] = (char) (((b & Ascii.US) << 6) | (b2 & 63)); } static /* synthetic */ void a(byte b, byte b2, byte b3, char[] cArr, int i) throws InvalidProtocolBufferException { if (b2 > -65 || ((b == -32 && b2 < -96) || ((b == -19 && b2 >= -96) || b3 > -65))) { throw InvalidProtocolBufferException.b(); } cArr[i] = (char) (((b & 15) << 12) | ((b2 & 63) << 6) | (b3 & 63)); } } static /* synthetic */ int a(byte[] bArr, int i, int i2) { byte b = bArr[i - 1]; int i3 = i2 - i; if (i3 == 0) { if (b > -12) { return -1; } return b; } if (i3 != 1) { if (i3 == 2) { return a(b, bArr[i], bArr[i + 1]); } throw new AssertionError(); } byte b2 = bArr[i]; if (b > -12 || b2 > -65) { return -1; } return b ^ (b2 << 8); } public static boolean d(byte[] bArr, int i, int i2) { return e.b(bArr, i, i2) == 0; } }