package o; import io.flutter.embedding.android.KeyboardMap; import java.util.Arrays; /* renamed from: o.gjB, reason: case insensitive filesystem */ /* loaded from: classes2.dex */ public final class C15174gjB { int[] a; int b; long[] c; int d = -1; int e; private Qpt i; int j; public final void d(Qpt qpt, int i, boolean z) { int d = qpt.d(); int i2 = (d + 511) & (-256); long[] jArr = this.c; int[] iArr = this.a; if (jArr == null || jArr.length < d) { jArr = new long[i2]; } if (iArr == null || iArr.length < d) { iArr = new int[i2]; } this.c = jArr; this.a = iArr; int i3 = 0; int i4 = 0; int i5 = 0; while (true) { if (i3 < d) { long d2 = qpt.d(i3); int b = qpt.b(i3); boolean z2 = i == 1; long[] jArr2 = jArr; jArr2[i3] = b | ((i3 + i5) << 32) | (z2 ? 2147483648L : 0L); iArr[i3] = (int) (KeyboardMap.kValueMask & d2); if (z2) { i4++; i5 += b; } i3++; jArr = jArr2; } else { this.i = qpt; this.j = d; this.b = i4; this.e = i5; this.d = Math.max(0, d - 1); return; } } } public final void a(long[] jArr) { if (jArr == null || jArr.length == 0 || this.c == null) { return; } int i = this.j; long[] jArr2 = new long[i]; for (int i2 = 0; i2 < this.j; i2++) { jArr2[i2] = (this.a[i2] << 32) | i2; } Arrays.sort(jArr2); int i3 = 0; int i4 = 0; while (i3 < jArr.length) { long j = jArr[i3]; int i5 = (int) (j >>> 32); boolean z = (j & 2147483648L) != 0; int i6 = i4; while (i4 < i) { long j2 = jArr2[i4]; int i7 = (int) (j2 >>> 32); int i8 = (int) (j2 & 2147483647L); if (i7 < i5) { i6 = i4; } else if (i7 == i5) { if (z) { e(i8); } else { d(i8); } i6 = i4 + 1; } i4++; } i3++; i4 = i6; } } public final long[] d() { long[] jArr = new long[this.j]; for (int i = 0; i < this.j; i++) { jArr[i] = (this.c[i] & 2147483648L) | (this.a[i] << 32); } Arrays.sort(jArr); return jArr; } public final int a(int i) { long j = this.c[i]; if ((2147483648L & j) != 0) { return (int) (j & 2147483647L); } return 0; } public final boolean d(int i) { long[] jArr = this.c; long j = jArr[i]; if ((2147483648L & j) == 0) { return false; } jArr[i] = j & (-2147483649L); this.b--; this.e -= (int) (2147483647L & j); this.d = Math.min(this.d, i); return true; } public final boolean e(int i) { long[] jArr = this.c; long j = jArr[i]; if ((j & 2147483648L) != 0) { return false; } jArr[i] = j | 2147483648L; this.b++; this.e += (int) (2147483647L & j); this.d = Math.min(this.d, i); return true; } public final void d(int i, int i2) { if (i == i2) { return; } long j = this.c[i]; int i3 = this.a[i]; if (i2 < i) { for (int i4 = i; i4 > i2; i4--) { long[] jArr = this.c; int i5 = i4 - 1; jArr[i4] = jArr[i5]; int[] iArr = this.a; iArr[i4] = iArr[i5]; } } else { int i6 = i; while (i6 < i2) { long[] jArr2 = this.c; int i7 = i6 + 1; jArr2[i6] = jArr2[i7]; int[] iArr2 = this.a; iArr2[i6] = iArr2[i7]; i6 = i7; } } this.c[i2] = j; this.a[i2] = i3; int min = Math.min(i, i2); this.d = min > 0 ? Math.min(this.d, min - 1) : -1; } public final void d(int i, int i2, int i3, int i4) { if (i == i3) { return; } long[] jArr = this.c; long j = jArr[i]; int i5 = (int) (j & 2147483647L); int i6 = (int) (2147483647L & jArr[i3]); if (i5 == 0) { StringBuilder sb = new StringBuilder("moveChildItem(fromGroupPosition = "); sb.append(i); sb.append(", fromChildPosition = "); sb.append(i2); sb.append(", toGroupPosition = "); sb.append(i3); sb.append(", toChildPosition = "); sb.append(i4); sb.append(") --- may be a bug."); throw new IllegalStateException(sb.toString()); } jArr[i] = (j & (-2147483648L)) | (i5 - 1); long j2 = (jArr[i3] & (-2147483648L)) | (i6 + 1); jArr[i3] = j2; if ((jArr[i] & 2147483648L) != 0) { this.e--; } if ((j2 & 2147483648L) != 0) { this.e++; } int min = Math.min(i, i3); this.d = min > 0 ? Math.min(this.d, min - 1) : -1; } public final int e(long j) { int i = -1; if (j == -1) { return -1; } int i2 = (int) j; int i3 = (int) (j >>> 32); int i4 = this.j; if (i2 >= 0 && i2 < i4) { if (i3 != -1 && (this.c[i2] & 2147483648L) == 0) { return -1; } int max = Math.max(0, Math.min(i2, this.d)); int i5 = this.d; int i6 = (int) (this.c[max] >>> 32); while (true) { if (max >= i4) { max = i5; break; } long[] jArr = this.c; long j2 = jArr[max]; jArr[max] = (i6 << 32) | (KeyboardMap.kValueMask & j2); int i7 = (int) (2147483647L & j2); if (max == i2) { if (i3 != -1) { if (i3 < i7) { i6 = i6 + 1 + i3; } } i = i6; } else { i6++; if ((j2 & 2147483648L) != 0) { i6 += i7; } i5 = max; max++; } } this.d = Math.max(this.d, max); } return i; } /* JADX WARN: Removed duplicated region for block: B:10:0x0040 */ /* JADX WARN: Removed duplicated region for block: B:13:0x0049 */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final long c(int r19) { /* r18 = this; r0 = r18 r1 = r19 r2 = -1 r3 = -1 if (r1 != r2) goto La return r3 La: int r2 = r0.j long[] r5 = r0.c int r6 = r0.d r7 = 32 r8 = 0 if (r6 > 0) goto L17 L15: r6 = r8 goto L3b L17: r9 = r5[r8] long r9 = r9 >>> r7 int r9 = (int) r9 r10 = r5[r6] long r10 = r10 >>> r7 int r10 = (int) r10 if (r1 > r9) goto L22 goto L15 L22: if (r1 < r10) goto L25 goto L3b L25: r9 = r8 r10 = r9 L27: if (r10 >= r6) goto L3a int r11 = r10 + r6 int r11 = r11 >>> 1 r12 = r5[r11] long r12 = r12 >>> r7 int r12 = (int) r12 if (r12 >= r1) goto L38 int r11 = r11 + 1 r9 = r10 r10 = r11 goto L27 L38: r6 = r11 goto L27 L3a: r6 = r9 L3b: int r5 = r0.d if (r6 != 0) goto L40 goto L47 L40: long[] r8 = r0.c r9 = r8[r6] long r8 = r9 >>> r7 int r8 = (int) r8 L47: if (r6 >= r2) goto L90 long[] r5 = r0.c r9 = r5[r6] long r11 = (long) r8 long r11 = r11 << r7 r13 = 4294967295(0xffffffff, double:2.1219957905E-314) long r15 = r9 & r13 long r11 = r11 | r15 r5[r6] = r11 if (r8 < r1) goto L65 long r1 = (long) r6 long r1 = r1 & r13 r3 = -4294967296(0xffffffff00000000, double:NaN) long r3 = r3 | r1 L63: r5 = r6 goto L90 L65: int r8 = r8 + 1 r11 = 2147483648(0x80000000, double:1.0609978955E-314) long r11 = r11 & r9 r15 = 0 int r5 = (r11 > r15 ? 1 : (r11 == r15 ? 0 : -1)) if (r5 == 0) goto L88 r11 = 2147483647(0x7fffffff, double:1.060997895E-314) long r9 = r9 & r11 int r5 = (int) r9 if (r5 <= 0) goto L87 int r9 = r8 + r5 int r9 = r9 + (-1) if (r9 < r1) goto L87 int r1 = r1 - r8 long r1 = (long) r1 long r3 = (long) r6 long r3 = r3 & r13 long r1 = r1 << r7 long r3 = r3 | r1 goto L63 L87: int r8 = r8 + r5 L88: int r5 = r6 + 1 r17 = r6 r6 = r5 r5 = r17 goto L47 L90: int r1 = r0.d int r1 = java.lang.Math.max(r1, r5) r0.d = r1 return r3 */ throw new UnsupportedOperationException("Method not decompiled: o.C15174gjB.c(int):long"); } public final boolean b() { return this.j == 0 || this.b == 0; } }