package o; import com.google.common.base.Ascii; import com.google.protobuf.InvalidProtocolBufferException; import java.nio.ByteBuffer; import net.sf.scuba.smartcards.ISO7816; /* renamed from: o.qto, reason: case insensitive filesystem */ /* loaded from: classes2.dex */ public final class C16752qto { private static final RVV b; static /* synthetic */ int d(int i) { if (i > -12) { return -1; } return i; } static /* synthetic */ int d(int i, int i2) { if (i > -12 || i2 > -65) { return -1; } return i ^ (i2 << 8); } /* JADX INFO: Access modifiers changed from: private */ public static int e(int i, int i2, int i3) { if (i > -12 || i2 > -65 || i3 > -65) { return -1; } return (i ^ (i2 << 8)) ^ (i3 << 16); } public static boolean d(byte[] bArr) { return b.b(0, bArr, 0, bArr.length) == 0; } public static int c(int i, byte[] bArr, int i2, int i3) { return b.b(i, bArr, i2, i3); } /* renamed from: o.qto$HBt */ /* loaded from: classes2.dex */ public static class HBt 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 */ HBt(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.C16752qto.HBt.(int, int):void"); } } public static int b(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 HBt(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 b.e(charSequence, bArr, i, i2); } /* JADX INFO: Access modifiers changed from: package-private */ public static String d(byte[] bArr, int i, int i2) throws InvalidProtocolBufferException { return b.d(bArr, i, i2); } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.qto$RVV */ /* loaded from: classes2.dex */ public static abstract class RVV { abstract int b(int i, byte[] bArr, int i2, int i3); abstract String d(ByteBuffer byteBuffer, int i, int i2) throws InvalidProtocolBufferException; abstract String d(byte[] bArr, int i, int i2) throws InvalidProtocolBufferException; abstract int e(CharSequence charSequence, byte[] bArr, int i, int i2); RVV() { } static String a(ByteBuffer byteBuffer, int i, int i2) throws InvalidProtocolBufferException { if ((i | i2 | ((byteBuffer.limit() - i) - i2)) < 0) { throw new ArrayIndexOutOfBoundsException(String.format("buffer limit=%d, index=%d, limit=%d", Integer.valueOf(byteBuffer.limit()), Integer.valueOf(i), Integer.valueOf(i2))); } int i3 = i + i2; char[] cArr = new char[i2]; int i4 = 0; while (i < i3) { byte b = byteBuffer.get(i); if (b < 0) { break; } i++; cArr[i4] = (char) b; i4++; } int i5 = i4; while (i < i3) { int i6 = i + 1; byte b2 = byteBuffer.get(i); if (b2 >= 0) { cArr[i5] = (char) b2; i5++; i = i6; while (i < i3) { byte b3 = byteBuffer.get(i); if (b3 >= 0) { i++; cArr[i5] = (char) b3; i5++; } } } else if (b2 < -32) { if (i6 >= i3) { throw InvalidProtocolBufferException.a(); } i += 2; Sts.e(b2, byteBuffer.get(i6), cArr, i5); i5++; } else if (b2 < -16) { if (i6 >= i3 - 1) { throw InvalidProtocolBufferException.a(); } Sts.c(b2, byteBuffer.get(i6), byteBuffer.get(i + 2), cArr, i5); i5++; i += 3; } else { if (i6 >= i3 - 2) { throw InvalidProtocolBufferException.a(); } Sts.a(b2, byteBuffer.get(i6), byteBuffer.get(i + 2), byteBuffer.get(i + 3), cArr, i5); i5 += 2; i += 4; } } return new String(cArr, 0, i5); } } /* renamed from: o.qto$IeS */ /* loaded from: classes2.dex */ static final class IeS extends RVV { IeS() { } /* JADX WARN: Code restructure failed: missing block: B:10:0x001c, code lost: if (r13[r14] <= (-65)) goto L11; */ /* JADX WARN: Code restructure failed: missing block: B:27:0x0046, code lost: if (r13[r14] > (-65)) goto L28; */ /* JADX WARN: Code restructure failed: missing block: B:47:0x0081, code lost: if (r13[r14] > (-65)) goto L49; */ @Override // o.C16752qto.RVV /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ final int b(int r12, byte[] r13, int r14, int r15) { /* Method dump skipped, instructions count: 238 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: o.C16752qto.IeS.b(int, byte[], int, int):int"); } @Override // o.C16752qto.RVV final String d(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.a(); } i += 2; Sts.e(b2, bArr[i6], cArr, i5); i5++; } else if (b2 < -16) { if (i6 >= i3 - 1) { throw InvalidProtocolBufferException.a(); } Sts.c(b2, bArr[i6], bArr[i + 2], cArr, i5); i5++; i += 3; } else { if (i6 >= i3 - 2) { throw InvalidProtocolBufferException.a(); } Sts.a(b2, bArr[i6], bArr[i + 2], bArr[i + 3], cArr, i5); i5 += 2; i += 4; } } return new String(cArr, 0, i5); } @Override // o.C16752qto.RVV final String d(ByteBuffer byteBuffer, int i, int i2) throws InvalidProtocolBufferException { return a(byteBuffer, i, i2); } /* JADX WARN: Code restructure failed: missing block: B:12:0x001d, code lost: return r10 + r0; */ @Override // o.C16752qto.RVV /* 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.C16752qto.IeS.e(java.lang.CharSequence, byte[], int, int):int"); } } /* renamed from: o.qto$LWm */ /* loaded from: classes2.dex */ static final class LWm extends RVV { LWm() { } /* JADX WARN: Code restructure failed: missing block: B:122:0x00e2, code lost: return -1; */ /* JADX WARN: Code restructure failed: missing block: B:30:0x005f, code lost: if (o.vqr.b(r22, r4) <= (-65)) goto L31; */ /* JADX WARN: Code restructure failed: missing block: B:51:0x00a7, code lost: if (o.vqr.b(r22, r4) > (-65)) goto L53; */ @Override // o.C16752qto.RVV /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ final int b(int r21, byte[] r22, int r23, int r24) { /* Method dump skipped, instructions count: 351 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: o.C16752qto.LWm.b(int, byte[], int, int):int"); } @Override // o.C16752qto.RVV final String d(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 a = a(bArr, i, i2) + i; int i3 = i + i2; while (a < i3 && vqr.b(bArr, a) >= 0) { a++; } if (a == i3) { return new String(bArr, i, i2, MTP.a); } char[] cArr = new char[i2]; int i4 = 0; while (i < a) { cArr[i4] = (char) vqr.b(bArr, i); i++; i4++; } int i5 = i4; while (a < i3) { int i6 = a + 1; byte b = vqr.b(bArr, a); if (b >= 0) { cArr[i5] = (char) b; i5++; a = i6; while (a < i3) { byte b2 = vqr.b(bArr, a); if (b2 >= 0) { a++; cArr[i5] = (char) b2; i5++; } } } else if (b < -32) { if (i6 >= i3) { throw InvalidProtocolBufferException.a(); } a += 2; Sts.e(b, vqr.b(bArr, i6), cArr, i5); i5++; } else if (b < -16) { if (i6 >= i3 - 1) { throw InvalidProtocolBufferException.a(); } Sts.c(b, vqr.b(bArr, i6), vqr.b(bArr, a + 2), cArr, i5); i5++; a += 3; } else { if (i6 >= i3 - 2) { throw InvalidProtocolBufferException.a(); } Sts.a(b, vqr.b(bArr, i6), vqr.b(bArr, a + 2), vqr.b(bArr, a + 3), cArr, i5); i5 += 2; a += 4; } } return new String(cArr, 0, i5); } @Override // o.C16752qto.RVV final String d(ByteBuffer byteBuffer, int i, int i2) throws InvalidProtocolBufferException { byte d; byte d2; if ((i | i2 | ((byteBuffer.limit() - i) - i2)) < 0) { throw new ArrayIndexOutOfBoundsException(String.format("buffer limit=%d, index=%d, limit=%d", Integer.valueOf(byteBuffer.limit()), Integer.valueOf(i), Integer.valueOf(i2))); } long d3 = vqr.d(byteBuffer) + i; long j = i2 + d3; char[] cArr = new char[i2]; int i3 = 0; while (d3 < j && (d2 = vqr.d(d3)) >= 0) { d3++; cArr[i3] = (char) d2; i3++; } int i4 = i3; while (d3 < j) { long j2 = d3 + 1; byte d4 = vqr.d(d3); if (d4 >= 0) { cArr[i4] = (char) d4; i4++; d3 = j2; while (d3 < j && (d = vqr.d(d3)) >= 0) { d3++; cArr[i4] = (char) d; i4++; } } else if (d4 < -32) { if (j2 >= j) { throw InvalidProtocolBufferException.a(); } d3 += 2; Sts.e(d4, vqr.d(j2), cArr, i4); i4++; } else if (d4 < -16) { if (j2 >= j - 1) { throw InvalidProtocolBufferException.a(); } Sts.c(d4, vqr.d(j2), vqr.d(d3 + 2), cArr, i4); i4++; d3 = 3 + d3; } else { if (j2 >= j - 2) { throw InvalidProtocolBufferException.a(); } Sts.a(d4, vqr.d(j2), vqr.d(2 + d3), vqr.d(d3 + 3), cArr, i4); i4 += 2; d3 += 4; } } return new String(cArr, 0, i4); } @Override // o.C16752qto.RVV 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; } vqr.b(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) { vqr.b(bArr, j2, (byte) charAt2); j2 += j; str = str3; str2 = str4; } else if (charAt2 < 2048 && j2 <= j3 - 2) { vqr.b(bArr, j2, (byte) ((charAt2 >>> 6) | 960)); vqr.b(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); vqr.b(bArr, j2, (byte) ((codePoint >>> 18) | 240)); vqr.b(bArr, j2 + j, (byte) (((codePoint >>> 12) & 63) | 128)); vqr.b(bArr, j2 + 2, (byte) (((codePoint >>> 6) & 63) | 128)); vqr.b(bArr, j2 + 3, (byte) ((codePoint & 63) | 128)); j2 = 4 + j2; i4 = i5; } else { i4 = i5; } } throw new HBt(i4 - 1, length); } if (55296 <= charAt2 && charAt2 <= 57343 && ((i3 = i4 + 1) == length || !Character.isSurrogatePair(charAt2, charSequence.charAt(i3)))) { throw new HBt(i4, length); } StringBuilder sb2 = new StringBuilder(str2); sb2.append(charAt2); sb2.append(str); sb2.append(j2); throw new ArrayIndexOutOfBoundsException(sb2.toString()); } vqr.b(bArr, j2, (byte) ((charAt2 >>> '\f') | com.kofax.mobile.sdk._internal.impl.camera.h.Az)); str = str3; str2 = str4; vqr.b(bArr, j2 + j, (byte) (((charAt2 >>> 6) & 63) | 128)); vqr.b(bArr, j2 + 2, (byte) ((charAt2 & '?') | 128)); j2 += 3; } i4++; str3 = str; str4 = str2; j = 1; } return (int) j2; } private static int a(byte[] bArr, long j, int i) { int i2 = 0; if (i < 16) { return 0; } while (true) { int i3 = i2 + 8; if (i3 > i || (vqr.i(bArr, vqr.c + j) & (-9187201950435737472L)) != 0) { break; } j += 8; i2 = i3; } while (i2 < i) { if (vqr.b(bArr, j) < 0) { return i2; } i2++; j++; } return i; } private static int c(byte[] bArr, int i, long j, int i2) { if (i2 == 0) { return C16752qto.d(i); } if (i2 == 1) { return C16752qto.d(i, vqr.b(bArr, j)); } if (i2 == 2) { return C16752qto.e(i, vqr.b(bArr, j), vqr.b(bArr, j + 1)); } throw new AssertionError(); } } static { b = (vqr.b() && vqr.e() && !zRL.d()) ? new LWm() : new IeS(); } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.qto$Sts */ /* loaded from: classes2.dex */ public static class Sts { static /* synthetic */ void a(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.a(); } 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 e(byte b, byte b2, char[] cArr, int i) throws InvalidProtocolBufferException { if (b < -62 || b2 > -65) { throw InvalidProtocolBufferException.a(); } cArr[i] = (char) (((b & Ascii.US) << 6) | (b2 & 63)); } static /* synthetic */ void c(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.a(); } cArr[i] = (char) (((b & 15) << 12) | ((b2 & 63) << 6) | (b3 & 63)); } } static /* synthetic */ int b(byte[] bArr, int i, int i2) { byte b2 = bArr[i - 1]; int i3 = i2 - i; if (i3 == 0) { if (b2 > -12) { return -1; } return b2; } if (i3 != 1) { if (i3 == 2) { return e(b2, bArr[i], bArr[i + 1]); } throw new AssertionError(); } byte b3 = bArr[i]; if (b2 > -12 || b3 > -65) { return -1; } return b2 ^ (b3 << 8); } /* JADX INFO: Access modifiers changed from: package-private */ public static String c(ByteBuffer byteBuffer, int i, int i2) throws InvalidProtocolBufferException { RVV rvv = b; if (byteBuffer.hasArray()) { return rvv.d(byteBuffer.array(), byteBuffer.arrayOffset() + i, i2); } if (byteBuffer.isDirect()) { return rvv.d(byteBuffer, i, i2); } return RVV.a(byteBuffer, i, i2); } public static boolean a(byte[] bArr, int i, int i2) { return b.b(0, bArr, i, i2) == 0; } }