package o; import com.google.zxing.common.reedsolomon.ReedSolomonException; /* loaded from: classes2.dex */ public final class lxg { private final Ayo a; public lxg(Ayo ayo) { this.a = ayo; } public final void b(int[] iArr, int i) throws ReedSolomonException { uTj utj = new uTj(this.a, iArr); int[] iArr2 = new int[i]; boolean z = true; for (int i2 = 0; i2 < i; i2++) { Ayo ayo = this.a; int b = utj.b(ayo.f[ayo.h + i2]); iArr2[(i - 1) - i2] = b; if (b != 0) { z = false; } } if (z) { return; } uTj[] b2 = b(this.a.b(i, 1), new uTj(this.a, iArr2), i); uTj utj2 = b2[0]; uTj utj3 = b2[1]; int[] e = e(utj2); int[] b3 = b(utj3, e); for (int i3 = 0; i3 < e.length; i3++) { int length = iArr.length - 1; Ayo ayo2 = this.a; int i4 = e[i3]; if (i4 == 0) { throw new IllegalArgumentException(); } int i5 = length - ayo2.m[i4]; if (i5 < 0) { throw new ReedSolomonException("Bad error location"); } iArr[i5] = Ayo.a(iArr[i5], b3[i3]); } } private uTj[] b(uTj utj, uTj utj2, int i) throws ReedSolomonException { if (utj.a() >= utj2.a()) { utj2 = utj; utj = utj2; } uTj utj3 = this.a.l; uTj utj4 = this.a.f8102o; while ((utj.a() << 1) >= i) { if (((Boolean) uTj.e(new Object[]{utj}, 587912493, -587912492, System.identityHashCode(utj))).booleanValue()) { throw new ReedSolomonException("r_{i-1} was zero"); } uTj utj5 = this.a.l; int c = this.a.c(utj.d(utj.a())); while (utj2.a() >= utj.a() && !((Boolean) uTj.e(new Object[]{utj2}, 587912493, -587912492, System.identityHashCode(utj2))).booleanValue()) { int a = utj2.a() - utj.a(); int e = this.a.e(utj2.d(utj2.a()), c); utj5 = utj5.e(this.a.b(a, e)); utj2 = utj2.e(utj.e(a, e)); } uTj e2 = utj5.c(utj4).e(utj3); if (utj2.a() >= utj.a()) { StringBuilder sb = new StringBuilder("Division algorithm failed to reduce polynomial? r: "); sb.append(utj2); sb.append(", rLast: "); sb.append(utj); throw new IllegalStateException(sb.toString()); } uTj utj6 = utj2; utj2 = utj; utj = utj6; uTj utj7 = utj4; utj4 = e2; utj3 = utj7; } int d = utj4.d(0); if (d == 0) { throw new ReedSolomonException("sigmaTilde(0) was zero"); } int c2 = this.a.c(d); return new uTj[]{utj4.c(c2), utj.c(c2)}; } private int[] e(uTj utj) throws ReedSolomonException { int a = utj.a(); if (a == 1) { return new int[]{utj.d(1)}; } int[] iArr = new int[a]; int i = 0; for (int i2 = 1; i2 < this.a.n && i < a; i2++) { if (utj.b(i2) == 0) { iArr[i] = this.a.c(i2); i++; } } if (i == a) { return iArr; } throw new ReedSolomonException("Error locator degree does not match number of roots"); } private int[] b(uTj utj, int[] iArr) { int length = iArr.length; int[] iArr2 = new int[length]; for (int i = 0; i < length; i++) { int c = this.a.c(iArr[i]); int i2 = 1; for (int i3 = 0; i3 < length; i3++) { if (i != i3) { int e = this.a.e(iArr[i3], c); i2 = this.a.e(i2, (e & 1) == 0 ? e | 1 : e & (-2)); } } iArr2[i] = this.a.e(utj.b(c), this.a.c(i2)); if (this.a.h != 0) { iArr2[i] = this.a.e(iArr2[i], c); } } return iArr2; } }