package o; import io.beid.beidk.definitions.LivenessStatus; import java.util.Arrays; /* loaded from: classes2.dex */ public final class GpJ { /* JADX INFO: Access modifiers changed from: package-private */ public static boolean c(char c) { return c == '\r' || c == '*' || c == '>' || c == ' ' || (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z'); } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean d(char c) { return c == ' ' || (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z'); } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean e(char c) { return c == ' ' || (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z'); } /* JADX INFO: Access modifiers changed from: package-private */ public static int a(CharSequence charSequence, int i, int i2) { int e = e(charSequence, i, i2); if (i2 == 3 && e == 3) { int min = Math.min(i + 3, charSequence.length()); while (i < min) { if (!c(charSequence.charAt(i))) { return 0; } i++; } } else if (i2 == 4 && e == 4) { int min2 = Math.min(i + 4, charSequence.length()); while (i < min2) { char charAt = charSequence.charAt(i); if (charAt < ' ' || charAt > '^') { return 0; } i++; } } return e; } private static int e(CharSequence charSequence, int i, int i2) { int i3; if (i >= charSequence.length()) { return i2; } int i4 = 6; float[] fArr = {1.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.25f}; if (i2 == 0) { // fill-array-data instruction fArr[0] = 0.0f; fArr[1] = 1.0f; fArr[2] = 1.0f; fArr[3] = 1.0f; fArr[4] = 1.0f; fArr[5] = 1.25f; } else { fArr[i2] = 0.0f; } byte[] bArr = new byte[6]; int[] iArr = new int[6]; int i5 = 0; while (true) { int i6 = i + i5; if (i6 == charSequence.length()) { Arrays.fill(bArr, (byte) 0); Arrays.fill(iArr, 0); int d = d(fArr, iArr, bArr); int i7 = 0; for (int i8 = 0; i8 < i4; i8++) { i7 += bArr[i8]; } if (iArr[0] == d) { return 0; } if (i7 == 1) { if (bArr[5] > 0) { return 5; } if (bArr[4] > 0) { return 4; } if (bArr[2] > 0) { return 2; } if (bArr[3] > 0) { return 3; } } return 1; } char charAt = charSequence.charAt(i6); i5++; if (charAt >= '0' && charAt <= '9') { fArr[0] = fArr[0] + 0.5f; } else if (charAt >= 128 && charAt <= 255) { float ceil = (float) Math.ceil(fArr[0]); fArr[0] = ceil; fArr[0] = ceil + 2.0f; } else { float ceil2 = (float) Math.ceil(fArr[0]); fArr[0] = ceil2; fArr[0] = ceil2 + 1.0f; } if (e(charAt)) { fArr[1] = fArr[1] + 0.6666667f; } else if (charAt >= 128 && charAt <= 255) { fArr[1] = fArr[1] + 2.6666667f; } else { fArr[1] = fArr[1] + 1.3333334f; } if (d(charAt)) { fArr[2] = fArr[2] + 0.6666667f; } else if (charAt >= 128 && charAt <= 255) { fArr[2] = fArr[2] + 2.6666667f; } else { fArr[2] = fArr[2] + 1.3333334f; } if (c(charAt)) { fArr[3] = fArr[3] + 0.6666667f; } else if (charAt >= 128 && charAt <= 255) { fArr[3] = fArr[3] + 4.3333335f; } else { fArr[3] = fArr[3] + 3.3333333f; } if (charAt < ' ' || charAt > '^') { i3 = 4; if (charAt >= 128 && charAt <= 255) { fArr[4] = fArr[4] + 4.25f; } else { fArr[4] = fArr[4] + 3.25f; } } else { i3 = 4; fArr[4] = fArr[4] + 0.75f; } fArr[5] = fArr[5] + 1.0f; if (i5 >= i3) { Arrays.fill(bArr, (byte) 0); Arrays.fill(iArr, 0); d(fArr, iArr, bArr); if (iArr[0] < Math.min(Math.min(iArr[5], Math.min(iArr[1], Math.min(iArr[2], iArr[3]))), iArr[i3])) { return 0; } int i9 = iArr[5]; if (i9 < iArr[0] || i9 + 1 < Math.min(iArr[1], Math.min(iArr[2], Math.min(iArr[3], iArr[4])))) { break; } if (iArr[4] + 1 < Math.min(Math.min(iArr[5], Math.min(iArr[1], Math.min(iArr[2], iArr[3]))), iArr[0])) { return 4; } if (iArr[2] + 1 < Math.min(Math.min(iArr[5], Math.min(iArr[1], Math.min(iArr[4], iArr[3]))), iArr[0])) { return 2; } if (iArr[3] + 1 < Math.min(Math.min(iArr[5], Math.min(iArr[1], Math.min(iArr[4], iArr[2]))), iArr[0])) { return 3; } if (iArr[1] + 1 >= Math.min(iArr[0], Math.min(iArr[5], Math.min(iArr[4], iArr[2])))) { continue; } else { int i10 = iArr[1]; int i11 = iArr[3]; if (i10 < i11) { return 1; } if (i10 == i11) { for (int i12 = i + i5 + 1; i12 < charSequence.length(); i12++) { char charAt2 = charSequence.charAt(i12); if (charAt2 == '\r' || charAt2 == '*' || charAt2 == '>') { return 3; } if (!c(charAt2)) { break; } } return 1; } } } i4 = 6; } return 5; } private static int d(float[] fArr, int[] iArr, byte[] bArr) { int i = Integer.MAX_VALUE; for (int i2 = 0; i2 < 6; i2++) { int ceil = (int) Math.ceil(fArr[i2]); iArr[i2] = ceil; if (i > ceil) { Arrays.fill(bArr, (byte) 0); i = ceil; } if (i == ceil) { bArr[i2] = (byte) (bArr[i2] + 1); } } return i; } /* JADX INFO: Access modifiers changed from: package-private */ public static void a(char c) { String hexString = Integer.toHexString(c); StringBuilder sb = new StringBuilder(); sb.append(LivenessStatus.OK.substring(0, 4 - hexString.length())); sb.append(hexString); String obj = sb.toString(); StringBuilder sb2 = new StringBuilder("Illegal character: "); sb2.append(c); sb2.append(" (0x"); sb2.append(obj); sb2.append(')'); throw new IllegalArgumentException(sb2.toString()); } }