package com.google.android.gms.internal.ads;

import android.content.Context;
import android.media.MediaCodecInfo;
import android.os.Build;
import android.text.TextUtils;
import androidx.media3.common.MimeTypes;
import androidx.media3.common.PlaybackException;
import androidx.media3.exoplayer.upstream.CmcdData;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.nio.ByteBuffer;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.security.spec.ECParameterSpec;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.SortedSet;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import javax.crypto.Mac;

/* JADX INFO: loaded from: classes2.dex */
public abstract class ih1 implements q22, x7.b {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final xk1 f12509a = new xk1(0);

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final xk1 f12510b = new xk1(2);

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final xk1 f12511c = new xk1(4);

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final xk1 f12512d = new xk1(6);

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final nz1 f12513e = new nz1(new long[]{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, new long[]{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, new long[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0});

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final pz1 f12514f = new pz1(new vu0(new long[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, new long[]{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, new long[]{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 19), new long[]{1, 0, 0, 0, 0, 0, 0, 0, 0, 0});

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public static final byte[] f12515g = {-19, -45, -11, 92, 26, 99, 18, 88, -42, -100, -9, -94, -34, -7, -34, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16};

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public static int f12516h = 2;

    public static boolean A(zzbch zzbchVar) {
        int iOrdinal = zzbchVar.ordinal();
        return iOrdinal == 1 || iOrdinal == 2 || iOrdinal == 3 || iOrdinal == 4 || iOrdinal == 5;
    }

    public static ov1 A0(Callable callable, ExecutorService executorService) {
        ov1 ov1Var = new ov1(callable);
        executorService.execute(ov1Var);
        return ov1Var;
    }

    public static Object A1(Future future) {
        if (future.isDone()) {
            return q(future);
        }
        throw new IllegalStateException(B0("Future was expected to be done: %s", future));
    }

    public static boolean B(String str) {
        return str == null || str.isEmpty();
    }

    public static String B0(String str, Object... objArr) {
        int length;
        int iIndexOf;
        StringBuilder sb = new StringBuilder(str.length() + (objArr.length * 16));
        int i10 = 0;
        int i11 = 0;
        while (true) {
            length = objArr.length;
            if (i10 >= length || (iIndexOf = str.indexOf("%s", i11)) == -1) {
                break;
            }
            sb.append((CharSequence) str, i11, iIndexOf);
            sb.append(K0(objArr[i10]));
            i11 = iIndexOf + 2;
            i10++;
        }
        sb.append((CharSequence) str, i11, str.length());
        if (i10 < length) {
            String str2 = " [";
            while (i10 < objArr.length) {
                sb.append(str2);
                sb.append(K0(objArr[i10]));
                i10++;
                str2 = ", ";
            }
            sb.append(']');
        }
        return sb.toString();
    }

    public static Object B1(com.google.common.util.concurrent.w wVar) {
        try {
            return q(wVar);
        } catch (ExecutionException e10) {
            if (e10.getCause() instanceof Error) {
                throw new zzgze((Error) e10.getCause());
            }
            throw new zzhao(e10.getCause());
        }
    }

    public static byte[] C(String str) {
        if ((str.length() & 1) != 0) {
            throw new IllegalArgumentException("Expected a string of even length");
        }
        int length = str.length() >> 1;
        byte[] bArr = new byte[length];
        for (int i10 = 0; i10 < length; i10++) {
            int i11 = i10 + i10;
            int iDigit = Character.digit(str.charAt(i11), 16);
            int iDigit2 = Character.digit(str.charAt(i11 + 1), 16);
            if (iDigit == -1 || iDigit2 == -1) {
                throw new IllegalArgumentException("input is not hexadecimal");
            }
            bArr[i10] = (byte) ((iDigit * 16) + iDigit2);
        }
        return bArr;
    }

    public static void C0(int i10, String str, boolean z10) {
        if (!z10) {
            throw new IllegalArgumentException(B0(str, Integer.valueOf(i10)));
        }
    }

    public static byte[] D(BigInteger bigInteger) {
        if (bigInteger.signum() != -1) {
            return bigInteger.toByteArray();
        }
        throw new IllegalArgumentException("n must not be negative");
    }

    public static void D0(long j10, byte[] bArr, int i10) {
        for (int i11 = 0; i11 < 4; i11++) {
            bArr[i10 + i11] = (byte) (255 & j10);
            j10 >>= 8;
        }
    }

    public static byte[] E(byte[] bArr) {
        if (bArr.length != 16) {
            throw new IllegalArgumentException("value must be a block.");
        }
        byte[] bArr2 = new byte[16];
        int i10 = 0;
        while (i10 < 16) {
            int i11 = i10 + 1;
            byte b10 = bArr[i10];
            byte b11 = (byte) ((b10 + b10) & 254);
            bArr2[i10] = b11;
            if (i10 < 15) {
                bArr2[i10] = (byte) (((bArr[i11] >> 7) & 1) | b11);
            }
            i10 = i11;
        }
        bArr2[15] = (byte) (((byte) ((bArr[0] >> 7) & 135)) ^ bArr2[15]);
        return bArr2;
    }

    public static void E0(File file, boolean z10) {
        if (z10 && file.exists() && !file.isDirectory()) {
            file.delete();
        }
        if (file.exists()) {
            return;
        }
        file.mkdirs();
    }

    public static byte[] F(byte[] bArr, byte[] bArr2) {
        long jR = R(0, bArr) & 67108863;
        long jR2 = (R(3, bArr) >> 2) & 67108611;
        long jR3 = (R(6, bArr) >> 4) & 67092735;
        long jR4 = (R(9, bArr) >> 6) & 66076671;
        long jR5 = (R(12, bArr) >> 8) & 1048575;
        int i10 = 17;
        byte[] bArr3 = new byte[17];
        long j10 = 0;
        int i11 = 0;
        long j11 = 0;
        long j12 = 0;
        long j13 = 0;
        long j14 = 0;
        while (true) {
            int length = bArr2.length;
            if (i11 >= length) {
                long j15 = j10 + (j11 >> 26);
                long j16 = j15 & 67108863;
                long j17 = j12 + (j15 >> 26);
                long j18 = j17 & 67108863;
                long j19 = j13 + (j17 >> 26);
                long j20 = j19 & 67108863;
                long j21 = ((j19 >> 26) * 5) + j14;
                long j22 = j21 >> 26;
                long j23 = j21 & 67108863;
                long j24 = j23 + 5;
                long j25 = (j11 & 67108863) + j22;
                long j26 = j25 + (j24 >> 26);
                long j27 = j16 + (j26 >> 26);
                long j28 = j18 + (j27 >> 26);
                long j29 = (j20 + (j28 >> 26)) - 67108864;
                long j30 = j29 >> 63;
                long j31 = ~j30;
                long j32 = (j25 & j30) | (j26 & 67108863 & j31);
                long j33 = (j16 & j30) | (j27 & 67108863 & j31);
                long j34 = (j18 & j30) | (j28 & 67108863 & j31);
                long j35 = (j20 & j30) | (j29 & j31);
                long jR6 = R(16, bArr) + (((j23 & j30) | (j24 & 67108863 & j31) | (j32 << 26)) & 4294967295L);
                long jR7 = R(20, bArr) + (((j32 >> 6) | (j33 << 20)) & 4294967295L);
                long jR8 = R(24, bArr) + (((j33 >> 12) | (j34 << 14)) & 4294967295L);
                long jR9 = R(28, bArr) + (((j34 >> 18) | (j35 << 8)) & 4294967295L);
                byte[] bArr4 = new byte[16];
                D0(jR6 & 4294967295L, bArr4, 0);
                long j36 = jR7 + (jR6 >> 32);
                D0(j36 & 4294967295L, bArr4, 4);
                long j37 = jR8 + (j36 >> 32);
                D0(j37 & 4294967295L, bArr4, 8);
                D0((jR9 + (j37 >> 32)) & 4294967295L, bArr4, 12);
                return bArr4;
            }
            int iMin = Math.min(16, length - i11);
            System.arraycopy(bArr2, i11, bArr3, 0, iMin);
            bArr3[iMin] = 1;
            if (iMin != 16) {
                Arrays.fill(bArr3, iMin + 1, i10, (byte) 0);
            }
            long j38 = jR5 * 5;
            long j39 = jR4 * 5;
            long j40 = jR3 * 5;
            long jR10 = j14 + (R(0, bArr3) & 67108863);
            long jR11 = j11 + ((R(3, bArr3) >> 2) & 67108863);
            long jR12 = j10 + ((R(6, bArr3) >> 4) & 67108863);
            long jR13 = j12 + ((R(9, bArr3) >> 6) & 67108863);
            long jR14 = j13 + (((R(12, bArr3) >> 8) & 67108863) | ((long) (bArr3[16] << 24)));
            long j41 = jR12 * jR;
            long j42 = jR12 * jR2;
            long j43 = jR13 * jR;
            long j44 = jR12 * jR3;
            long j45 = jR13 * jR2;
            long j46 = jR14 * jR;
            long j47 = (jR2 * 5 * jR14) + (jR13 * j40) + (jR12 * j39) + (jR11 * j38) + (jR10 * jR);
            long j48 = jR12 * j38;
            long j49 = j40 * jR14;
            long j50 = j49 + (jR13 * j39) + j48 + (jR10 * jR2) + (jR11 * jR) + (j47 >> 26);
            long j51 = jR13 * j38;
            long j52 = j39 * jR14;
            long j53 = j52 + j51 + (jR10 * jR3) + (jR11 * jR2) + j41 + (j50 >> 26);
            long j54 = jR14 * j38;
            long j55 = j54 + (jR10 * jR4) + (jR11 * jR3) + j42 + j43 + (j53 >> 26);
            long j56 = j55 >> 26;
            long j57 = j55 & 67108863;
            long j58 = (jR10 * jR5) + (jR11 * jR4) + j44 + j45 + j46 + j56;
            long j59 = ((j58 >> 26) * 5) + (j47 & 67108863);
            j11 = (j50 & 67108863) + (j59 >> 26);
            i11 += 16;
            i10 = 17;
            j13 = j58 & 67108863;
            j14 = j59 & 67108863;
            j10 = j53 & 67108863;
            j12 = j57;
        }
    }

    public static void F0(List list, oq1 oq1Var, int i10, int i11) {
        int size = list.size();
        while (true) {
            size--;
            if (size <= i11) {
                break;
            } else if (oq1Var.zza(list.get(size))) {
                list.remove(size);
            }
        }
        while (true) {
            i11--;
            if (i11 < i10) {
                return;
            } else {
                list.remove(i11);
            }
        }
    }

    public static byte[] G(byte[]... bArr) throws GeneralSecurityException {
        int i10 = 0;
        int i11 = 0;
        while (true) {
            if (i10 >= bArr.length) {
                byte[] bArr2 = new byte[i11];
                int i12 = 0;
                for (byte[] bArr3 : bArr) {
                    int length = bArr3.length;
                    System.arraycopy(bArr3, 0, bArr2, i12, length);
                    i12 += length;
                }
                return bArr2;
            }
            int length2 = bArr[i10].length;
            if (i11 > Integer.MAX_VALUE - length2) {
                throw new GeneralSecurityException("exceeded size limit");
            }
            i11 += length2;
            i10++;
        }
    }

    public static boolean G0(char c6) {
        return c6 >= 'A' && c6 <= 'Z';
    }

    public static long[] H(long[]... jArr) {
        long length = 0;
        for (long[] jArr2 : jArr) {
            length += (long) jArr2.length;
        }
        int i10 = (int) length;
        L0("the total number of elements (%s) in the arrays must fit in an int", length, length == ((long) i10));
        long[] jArr3 = new long[i10];
        int i11 = 0;
        for (long[] jArr4 : jArr) {
            int length2 = jArr4.length;
            System.arraycopy(jArr4, 0, jArr3, i11, length2);
            i11 += length2;
        }
        return jArr3;
    }

    public static boolean H0(Set set, Object obj) {
        if (set == obj) {
            return true;
        }
        if (obj instanceof Set) {
            Set set2 = (Set) obj;
            try {
                if (set.size() == set2.size()) {
                    if (set.containsAll(set2)) {
                        return true;
                    }
                }
            } catch (ClassCastException | NullPointerException unused) {
            }
        }
        return false;
    }

    public static int I(int i10) {
        switch (i10) {
            case 0:
                return 1;
            case 1:
                return 2;
            case 2:
                return 3;
            case 3:
                return 4;
            case 4:
                return 5;
            case 5:
                return 6;
            case 6:
                return 7;
            case 7:
                return 8;
            case 8:
                return 9;
            case 9:
                return 10;
            case 10:
                return 11;
            case 11:
                return 12;
            case 12:
                return 13;
            default:
                return 0;
        }
    }

    public static int I0(Object obj, Object obj2, int i10, Object obj3, int[] iArr, Object[] objArr, Object[] objArr2) {
        int i11;
        int i12;
        int iP = P(obj);
        int i13 = iP & i10;
        int iN = N(i13, obj3);
        if (iN != 0) {
            int i14 = ~i10;
            int i15 = iP & i14;
            int i16 = -1;
            while (true) {
                i11 = iN - 1;
                int i17 = iArr[i11];
                i12 = i17 & i10;
                if ((i17 & i14) != i15 || !Objects.equals(obj, objArr[i11]) || (objArr2 != null && !Objects.equals(obj2, objArr2[i11]))) {
                    if (i12 == 0) {
                        break;
                    }
                    i16 = i11;
                    iN = i12;
                } else {
                    break;
                }
            }
            if (i16 == -1) {
                s0(i13, i12, obj3);
            } else {
                iArr[i16] = (iArr[i16] & i14) | (i12 & i10);
            }
            return i11;
        }
        return -1;
    }

    public static String J(String str) {
        return str == null ? "" : str;
    }

    public static long J0(int i10, byte[] bArr) {
        return (((long) bArr[i10]) & 255) | ((((long) bArr[i10 + 1]) & 255) << 8) | ((((long) bArr[i10 + 2]) & 255) << 16) | ((((long) bArr[i10 + 3]) & 255) << 24) | ((((long) bArr[i10 + 4]) & 255) << 32) | ((((long) bArr[i10 + 5]) & 255) << 40) | ((((long) bArr[i10 + 6]) & 255) << 48) | ((((long) bArr[i10 + 7]) & 255) << 56);
    }

    public static byte[] K(byte[] bArr) {
        int i10;
        byte[] bArr2 = new byte[64];
        int i11 = 0;
        while (true) {
            if (i11 >= 32) {
                break;
            }
            int i12 = i11 + i11;
            bArr2[i12] = (byte) (bArr[i11] & 15);
            bArr2[i12 + 1] = (byte) ((bArr[i11] & 255) >> 4);
            i11++;
        }
        int i13 = 0;
        int i14 = 0;
        while (i13 < 63) {
            byte b10 = (byte) (bArr2[i13] + i14);
            bArr2[i13] = b10;
            int i15 = (b10 + 8) >> 4;
            bArr2[i13] = (byte) (b10 - (i15 << 4));
            i13++;
            i14 = i15;
        }
        bArr2[63] = (byte) (bArr2[63] + i14);
        pz1 pz1Var = new pz1(f12514f, 0);
        pz1 pz1Var2 = new pz1();
        for (i10 = 1; i10 < 64; i10 += 2) {
            nz1 nz1Var = new nz1();
            i1(nz1Var, i10 / 2, bArr2[i10]);
            pz1.a(pz1Var2, pz1Var);
            V0(pz1Var, pz1Var2, nz1Var);
        }
        vu0 vu0Var = new vu0(19);
        vu0.m(vu0Var, pz1Var);
        a1(vu0Var, pz1Var);
        vu0.m(vu0Var, pz1Var);
        a1(vu0Var, pz1Var);
        vu0.m(vu0Var, pz1Var);
        a1(vu0Var, pz1Var);
        vu0.m(vu0Var, pz1Var);
        a1(vu0Var, pz1Var);
        for (int i16 = 0; i16 < 64; i16 += 2) {
            nz1 nz1Var2 = new nz1();
            i1(nz1Var2, i16 / 2, bArr2[i16]);
            pz1.a(pz1Var2, pz1Var);
            V0(pz1Var, pz1Var2, nz1Var2);
        }
        vu0 vu0Var2 = new vu0(pz1Var);
        long[] jArr = new long[10];
        vj1.p(jArr, (long[]) vu0Var2.f17778b);
        long[] jArr2 = new long[10];
        vj1.p(jArr2, (long[]) vu0Var2.f17779c);
        long[] jArr3 = new long[10];
        vj1.p(jArr3, (long[]) vu0Var2.f17780d);
        long[] jArr4 = new long[10];
        vj1.p(jArr4, jArr3);
        long[] jArr5 = new long[10];
        vj1.j(jArr5, jArr2, jArr);
        vj1.n(jArr5, jArr5, jArr3);
        long[] jArr6 = new long[10];
        vj1.n(jArr6, jArr, jArr2);
        vj1.n(jArr6, jArr6, qz1.f15907a);
        vj1.g(jArr6, jArr6, jArr4);
        vj1.l(jArr6, jArr6);
        if (MessageDigest.isEqual(vj1.r(jArr5), vj1.r(jArr6))) {
            return vu0Var2.o();
        }
        throw new IllegalStateException("arithmetic error in scalar multiplication");
    }

    public static String K0(Object obj) {
        if (obj == null) {
            return "null";
        }
        try {
            return obj.toString();
        } catch (Exception e10) {
            String name = obj.getClass().getName();
            String hexString = Integer.toHexString(System.identityHashCode(obj));
            String strP = defpackage.e.p(new StringBuilder(name.length() + 1 + String.valueOf(hexString).length()), name, "@", hexString);
            Logger.getLogger("com.google.common.base.Strings").logp(Level.WARNING, "com.google.common.base.Strings", "lenientToString", "Exception during lenientFormat for ".concat(strP), (Throwable) e10);
            String name2 = e10.getClass().getName();
            StringBuilder sb = new StringBuilder(strP.length() + 8 + name2.length() + 1);
            u.a.h(sb, "<", strP, " threw ", name2);
            sb.append(">");
            return sb.toString();
        }
    }

    public static int L(int i10) {
        return (int) (((long) Integer.rotateLeft((int) (((long) i10) * (-862048943)), 15)) * 461845907);
    }

    public static void L0(String str, long j10, boolean z10) {
        if (!z10) {
            throw new IllegalArgumentException(B0(str, Long.valueOf(j10)));
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:20:0x003e, code lost:
    
        if (((r0 & 1) & (r7 != java.math.RoundingMode.HALF_EVEN ? 0 : 1)) != 0) goto L27;
     */
    /* JADX WARN: Code restructure failed: missing block: B:22:0x0041, code lost:
    
        if (r1 > 0) goto L27;
     */
    /* JADX WARN: Code restructure failed: missing block: B:24:0x0044, code lost:
    
        if (r5 > 0) goto L27;
     */
    /* JADX WARN: Code restructure failed: missing block: B:26:0x0047, code lost:
    
        if (r5 < 0) goto L27;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static int M(int i10, int i11, RoundingMode roundingMode) {
        roundingMode.getClass();
        if (i11 == 0) {
            throw new ArithmeticException("/ by zero");
        }
        int i12 = i10 / i11;
        int i13 = i10 - (i11 * i12);
        if (i13 != 0) {
            int i14 = ((i10 ^ i11) >> 31) | 1;
            switch (pt1.f15528a[roundingMode.ordinal()]) {
                case 1:
                    f0(false);
                case 2:
                    return i12;
                case 3:
                    break;
                case 4:
                    return i12 + i14;
                case 5:
                    break;
                case 6:
                case 7:
                case 8:
                    int iAbs = Math.abs(i13);
                    int iAbs2 = iAbs - (Math.abs(i11) - iAbs);
                    if (iAbs2 == 0) {
                        if (roundingMode != RoundingMode.HALF_UP) {
                            break;
                        }
                        return i12 + i14;
                    }
                    break;
                default:
                    throw new AssertionError();
            }
        }
        return i12;
    }

    public static boolean M0(File file) {
        boolean z10;
        if (!file.exists()) {
            return true;
        }
        File[] fileArrListFiles = file.listFiles();
        if (fileArrListFiles != null) {
            z10 = true;
            for (int i10 = 0; i10 < fileArrListFiles.length; i10++) {
                File file2 = fileArrListFiles[i10];
                z10 = file2 != null && M0(file2) && z10;
            }
        } else {
            z10 = true;
        }
        return file.delete() && z10;
    }

    public static int N(int i10, Object obj) {
        return obj instanceof byte[] ? ((byte[]) obj)[i10] & 255 : obj instanceof short[] ? (char) ((short[]) obj)[i10] : ((int[]) obj)[i10];
    }

    public static boolean N0(String str, CharSequence charSequence) {
        char c6;
        int length = str.length();
        if (str == charSequence) {
            return true;
        }
        if (length != charSequence.length()) {
            return false;
        }
        for (int i10 = 0; i10 < length; i10++) {
            if (str.charAt(i10) != charSequence.charAt(i10) && ((c6 = (char) ((r4 | ' ') - 97)) >= 26 || c6 != ((char) ((r5 | ' ') - 97)))) {
                return false;
            }
        }
        return true;
    }

    public static int O(int i10, byte[] bArr, int i11, ga2 ga2Var) {
        byte b10 = bArr[i11];
        int i12 = i11 + 1;
        int i13 = i10 & 127;
        if (b10 >= 0) {
            ga2Var.f11678a = i13 | (b10 << 7);
            return i12;
        }
        int i14 = i13 | ((b10 & 127) << 7);
        int i15 = i11 + 2;
        byte b11 = bArr[i12];
        if (b11 >= 0) {
            ga2Var.f11678a = i14 | (b11 << 14);
            return i15;
        }
        int i16 = i14 | ((b11 & 127) << 14);
        int i17 = i11 + 3;
        byte b12 = bArr[i15];
        if (b12 >= 0) {
            ga2Var.f11678a = i16 | (b12 << 21);
            return i17;
        }
        int i18 = i16 | ((b12 & 127) << 21);
        int i19 = i11 + 4;
        byte b13 = bArr[i17];
        if (b13 >= 0) {
            ga2Var.f11678a = i18 | (b13 << 28);
            return i19;
        }
        int i20 = i18 | ((b13 & 127) << 28);
        while (true) {
            int i21 = i19 + 1;
            if (bArr[i19] >= 0) {
                ga2Var.f11678a = i20;
                return i21;
            }
            i19 = i21;
        }
    }

    public static /* synthetic */ boolean O0(long[] jArr) {
        long[] jArr2 = new long[11];
        System.arraycopy(jArr, 0, jArr2, 0, 10);
        vj1.m(jArr2);
        byte[] bArrR = vj1.r(jArr2);
        for (int i10 = 0; i10 < 32; i10++) {
            if (bArrR[i10] != 0) {
                return true;
            }
        }
        return false;
    }

    public static int P(Object obj) {
        return L(obj == null ? 0 : obj.hashCode());
    }

    public static int P0(byte[] bArr, int i10, ga2 ga2Var) throws zzicg {
        int iD = d(bArr, i10, ga2Var);
        int i11 = ga2Var.f11678a;
        if (i11 < 0) {
            throw new zzicg("CodedInputStream encountered an embedded string or message which claimed to have negative size.");
        }
        if (i11 == 0) {
            ga2Var.f11680c = "";
            return iD;
        }
        ga2Var.f11680c = tc2.d(iD, i11, bArr);
        return iD + i11;
    }

    public static int Q(boolean z10) {
        MediaCodecInfo.VideoCapabilities videoCapabilities;
        List supportedPerformancePoints;
        try {
            sm2 sm2Var = new sm2();
            sm2Var.zzm(MimeTypes.VIDEO_H264);
            zn2 zn2Var = new zn2(sm2Var);
            if (zn2Var.zzo != null) {
                List listB = do2.b(xv1.f18601h, zn2Var, z10, false);
                for (int i10 = 0; i10 < ((zzgwa) listB).f19788d; i10++) {
                    zzgwa zzgwaVar = (zzgwa) listB;
                    if (((tn2) zzgwaVar.get(i10)).zzd != null && (videoCapabilities = ((tn2) zzgwaVar.get(i10)).zzd.getVideoCapabilities()) != null && (supportedPerformancePoints = videoCapabilities.getSupportedPerformancePoints()) != null && !supportedPerformancePoints.isEmpty()) {
                        androidx.media3.exoplayer.audio.m.j();
                        MediaCodecInfo.VideoCapabilities.PerformancePoint performancePointE = androidx.media3.exoplayer.audio.m.e();
                        for (int i11 = 0; i11 < supportedPerformancePoints.size(); i11++) {
                            if (androidx.media3.exoplayer.audio.m.g(supportedPerformancePoints.get(i11)).covers(performancePointE)) {
                                return 2;
                            }
                        }
                        return 1;
                    }
                }
            }
        } catch (zzuy unused) {
        }
        return 0;
    }

    public static ov1 Q0(pu1 pu1Var, dv1 dv1Var) {
        ov1 ov1Var = new ov1();
        ov1Var.f15178h = new zzhal(ov1Var, pu1Var);
        ((a30) dv1Var).execute(ov1Var);
        return ov1Var;
    }

    public static long R(int i10, byte[] bArr) {
        int i11 = bArr[i10] & 255;
        int i12 = bArr[i10 + 1] & 255;
        int i13 = bArr[i10 + 2] & 255;
        return ((long) (((bArr[i10 + 3] & 255) << 24) | (i12 << 8) | i11 | (i13 << 16))) & 4294967295L;
    }

    public static void R0(boolean z10, String str, Object obj) {
        if (!z10) {
            throw new IllegalArgumentException(B0(str, obj));
        }
    }

    public static long S(long j10, long j11) {
        u(j10, CmcdData.OBJECT_TYPE_AUDIO_ONLY);
        u(j11, "b");
        if (j10 == 0) {
            return j11;
        }
        if (j11 == 0) {
            return j10;
        }
        int iNumberOfTrailingZeros = Long.numberOfTrailingZeros(j10);
        long jNumberOfTrailingZeros = j10 >> iNumberOfTrailingZeros;
        int iNumberOfTrailingZeros2 = Long.numberOfTrailingZeros(j11);
        long j12 = j11 >> iNumberOfTrailingZeros2;
        while (jNumberOfTrailingZeros != j12) {
            long j13 = jNumberOfTrailingZeros - j12;
            long j14 = (j13 >> 63) & j13;
            long j15 = (j13 - j14) - j14;
            jNumberOfTrailingZeros = j15 >> Long.numberOfTrailingZeros(j15);
            j12 += j14;
        }
        return jNumberOfTrailingZeros << Math.min(iNumberOfTrailingZeros, iNumberOfTrailingZeros2);
    }

    public static boolean S0(Set set, Collection collection) {
        collection.getClass();
        if (collection instanceof ss1) {
            collection = ((ss1) collection).zza();
        }
        boolean zRemove = false;
        if (!(collection instanceof Set) || collection.size() <= set.size()) {
            Iterator it = collection.iterator();
            while (it.hasNext()) {
                zRemove |= set.remove(it.next());
            }
            return zRemove;
        }
        Iterator it2 = set.iterator();
        while (it2.hasNext()) {
            if (collection.contains(it2.next())) {
                it2.remove();
                zRemove = true;
            }
        }
        return zRemove;
    }

    /* JADX WARN: Removed duplicated region for block: B:6:0x0032  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final zzbch T(Context context, ch1 ch1Var) {
        zzbch zzbchVar;
        String[] strArr;
        File file = new File(new File(context.getApplicationInfo().dataDir), "lib");
        boolean zExists = file.exists();
        zzbch zzbchVar2 = zzbch.X86;
        zzbch zzbchVar3 = zzbch.ARM7;
        zzbch zzbchVar4 = zzbch.X86_64;
        zzbch zzbchVar5 = zzbch.ARM64;
        zzbch zzbchVar6 = zzbch.RISCV64;
        zzbch zzbchVar7 = zzbch.UNKNOWN;
        zzbch zzbchVar8 = zzbch.UNSUPPORTED;
        if (zExists) {
            File[] fileArrListFiles = file.listFiles(new mt1(Pattern.compile(".*\\.so$", 2)));
            if (fileArrListFiles == null || fileArrListFiles.length == 0) {
                if (ch1Var != null) {
                    ch1Var.d(5017, "No .so");
                }
                zzbchVar = zzbchVar7;
            } else {
                try {
                    FileInputStream fileInputStream = new FileInputStream(fileArrListFiles[0]);
                    try {
                        byte[] bArr = new byte[20];
                        if (fileInputStream.read(bArr) == 20) {
                            byte[] bArr2 = {0, 0};
                            if (bArr[5] == 2) {
                                x0(bArr, null, ch1Var);
                            } else {
                                bArr2[0] = bArr[19];
                                bArr2[1] = bArr[18];
                                short s10 = ByteBuffer.wrap(bArr2).getShort();
                                if (s10 == 3) {
                                    zzbchVar = zzbchVar2;
                                } else if (s10 == 40) {
                                    zzbchVar = zzbchVar3;
                                } else if (s10 == 62) {
                                    zzbchVar = zzbchVar4;
                                } else if (s10 == 183) {
                                    zzbchVar = zzbchVar5;
                                } else if (s10 != 243) {
                                    x0(bArr, null, ch1Var);
                                    zzbchVar = zzbchVar8;
                                } else {
                                    zzbchVar = zzbchVar6;
                                }
                                fileInputStream.close();
                            }
                        }
                        fileInputStream.close();
                    } finally {
                    }
                } catch (IOException e10) {
                    x0(null, e10.toString(), ch1Var);
                }
                zzbchVar = zzbchVar8;
            }
        } else {
            if (ch1Var != null) {
                ch1Var.d(5017, "No lib/");
            } else {
                ch1Var = null;
            }
            zzbchVar = zzbchVar7;
        }
        if (zzbchVar == zzbchVar7) {
            HashSet hashSet = new HashSet(Arrays.asList("i686", "armv71"));
            String strA = zzgrs.OS_ARCH.a();
            if (TextUtils.isEmpty(strA) || !hashSet.contains(strA)) {
                try {
                    strArr = (String[]) Build.class.getField("SUPPORTED_ABIS").get(null);
                } catch (IllegalAccessException e11) {
                    if (ch1Var != null) {
                        ch1Var.c(2024, 0L, e11);
                    }
                } catch (NoSuchFieldException e12) {
                    if (ch1Var != null) {
                        ch1Var.c(2024, 0L, e12);
                    }
                }
                if (strArr == null || strArr.length <= 0) {
                    strA = Build.CPU_ABI;
                    if (strA == null) {
                        strA = Build.CPU_ABI2;
                    }
                } else {
                    strA = strArr[0];
                }
            }
            if (TextUtils.isEmpty(strA)) {
                x0(null, "Empty dev arch", ch1Var);
            } else if (!strA.equalsIgnoreCase("i686") && !strA.equalsIgnoreCase("x86")) {
                if (strA.equalsIgnoreCase("x86_64")) {
                    zzbchVar2 = zzbchVar4;
                } else if (strA.equalsIgnoreCase("arm64-v8a")) {
                    zzbchVar2 = zzbchVar5;
                } else if (strA.equalsIgnoreCase("armeabi-v7a") || strA.equalsIgnoreCase("armv71")) {
                    zzbchVar2 = zzbchVar3;
                } else if (strA.equalsIgnoreCase("riscv64")) {
                    zzbchVar2 = zzbchVar6;
                } else {
                    x0(null, strA, ch1Var);
                }
            }
            zzbchVar2 = zzbchVar8;
        } else {
            zzbchVar2 = zzbchVar;
        }
        if (ch1Var != null) {
            ch1Var.d(5018, zzbchVar2.name());
        }
        return zzbchVar2;
    }

    public static int T0(byte[] bArr, int i10, ga2 ga2Var) throws zzicg {
        int iD = d(bArr, i10, ga2Var);
        int i11 = ga2Var.f11678a;
        if (i11 < 0) {
            throw new zzicg("CodedInputStream encountered an embedded string or message which claimed to have negative size.");
        }
        if (i11 > bArr.length - iD) {
            throw new zzicg("While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.");
        }
        if (i11 == 0) {
            ga2Var.f11680c = zzian.f19856a;
            return iD;
        }
        ga2Var.f11680c = zzian.w(iD, i11, bArr);
        return iD + i11;
    }

    public static xs1 U(Set set, oq1 oq1Var) {
        if (!(set instanceof SortedSet)) {
            if (!(set instanceof xs1)) {
                set.getClass();
                return new xs1(set, oq1Var);
            }
            xs1 xs1Var = (xs1) set;
            oq1 oq1Var2 = xs1Var.f18562b;
            oq1Var2.getClass();
            return new xs1((Set) xs1Var.f18561a, new zzgre(Arrays.asList(oq1Var2, oq1Var)));
        }
        Set set2 = (SortedSet) set;
        if (!(set2 instanceof xs1)) {
            set2.getClass();
            return new ys1(set2, oq1Var);
        }
        xs1 xs1Var2 = (xs1) set2;
        oq1 oq1Var3 = xs1Var2.f18562b;
        oq1Var3.getClass();
        return new ys1((SortedSet) xs1Var2.f18561a, new zzgre(Arrays.asList(oq1Var3, oq1Var)));
    }

    public static ut1 U0(com.google.common.util.concurrent.w wVar, Class cls, mq1 mq1Var, Executor executor) {
        int i10 = vt1.f17769k;
        ut1 ut1Var = new ut1(wVar, cls, mq1Var);
        wVar.g(ut1Var, za2.C(executor, ut1Var));
        return ut1Var;
    }

    public static dw1 V(byte[] bArr) throws GeneralSecurityException {
        try {
            ua2 ua2Var = ua2.f17195b;
            int i10 = fa2.f11138a;
            w42 w42VarE = w42.E(bArr, ua2.f17196c);
            t02 t02Var = t02.f16664b;
            i92 i92VarB = q12.b(w42VarE.B());
            i12 i12Var = new i12(w42VarE, i92VarB);
            o12 o12Var = (o12) t02Var.f16665a.get();
            o12Var.getClass();
            return !o12Var.f14808d.containsKey(new m12(i92VarB, i12.class)) ? new i02(i12Var) : t02Var.g(i12Var);
        } catch (IOException e10) {
            throw new GeneralSecurityException("Failed to parse proto", e10);
        }
    }

    public static void V0(pz1 pz1Var, pz1 pz1Var2, nz1 nz1Var) {
        long[] jArr = new long[10];
        vu0 vu0Var = pz1Var.f15556a;
        long[] jArr2 = (long[]) vu0Var.f17778b;
        vu0 vu0Var2 = pz1Var2.f15556a;
        long[] jArr3 = (long[]) vu0Var2.f17779c;
        long[] jArr4 = (long[]) vu0Var2.f17778b;
        vj1.g(jArr2, jArr3, jArr4);
        long[] jArr5 = (long[]) vu0Var.f17779c;
        vj1.j(jArr5, jArr3, jArr4);
        vj1.n(jArr5, jArr5, nz1Var.f14775b);
        long[] jArr6 = (long[]) vu0Var.f17780d;
        vj1.n(jArr6, jArr2, nz1Var.f14774a);
        long[] jArr7 = pz1Var.f15557b;
        vj1.n(jArr7, pz1Var2.f15557b, nz1Var.f14776c);
        nz1Var.a(jArr2, (long[]) vu0Var2.f17780d);
        vj1.g(jArr, jArr2, jArr2);
        vj1.j(jArr2, jArr6, jArr5);
        vj1.g(jArr5, jArr6, jArr5);
        vj1.g(jArr6, jArr, jArr7);
        vj1.j(jArr7, jArr, jArr7);
    }

    public static q22 W(o22 o22Var) {
        jc1 jc1Var = o22Var.f14822c;
        r22 r22Var = new r22(jc1Var.h());
        try {
            Provider providerE = vj1.e();
            if (providerE == null) {
                throw new GeneralSecurityException("Conscrypt not available");
            }
            Mac.getInstance("AESCMAC", providerE);
            return new uz0(r22Var, new uz0(jc1Var.h(), providerE));
        } catch (GeneralSecurityException unused) {
            return r22Var;
        }
    }

    public static tt1 W0(com.google.common.util.concurrent.w wVar, Class cls, qu1 qu1Var, Executor executor) {
        int i10 = vt1.f17769k;
        tt1 tt1Var = new tt1(wVar, cls, qu1Var);
        wVar.g(tt1Var, za2.C(executor, tt1Var));
        return tt1Var;
    }

    public static Object X(ws1 ws1Var, String str) {
        vs1 vs1Var = new vs1(ws1Var, ws1Var.f18209a, ws1Var.f18210b);
        return vs1Var.hasNext() ? vs1Var.next() : str;
    }

    public static void X0(pz1 pz1Var, pz1 pz1Var2, nz1 nz1Var) {
        long[] jArr = new long[10];
        vu0 vu0Var = pz1Var.f15556a;
        long[] jArr2 = (long[]) vu0Var.f17778b;
        vu0 vu0Var2 = pz1Var2.f15556a;
        long[] jArr3 = (long[]) vu0Var2.f17779c;
        long[] jArr4 = (long[]) vu0Var2.f17778b;
        vj1.g(jArr2, jArr3, jArr4);
        long[] jArr5 = (long[]) vu0Var.f17779c;
        vj1.j(jArr5, jArr3, jArr4);
        vj1.n(jArr5, jArr5, nz1Var.f14774a);
        long[] jArr6 = (long[]) vu0Var.f17780d;
        vj1.n(jArr6, jArr2, nz1Var.f14775b);
        long[] jArr7 = pz1Var.f15557b;
        vj1.n(jArr7, pz1Var2.f15557b, nz1Var.f14776c);
        nz1Var.a(jArr2, (long[]) vu0Var2.f17780d);
        vj1.g(jArr, jArr2, jArr2);
        vj1.j(jArr2, jArr6, jArr5);
        vj1.g(jArr5, jArr6, jArr5);
        vj1.j(jArr6, jArr, jArr7);
        vj1.g(jArr7, jArr, jArr7);
    }

    public static String Y(zzhxn zzhxnVar) throws GeneralSecurityException {
        int iOrdinal = zzhxnVar.ordinal();
        if (iOrdinal == 0) {
            return "SHA-1";
        }
        if (iOrdinal == 1) {
            return "SHA-224";
        }
        if (iOrdinal == 2) {
            return "SHA-256";
        }
        if (iOrdinal == 3) {
            return "SHA-384";
        }
        if (iOrdinal == 4) {
            return "SHA-512";
        }
        throw new GeneralSecurityException("Unsupported hash ".concat(zzhxnVar.toString()));
    }

    public static int Y0(ic2 ic2Var, byte[] bArr, int i10, int i11, int i12, ga2 ga2Var) throws zzicg {
        cb2 cb2VarZza = ic2Var.zza();
        int iG1 = g1(cb2VarZza, ic2Var, bArr, i10, i11, i12, ga2Var);
        ic2Var.f(cb2VarZza);
        ga2Var.f11680c = cb2VarZza;
        return iG1;
    }

    public static String Z(String str) {
        int length = str.length();
        int i10 = 0;
        while (i10 < length) {
            char cCharAt = str.charAt(i10);
            if (cCharAt >= 'a' && cCharAt <= 'z') {
                char[] charArray = str.toCharArray();
                while (i10 < length) {
                    char c6 = charArray[i10];
                    if (c6 >= 'a' && c6 <= 'z') {
                        charArray[i10] = (char) (c6 ^ ' ');
                    }
                    i10++;
                }
                return String.valueOf(charArray);
            }
            i10++;
        }
        return str;
    }

    public static com.google.common.util.concurrent.w Z0(com.google.common.util.concurrent.w wVar, long j10, TimeUnit timeUnit, ScheduledExecutorService scheduledExecutorService) {
        if (wVar.isDone()) {
            return wVar;
        }
        nv1 nv1Var = new nv1();
        nv1Var.f14745h = wVar;
        mv1 mv1Var = new mv1(nv1Var, 0);
        nv1Var.f14746i = scheduledExecutorService.schedule(mv1Var, j10, timeUnit);
        wVar.g(mv1Var, zzgzd.f19813a);
        return nv1Var;
    }

    public static ECParameterSpec a0(zzhww zzhwwVar) throws NoSuchAlgorithmException {
        int iOrdinal = zzhwwVar.ordinal();
        if (iOrdinal == 0) {
            return sz1.f16638a;
        }
        if (iOrdinal == 1) {
            return sz1.f16639b;
        }
        if (iOrdinal == 2) {
            return sz1.f16640c;
        }
        throw new NoSuchAlgorithmException("curve not implemented:".concat(zzhwwVar.toString()));
    }

    public static void a1(vu0 vu0Var, pz1 pz1Var) {
        vu0 vu0Var2 = pz1Var.f15556a;
        long[] jArr = (long[]) vu0Var2.f17778b;
        long[] jArr2 = (long[]) vu0Var.f17778b;
        long[] jArr3 = new long[10];
        vj1.p(jArr, jArr2);
        long[] jArr4 = (long[]) vu0Var2.f17780d;
        long[] jArr5 = (long[]) vu0Var.f17779c;
        vj1.p(jArr4, jArr5);
        long[] jArr6 = (long[]) vu0Var.f17780d;
        long[] jArr7 = pz1Var.f15557b;
        vj1.p(jArr7, jArr6);
        vj1.g(jArr7, jArr7, jArr7);
        long[] jArr8 = (long[]) vu0Var2.f17779c;
        vj1.g(jArr8, jArr2, jArr5);
        vj1.p(jArr3, jArr8);
        vj1.g(jArr8, jArr4, jArr);
        vj1.j(jArr4, jArr4, jArr);
        vj1.j(jArr, jArr3, jArr8);
        vj1.j(jArr7, jArr7, jArr4);
    }

    public static void b0(int i10, Object obj) {
        if (obj == null) {
            throw new NullPointerException(defpackage.e.n(new StringBuilder(String.valueOf(i10).length() + 9), "at index ", i10));
        }
    }

    public static void b1(boolean z10) {
        if (!z10) {
            throw new IllegalStateException();
        }
    }

    public static byte c(long j10) {
        L0("out of range: %s", j10, (j10 >> 8) == 0);
        return (byte) j10;
    }

    public static void c0(int i10, String str) {
        if (i10 >= 0) {
            return;
        }
        StringBuilder sb = new StringBuilder(str.length() + 29 + String.valueOf(i10).length());
        sb.append(str);
        sb.append(" cannot be negative but was: ");
        sb.append(i10);
        throw new IllegalArgumentException(sb.toString());
    }

    public static int c1(int i10, int i11) {
        int i12 = (~(i10 ^ i11)) & 255;
        int i13 = i12 & (i12 << 4);
        int i14 = i13 & (i13 << 2);
        return (i14 & (i14 + i14)) >> 7;
    }

    public static int d(byte[] bArr, int i10, ga2 ga2Var) {
        int i11 = i10 + 1;
        byte b10 = bArr[i10];
        if (b10 < 0) {
            return O(b10, bArr, i11, ga2Var);
        }
        ga2Var.f11678a = b10;
        return i11;
    }

    public static void d0(File file) throws IOException {
        file.getClass();
        File parentFile = file.getCanonicalFile().getParentFile();
        if (parentFile == null) {
            return;
        }
        parentFile.mkdirs();
        if (!parentFile.isDirectory()) {
            throw new IOException("Unable to create parent directories of ".concat(file.toString()));
        }
    }

    public static int d1(Object obj, ic2 ic2Var, byte[] bArr, int i10, int i11, ga2 ga2Var) throws zzicg {
        int iO = i10 + 1;
        int i12 = bArr[i10];
        if (i12 < 0) {
            iO = O(i12, bArr, iO, ga2Var);
            i12 = ga2Var.f11678a;
        }
        int i13 = iO;
        if (i12 < 0 || i12 > i11 - i13) {
            throw new zzicg("While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.");
        }
        int i14 = ga2Var.f11681d + 1;
        ga2Var.f11681d = i14;
        if (i14 >= 100) {
            throw new zzicg("Protocol message had too many levels of nesting.  May be malicious.  Use setRecursionLimit() to increase the recursion depth limit.");
        }
        int i15 = i12 + i13;
        ic2Var.i(obj, bArr, i13, i15, ga2Var);
        ga2Var.f11681d--;
        ga2Var.f11680c = obj;
        return i15;
    }

    public static long e(double d10) {
        e0("not a normal value", g0(d10));
        int exponent = Math.getExponent(d10);
        long jDoubleToRawLongBits = Double.doubleToRawLongBits(d10) & 4503599627370495L;
        return exponent == -1023 ? jDoubleToRawLongBits + jDoubleToRawLongBits : jDoubleToRawLongBits | 4503599627370496L;
    }

    public static void e0(String str, boolean z10) {
        if (!z10) {
            throw new IllegalArgumentException(str);
        }
    }

    public static ju1 e1(com.google.common.util.concurrent.w wVar, qu1 qu1Var, Executor executor) {
        int i10 = lu1.f13870j;
        ju1 ju1Var = new ju1(wVar, qu1Var);
        wVar.g(ju1Var, za2.C(executor, ju1Var));
        return ju1Var;
    }

    /* JADX WARN: Code restructure failed: missing block: B:20:0x0049, code lost:
    
        if (r8 > 0) goto L23;
     */
    /* JADX WARN: Code restructure failed: missing block: B:22:0x004c, code lost:
    
        if (r8 < 0) goto L23;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static long f(long j10, long j11, RoundingMode roundingMode) {
        roundingMode.getClass();
        long j12 = j10 / j11;
        long j13 = j10 - (j11 * j12);
        if (j13 != 0) {
            int i10 = ((int) ((j10 ^ j11) >> 63)) | 1;
            switch (qt1.f15859a[roundingMode.ordinal()]) {
                case 1:
                    f0(false);
                case 2:
                case 3:
                    break;
                case 4:
                    return j12 + ((long) i10);
                case 5:
                    break;
                case 6:
                case 7:
                case 8:
                    long jAbs = Math.abs(j13);
                    long jAbs2 = jAbs - (Math.abs(j11) - jAbs);
                    return jAbs2 != 0 ? j12 : j12;
                default:
                    throw new AssertionError();
            }
        }
    }

    public static void f0(boolean z10) {
        if (!z10) {
            throw new ArithmeticException("mode was UNNECESSARY, but rounding was necessary");
        }
    }

    public static void f1(String str, boolean z10) {
        if (!z10) {
            throw new IllegalStateException(str);
        }
    }

    public static pf g(Context context, String str, String str2) {
        pf pfVar;
        try {
            pfVar = (pf) new hh1(context, str, str2).f12170d.poll(5000L, TimeUnit.MILLISECONDS);
        } catch (InterruptedException unused) {
            pfVar = null;
        }
        return pfVar == null ? hh1.b() : pfVar;
    }

    public static boolean g0(double d10) {
        return Math.getExponent(d10) <= 1023;
    }

    public static int g1(Object obj, ic2 ic2Var, byte[] bArr, int i10, int i11, int i12, ga2 ga2Var) throws zzicg {
        yb2 yb2Var = (yb2) ic2Var;
        int i13 = ga2Var.f11681d + 1;
        ga2Var.f11681d = i13;
        if (i13 >= 100) {
            throw new zzicg("Protocol message had too many levels of nesting.  May be malicious.  Use setRecursionLimit() to increase the recursion depth limit.");
        }
        int iW = yb2Var.w(obj, bArr, i10, i11, i12, ga2Var);
        ga2Var.f11681d--;
        ga2Var.f11680c = obj;
        return iW;
    }

    public static ei1 h(Context context, zzbch zzbchVar, String str, String str2, ch1 ch1Var) {
        ei1 ei1Var;
        jh1 jh1Var = new jh1(context, zzbchVar, str, str2, ch1Var);
        try {
            ei1Var = (ei1) jh1Var.f12868e.poll(50000L, TimeUnit.MILLISECONDS);
        } catch (InterruptedException e10) {
            jh1Var.b(2009, jh1Var.f12871h, e10);
            ei1Var = null;
        }
        jh1Var.b(PlaybackException.ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED, jh1Var.f12871h, null);
        if (ei1Var != null) {
            if (ei1Var.f10802c == 7) {
                ch1.f9896e = 3;
            } else {
                ch1.f9896e = 2;
            }
        }
        return ei1Var == null ? new ei1() : ei1Var;
    }

    public static boolean h0(File file, byte[] bArr) throws Throwable {
        FileOutputStream fileOutputStream = null;
        try {
            FileOutputStream fileOutputStream2 = new FileOutputStream(file);
            try {
                if (Build.VERSION.SDK_INT >= 34) {
                    file.setReadOnly();
                }
                fileOutputStream2.write(bArr);
                fileOutputStream2.flush();
                hb.a.d(fileOutputStream2);
                return true;
            } catch (IOException unused) {
                fileOutputStream = fileOutputStream2;
                hb.a.d(fileOutputStream);
                return false;
            } catch (Throwable th) {
                th = th;
                fileOutputStream = fileOutputStream2;
                hb.a.d(fileOutputStream);
                throw th;
            }
        } catch (IOException unused2) {
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public static ku1 h1(com.google.common.util.concurrent.w wVar, mq1 mq1Var, Executor executor) {
        int i10 = lu1.f13870j;
        ku1 ku1Var = new ku1(wVar, mq1Var);
        wVar.g(ku1Var, za2.C(executor, ku1Var));
        return ku1Var;
    }

    public static wj1 i(w8.h hVar) {
        wj1 wj1Var = new wj1();
        wj1Var.f18095h = hVar;
        hVar.a(zzgzd.f19813a, new jc1(wj1Var, 7));
        return wj1Var;
    }

    public static boolean i0(Object obj, Map map) {
        if (map == obj) {
            return true;
        }
        if (obj instanceof Map) {
            return map.entrySet().equals(((Map) obj).entrySet());
        }
        return false;
    }

    public static void i1(nz1 nz1Var, int i10, byte b10) {
        nz1[][] nz1VarArr = qz1.f15910d;
        int i11 = (b10 & 255) >> 7;
        int i12 = (-i11) & b10;
        int i13 = b10 - (i12 + i12);
        nz1Var.b(nz1VarArr[i10][0], c1(i13, 1));
        nz1Var.b(nz1VarArr[i10][1], c1(i13, 2));
        nz1Var.b(nz1VarArr[i10][2], c1(i13, 3));
        nz1Var.b(nz1VarArr[i10][3], c1(i13, 4));
        nz1Var.b(nz1VarArr[i10][4], c1(i13, 5));
        nz1Var.b(nz1VarArr[i10][5], c1(i13, 6));
        nz1Var.b(nz1VarArr[i10][6], c1(i13, 7));
        nz1Var.b(nz1VarArr[i10][7], c1(i13, 8));
        long[] jArrCopyOf = Arrays.copyOf(nz1Var.f14775b, 10);
        long[] jArrCopyOf2 = Arrays.copyOf(nz1Var.f14774a, 10);
        long[] jArrCopyOf3 = Arrays.copyOf(nz1Var.f14776c, 10);
        for (int i14 = 0; i14 < jArrCopyOf3.length; i14++) {
            jArrCopyOf3[i14] = -jArrCopyOf3[i14];
        }
        nz1Var.b(new nz1(jArrCopyOf, jArrCopyOf2, jArrCopyOf3), i11);
    }

    public static ws1 j(zzgup zzgupVar, zzgup zzgupVar2) {
        if (zzgupVar == null) {
            throw new NullPointerException("set1");
        }
        if (zzgupVar2 != null) {
            return new ws1(zzgupVar, zzgupVar2);
        }
        throw new NullPointerException("set2");
    }

    public static byte[] j0(String str, boolean z10) {
        ft1 ft1Var;
        if (z10) {
            ft1Var = gt1.f11872e;
            if (ft1Var.f11875b != null) {
                ft1Var = new ft1(ft1Var.f11874a, null);
            }
        } else {
            ft1Var = gt1.f11871d;
        }
        byte[] bArrH = ft1Var.h(str);
        if (bArrH.length != 0 || str.length() <= 0) {
            return bArrH;
        }
        throw new IllegalArgumentException("Unable to decode ".concat(str));
    }

    public static void j1(Object obj, String str) {
        if (obj == null) {
            throw new NullPointerException(str);
        }
    }

    public static bv1 k(Object obj) {
        return obj == null ? bv1.f9665b : new bv1(obj);
    }

    public static byte[] k0(BigInteger bigInteger, int i10) throws GeneralSecurityException {
        if (bigInteger.signum() == -1) {
            throw new IllegalArgumentException("integer must be nonnegative");
        }
        byte[] byteArray = bigInteger.toByteArray();
        int length = byteArray.length;
        if (length == i10) {
            return byteArray;
        }
        int i11 = i10 + 1;
        if (length > i11) {
            throw new GeneralSecurityException("integer too large");
        }
        if (length == i11) {
            if (byteArray[0] == 0) {
                return Arrays.copyOfRange(byteArray, 1, length);
            }
            throw new GeneralSecurityException("integer too large");
        }
        byte[] bArr = new byte[i10];
        System.arraycopy(byteArray, 0, bArr, i10 - length, length);
        return bArr;
    }

    public static int k1(int i10, byte[] bArr, int i11, int i12, jb2 jb2Var, ga2 ga2Var) {
        db2 db2Var = (db2) jb2Var;
        int iD = d(bArr, i11, ga2Var);
        db2Var.i(ga2Var.f11678a);
        while (iD < i12) {
            int iD2 = d(bArr, iD, ga2Var);
            if (i10 != ga2Var.f11678a) {
                break;
            }
            iD = d(bArr, iD2, ga2Var);
            db2Var.i(ga2Var.f11678a);
        }
        return iD;
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Code restructure failed: missing block: B:142:0x029d, code lost:
    
        throw new com.google.android.gms.internal.ads.zzhyo("invalid key");
     */
    /* JADX WARN: Removed duplicated region for block: B:113:0x020e  */
    /* JADX WARN: Removed duplicated region for block: B:64:0x0119  */
    /* JADX WARN: Removed duplicated region for block: B:78:0x0161  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static aw1 l(String str) throws Throwable {
        String str2;
        zzhqb zzhqbVar;
        byte b10;
        int i10;
        String strC;
        zzhqy zzhqyVar;
        String strC2;
        String str3 = "invalid keyset";
        try {
            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(str.getBytes(rv1.f16233a));
            String str4 = "status";
            String str5 = "keyData";
            try {
                try {
                    int i11 = gw1.f11901a;
                    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                    byte[] bArr = new byte[1024];
                    while (true) {
                        int i12 = byteArrayInputStream.read(bArr);
                        str2 = str3;
                        if (i12 == -1) {
                            break;
                        }
                        try {
                            byteArrayOutputStream.write(bArr, 0, i12);
                            str3 = str2;
                        } catch (zzhyo e10) {
                            e = e10;
                            throw new IOException(e);
                        } catch (IllegalStateException e11) {
                            e = e11;
                            throw new IOException(e);
                        } catch (Throwable th) {
                            th = th;
                            str3 = str2;
                            try {
                                byteArrayInputStream.close();
                                throw th;
                            } catch (zzicg unused) {
                                throw new GeneralSecurityException(str3);
                            }
                        }
                    }
                    o92 o92VarF = za2.t(new String(byteArrayOutputStream.toByteArray(), rv1.f16233a)).f();
                    try {
                        zzhzc zzhzcVar = o92VarF.f14965a;
                        if (!zzhzcVar.containsKey("key")) {
                            throw new zzhyo("invalid keyset: no key");
                        }
                        m92 m92VarH = o92VarF.h("key");
                        if (!(m92VarH instanceof l92)) {
                            throw new zzhyo("invalid keyset: key must be an array");
                        }
                        m92VarH.getClass();
                        if (!(m92VarH instanceof l92)) {
                            throw new IllegalStateException("Not a JSON Array: ".concat(m92VarH.toString()));
                        }
                        ArrayList arrayList = ((l92) m92VarH).f13550a;
                        if (arrayList.size() == 0) {
                            throw new zzhyo("invalid keyset: key is empty");
                        }
                        y42 y42VarH = b52.H();
                        if (zzhzcVar.containsKey("primaryKeyId")) {
                            int iA = rv1.a(o92VarF.h("primaryKeyId"));
                            y42VarH.c();
                            ((b52) y42VarH.f8617b).I(iA);
                        }
                        int i13 = 0;
                        while (true) {
                            int size = arrayList.size();
                            zzhqb zzhqbVar2 = zzhqb.SYMMETRIC;
                            zzhqb zzhqbVar3 = zzhqb.ASYMMETRIC_PRIVATE;
                            if (i13 >= size) {
                                zzhqb zzhqbVar4 = zzhqbVar3;
                                b52 b52Var = (b52) y42VarH.e();
                                byteArrayInputStream.close();
                                byte[] bArrB = b52Var.b();
                                try {
                                    ua2 ua2Var = ua2.f17195b;
                                    int i14 = fa2.f11138a;
                                    b52 b52VarF = b52.F(bArrB, ua2.f17196c);
                                    for (a52 a52Var : b52VarF.C()) {
                                        if (a52Var.C().D() == zzhqb.UNKNOWN_KEYMATERIAL || a52Var.C().D() == zzhqbVar2 || a52Var.C().D() == (zzhqbVar = zzhqbVar4)) {
                                            throw new GeneralSecurityException(String.format("keyset contains key material of type %s for type url %s", a52Var.C().D().name(), a52Var.C().B()));
                                        }
                                        zzhqbVar4 = zzhqbVar;
                                    }
                                    return aw1.a(b52VarF);
                                } catch (zzicg unused2) {
                                    throw new GeneralSecurityException(str2);
                                }
                            }
                            o92 o92VarF2 = ((m92) arrayList.get(i13)).f();
                            zzhzc zzhzcVar2 = o92VarF2.f14965a;
                            if (zzhzcVar2.containsKey(str5) && zzhzcVar2.containsKey(str4) && zzhzcVar2.containsKey("keyId") && zzhzcVar2.containsKey("outputPrefixType")) {
                                m92 m92VarH2 = o92VarF2.h(str5);
                                if (!(m92VarH2 instanceof o92)) {
                                    throw new zzhyo("invalid key: keyData must be an object");
                                }
                                z42 z42VarF = a52.F();
                                String str6 = str4;
                                String strC3 = o92VarF2.h(str4).c();
                                String str7 = str5;
                                ArrayList arrayList2 = arrayList;
                                int iHashCode = strC3.hashCode();
                                if (iHashCode != -891611359) {
                                    if (iHashCode != 478389753) {
                                        b10 = (iHashCode == 1053567612 && strC3.equals("DISABLED")) ? (byte) 1 : (byte) -1;
                                    } else if (strC3.equals("DESTROYED")) {
                                        b10 = 2;
                                    }
                                } else if (strC3.equals("ENABLED")) {
                                    b10 = 0;
                                }
                                if (b10 == 0) {
                                    i10 = 3;
                                } else if (b10 == 1) {
                                    i10 = 4;
                                } else {
                                    if (b10 != 2) {
                                        throw new zzhyo("unknown status: ".concat(strC3));
                                    }
                                    i10 = 5;
                                }
                                z42VarF.c();
                                ((a52) z42VarF.f8617b).K(i10);
                                int iA2 = rv1.a(o92VarF2.h("keyId"));
                                z42VarF.c();
                                ((a52) z42VarF.f8617b).H(iA2);
                                strC = o92VarF2.h("outputPrefixType").c();
                                strC.getClass();
                                switch (strC) {
                                    case "LEGACY":
                                        zzhqyVar = zzhqy.LEGACY;
                                        break;
                                    case "RAW":
                                        zzhqyVar = zzhqy.RAW;
                                        break;
                                    case "TINK":
                                        zzhqyVar = zzhqy.TINK;
                                        break;
                                    case "CRUNCHY":
                                        zzhqyVar = zzhqy.CRUNCHY;
                                        break;
                                    default:
                                        throw new zzhyo("unknown output prefix type: ".concat(strC));
                                }
                                z42VarF.c();
                                ((a52) z42VarF.f8617b).I(zzhqyVar);
                                o92 o92VarF3 = m92VarH2.f();
                                zzhzc zzhzcVar3 = o92VarF3.f14965a;
                                if (zzhzcVar3.containsKey("typeUrl") && zzhzcVar3.containsKey("value") && zzhzcVar3.containsKey("keyMaterialType")) {
                                    byte[] bArrA = s82.a(o92VarF3.h("value").c());
                                    t42 t42VarE = u42.E();
                                    String strC4 = o92VarF3.h("typeUrl").c();
                                    t42VarE.c();
                                    ((u42) t42VarE.f8617b).G(strC4);
                                    zzian zzianVarW = zzian.w(0, bArrA.length, bArrA);
                                    t42VarE.c();
                                    ((u42) t42VarE.f8617b).H(zzianVarW);
                                    strC2 = o92VarF3.h("keyMaterialType").c();
                                    strC2.getClass();
                                    switch (strC2) {
                                        case "REMOTE":
                                            zzhqbVar2 = zzhqb.REMOTE;
                                            break;
                                        case "SYMMETRIC":
                                            break;
                                        case "ASYMMETRIC_PRIVATE":
                                            zzhqbVar2 = zzhqbVar3;
                                            break;
                                        case "ASYMMETRIC_PUBLIC":
                                            zzhqbVar2 = zzhqb.ASYMMETRIC_PUBLIC;
                                            break;
                                        default:
                                            throw new zzhyo("unknown key material type: ".concat(strC2));
                                    }
                                    t42VarE.c();
                                    ((u42) t42VarE.f8617b).I(zzhqbVar2);
                                    u42 u42Var = (u42) t42VarE.e();
                                    z42VarF.c();
                                    ((a52) z42VarF.f8617b).G(u42Var);
                                    a52 a52Var2 = (a52) z42VarF.e();
                                    y42VarH.c();
                                    ((b52) y42VarH.f8617b).J(a52Var2);
                                    i13++;
                                    str5 = str7;
                                    str4 = str6;
                                    arrayList = arrayList2;
                                }
                            }
                        }
                        throw new zzhyo("invalid keyData");
                    } catch (zzicg unused3) {
                        str3 = str2;
                        throw new GeneralSecurityException(str3);
                    }
                } catch (Throwable th2) {
                    th = th2;
                }
            } catch (zzhyo e12) {
                e = e12;
            } catch (IllegalStateException e13) {
                e = e13;
            }
        } catch (IOException unused4) {
            throw new GeneralSecurityException("Parse keyset failed");
        }
    }

    public static byte[] l0(byte[] bArr) {
        MessageDigest messageDigest = (MessageDigest) w82.f17929e.a("SHA-512");
        messageDigest.update(bArr, 0, 32);
        byte[] bArrDigest = messageDigest.digest();
        bArrDigest[0] = (byte) (bArrDigest[0] & 248);
        int i10 = bArrDigest[31] & 127;
        bArrDigest[31] = (byte) i10;
        bArrDigest[31] = (byte) (i10 | 64);
        return bArrDigest;
    }

    public static byte[] l1(byte[] bArr) {
        int i10;
        byte[] bArr2 = new byte[256];
        for (int i11 = 0; i11 < 256; i11++) {
            bArr2[i11] = (byte) (1 & ((bArr[i11 >> 3] & 255) >> (i11 & 7)));
        }
        for (int i12 = 0; i12 < 256; i12++) {
            if (bArr2[i12] != 0) {
                for (int i13 = 1; i13 <= 6 && (i10 = i12 + i13) < 256; i13++) {
                    byte b10 = bArr2[i10];
                    if (b10 != 0) {
                        byte b11 = bArr2[i12];
                        int i14 = b10 << i13;
                        int i15 = b11 + i14;
                        if (i15 <= 15) {
                            bArr2[i12] = (byte) i15;
                            bArr2[i10] = 0;
                        } else {
                            int i16 = b11 - i14;
                            if (i16 >= -15) {
                                bArr2[i12] = (byte) i16;
                                while (true) {
                                    if (i10 >= 256) {
                                        break;
                                    }
                                    if (bArr2[i10] == 0) {
                                        bArr2[i10] = 1;
                                        break;
                                    }
                                    bArr2[i10] = 0;
                                    i10++;
                                }
                            }
                        }
                    }
                }
            }
        }
        return bArr2;
    }

    public static tz1 m() {
        try {
            tz1 tz1Var = iw1.f12640a;
            if (mz1.a()) {
                throw new GeneralSecurityException("Cannot use non-FIPS-compliant AeadConfigurationV1 in FIPS mode");
            }
            return iw1.f12640a;
        } catch (GeneralSecurityException e10) {
            throw new IllegalStateException(e10);
        }
    }

    public static final byte[] m0(byte[] bArr, int i10, byte[] bArr2) {
        if (bArr.length - 16 < i10) {
            throw new IllegalArgumentException("That combination of buffers, offsets and length to xor result in out-of-bond accesses.");
        }
        byte[] bArr3 = new byte[16];
        for (int i11 = 0; i11 < 16; i11++) {
            bArr3[i11] = (byte) (bArr[i11 + i10] ^ bArr2[i11]);
        }
        return bArr3;
    }

    public static int m1(byte[] bArr, int i10, jb2 jb2Var, ga2 ga2Var) throws zzicg {
        db2 db2Var = (db2) jb2Var;
        int iD = d(bArr, i10, ga2Var);
        int i11 = ga2Var.f11678a + iD;
        while (iD < i11) {
            iD = d(bArr, iD, ga2Var);
            db2Var.i(ga2Var.f11678a);
        }
        if (iD == i11) {
            return iD;
        }
        throw new zzicg("While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.");
    }

    public static File n(String str, String str2, File file) {
        if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) {
            return null;
        }
        return new File(r0(str, file), str2);
    }

    public static int n0(Set set) {
        Iterator it = set.iterator();
        int iHashCode = 0;
        while (it.hasNext()) {
            Object next = it.next();
            iHashCode += next != null ? next.hashCode() : 0;
        }
        return iHashCode;
    }

    public static ru1 n1(ArrayList arrayList) {
        return new ru1(zzguf.s(arrayList), true);
    }

    public static Object o(int i10) {
        if (i10 < 2 || i10 > 1073741824 || Integer.highestOneBit(i10) != i10) {
            throw new IllegalArgumentException(defpackage.e.n(new StringBuilder(String.valueOf(i10).length() + 41), "must be power of 2 between 2^1 and 2^30: ", i10));
        }
        return i10 <= 256 ? new byte[i10] : i10 <= 65536 ? new short[i10] : new int[i10];
    }

    public static int o0(byte[] bArr, int i10, ga2 ga2Var) {
        long j10 = bArr[i10];
        int i11 = i10 + 1;
        if (j10 >= 0) {
            ga2Var.f11679b = j10;
            return i11;
        }
        int i12 = i10 + 2;
        byte b10 = bArr[i11];
        long j11 = (j10 & 127) | (((long) (b10 & 127)) << 7);
        int i13 = 7;
        while (b10 < 0) {
            int i14 = i12 + 1;
            byte b11 = bArr[i12];
            i13 += 7;
            j11 |= ((long) (b11 & 127)) << i13;
            b10 = b11;
            i12 = i14;
        }
        ga2Var.f11679b = j11;
        return i12;
    }

    public static void o1(int i10, int i11) {
        String strB0;
        if (i10 < 0 || i10 >= i11) {
            if (i10 < 0) {
                strB0 = B0("%s (%s) must not be negative", "index", Integer.valueOf(i10));
            } else {
                if (i11 < 0) {
                    throw new IllegalArgumentException(defpackage.e.n(new StringBuilder(String.valueOf(i11).length() + 15), "negative size: ", i11));
                }
                strB0 = B0("%s (%s) must be less than size (%s)", "index", Integer.valueOf(i10), Integer.valueOf(i11));
            }
            throw new IndexOutOfBoundsException(strB0);
        }
    }

    public static Object p(Object obj, Object obj2) {
        if (obj != null) {
            return obj;
        }
        if (obj2 != null) {
            return obj2;
        }
        throw new NullPointerException("Both parameters are null");
    }

    public static long p0(long j10, long j11) {
        int iNumberOfLeadingZeros = Long.numberOfLeadingZeros(~j11) + Long.numberOfLeadingZeros(j11) + Long.numberOfLeadingZeros(~j10) + Long.numberOfLeadingZeros(j10);
        if (iNumberOfLeadingZeros > 65) {
            return j10 * j11;
        }
        long j12 = ((j10 ^ j11) >>> 63) + Long.MAX_VALUE;
        if ((iNumberOfLeadingZeros < 64) || ((j11 == Long.MIN_VALUE) & (j10 < 0))) {
            return j12;
        }
        long j13 = j10 * j11;
        return (j10 == 0 || j13 / j10 == j11) ? j13 : j12;
    }

    public static int p1(ic2 ic2Var, int i10, byte[] bArr, int i11, int i12, jb2 jb2Var, ga2 ga2Var) throws zzicg {
        cb2 cb2VarZza = ic2Var.zza();
        int iD1 = d1(cb2VarZza, ic2Var, bArr, i11, i12, ga2Var);
        ic2Var.f(cb2VarZza);
        ga2Var.f11680c = cb2VarZza;
        jb2Var.add(cb2VarZza);
        while (iD1 < i12) {
            int iD = d(bArr, iD1, ga2Var);
            if (i10 != ga2Var.f11678a) {
                break;
            }
            cb2 cb2VarZza2 = ic2Var.zza();
            int iD12 = d1(cb2VarZza2, ic2Var, bArr, iD, i12, ga2Var);
            ic2Var.f(cb2VarZza2);
            ga2Var.f11680c = cb2VarZza2;
            jb2Var.add(cb2VarZza2);
            iD1 = iD12;
        }
        return iD1;
    }

    public static Object q(Future future) {
        Object obj;
        boolean z10 = false;
        while (true) {
            try {
                obj = future.get();
                break;
            } catch (InterruptedException unused) {
                z10 = true;
            } catch (Throwable th) {
                if (z10) {
                    Thread.currentThread().interrupt();
                }
                throw th;
            }
        }
        if (z10) {
            Thread.currentThread().interrupt();
        }
        return obj;
    }

    public static av1 q0(Throwable th) {
        th.getClass();
        av1 av1Var = new av1();
        av1Var.d(th);
        return av1Var;
    }

    public static long q1(byte[] bArr, int i10) {
        return (((long) (bArr[i10 + 2] & 255)) << 16) | (bArr[i10] & 255) | (((long) (bArr[i10 + 1] & 255)) << 8);
    }

    public static String r(String str) {
        int length = str.length();
        int i10 = 0;
        while (i10 < length) {
            if (G0(str.charAt(i10))) {
                char[] charArray = str.toCharArray();
                while (i10 < length) {
                    char c6 = charArray[i10];
                    if (G0(c6)) {
                        charArray[i10] = (char) (c6 ^ ' ');
                    }
                    i10++;
                }
                return String.valueOf(charArray);
            }
            i10++;
        }
        return str;
    }

    public static File r0(String str, File file) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        File file2 = new File(file, str);
        E0(file2, false);
        return file2;
    }

    public static e.t0 r1(ArrayList arrayList) {
        return new e.t0(false, zzguf.s(arrayList));
    }

    public static BigDecimal s(String str) {
        u0(str);
        BigDecimal bigDecimal = new BigDecimal(str);
        if (Math.abs(bigDecimal.scale()) < 10000) {
            return bigDecimal;
        }
        throw new NumberFormatException("Number has unsupported scale: ".concat(str));
    }

    public static void s0(int i10, int i11, Object obj) {
        if (obj instanceof byte[]) {
            ((byte[]) obj)[i10] = (byte) i11;
        } else if (obj instanceof short[]) {
            ((short[]) obj)[i10] = (short) i11;
        } else {
            ((int[]) obj)[i10] = i11;
        }
    }

    public static void s1(int i10, int i11) {
        if (i10 < 0 || i10 > i11) {
            throw new IndexOutOfBoundsException(y1(i10, i11, "index"));
        }
    }

    public static void t(int i10, Object[] objArr) {
        for (int i11 = 0; i11 < i10; i11++) {
            b0(i11, objArr[i11]);
        }
    }

    public static void t0(File file, File file2) throws Throwable {
        if (!(!file.equals(file2))) {
            throw new IllegalArgumentException(B0("Source %s and destination %s must be different", file, file2));
        }
        if (file.renameTo(file2)) {
            return;
        }
        if (!(!file.equals(file2))) {
            throw new IllegalArgumentException(B0("Source %s and destination %s must be different", file, file2));
        }
        zzgup zzgupVarQ = zzgup.q(new zzgxj[0]);
        lt1 lt1Var = new lt1();
        try {
            FileInputStream fileInputStream = new FileInputStream(file);
            ArrayDeque arrayDeque = lt1Var.f13865a;
            arrayDeque.addFirst(fileInputStream);
            FileOutputStream fileOutputStream = new FileOutputStream(file2, zzgupVarQ.contains(zzgxj.f19810a));
            arrayDeque.addFirst(fileOutputStream);
            int i10 = jt1.f13018a;
            byte[] bArr = new byte[8192];
            while (true) {
                int i11 = fileInputStream.read(bArr);
                if (i11 == -1) {
                    break;
                } else {
                    fileOutputStream.write(bArr, 0, i11);
                }
            }
            lt1Var.close();
            if (file.delete()) {
                return;
            }
            if (!file2.delete()) {
                throw new IOException("Unable to delete ".concat(file2.toString()));
            }
            throw new IOException("Unable to delete ".concat(file.toString()));
        } catch (Throwable th) {
            try {
                lt1Var.f13866b = th;
                Object obj = wq1.f18189a;
                if (IOException.class.isInstance(th)) {
                    throw ((Throwable) IOException.class.cast(th));
                }
                if (th instanceof RuntimeException) {
                    throw ((RuntimeException) th);
                }
                if (!(th instanceof Error)) {
                    throw new RuntimeException(th);
                }
                throw ((Error) th);
            } catch (Throwable th2) {
                lt1Var.close();
                throw th2;
            }
        }
    }

    public static int t1(int i10, byte[] bArr, int i11, int i12, nc2 nc2Var, ga2 ga2Var) throws zzicg {
        if ((i10 >>> 3) == 0) {
            throw new zzicg("Protocol message contained an invalid tag (zero).");
        }
        int i13 = i10 & 7;
        if (i13 == 0) {
            int iO0 = o0(bArr, i11, ga2Var);
            nc2Var.d(i10, Long.valueOf(ga2Var.f11679b));
            return iO0;
        }
        if (i13 == 1) {
            nc2Var.d(i10, Long.valueOf(J0(i11, bArr)));
            return i11 + 8;
        }
        if (i13 == 2) {
            int iD = d(bArr, i11, ga2Var);
            int i14 = ga2Var.f11678a;
            if (i14 < 0) {
                throw new zzicg("CodedInputStream encountered an embedded string or message which claimed to have negative size.");
            }
            if (i14 > bArr.length - iD) {
                throw new zzicg("While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.");
            }
            if (i14 == 0) {
                nc2Var.d(i10, zzian.f19856a);
            } else {
                nc2Var.d(i10, zzian.w(iD, i14, bArr));
            }
            return iD + i14;
        }
        if (i13 != 3) {
            if (i13 != 5) {
                throw new zzicg("Protocol message contained an invalid tag (zero).");
            }
            nc2Var.d(i10, Integer.valueOf(z0(i11, bArr)));
            return i11 + 4;
        }
        int i15 = (i10 & (-8)) | 4;
        nc2 nc2VarA = nc2.a();
        int i16 = ga2Var.f11681d + 1;
        ga2Var.f11681d = i16;
        if (i16 >= 100) {
            throw new zzicg("Protocol message had too many levels of nesting.  May be malicious.  Use setRecursionLimit() to increase the recursion depth limit.");
        }
        int i17 = 0;
        while (true) {
            if (i11 >= i12) {
                break;
            }
            int iD2 = d(bArr, i11, ga2Var);
            i17 = ga2Var.f11678a;
            if (i17 == i15) {
                i11 = iD2;
                break;
            }
            i11 = t1(i17, bArr, iD2, i12, nc2VarA, ga2Var);
        }
        ga2Var.f11681d--;
        if (i11 > i12 || i17 != i15) {
            throw new zzicg("Failed to parse the message.");
        }
        nc2Var.d(i10, nc2VarA);
        return i11;
    }

    public static void u(long j10, String str) {
        if (j10 >= 0) {
            return;
        }
        StringBuilder sb = new StringBuilder(String.valueOf(j10).length() + 17);
        sb.append(str);
        sb.append(" (");
        sb.append(j10);
        sb.append(") must be >= 0");
        throw new IllegalArgumentException(sb.toString());
    }

    public static void u0(String str) {
        if (str.length() <= 10000) {
            return;
        }
        String strSubstring = str.substring(0, 30);
        throw new NumberFormatException(defpackage.e.p(new StringBuilder(String.valueOf(strSubstring).length() + 28), "Number string too large: ", strSubstring, "..."));
    }

    public static long u1(int i10, byte[] bArr) {
        return (((long) (bArr[i10 + 3] & 255)) << 24) | q1(bArr, i10);
    }

    public static void v(File file, byte[] bArr) throws IOException {
        zzgup zzgupVarQ = zzgup.q(new zzgxj[0]);
        bArr.getClass();
        FileOutputStream fileOutputStream = new FileOutputStream(file, zzgupVarQ.contains(zzgxj.f19810a));
        try {
            fileOutputStream.write(bArr);
            fileOutputStream.close();
        } catch (Throwable th) {
            try {
                fileOutputStream.close();
            } catch (Throwable th2) {
                th.addSuppressed(th2);
            }
            throw th;
        }
    }

    public static final void v0(StringBuilder sb, Iterator it, String str) {
        try {
            if (it.hasNext()) {
                Object next = it.next();
                Objects.requireNonNull(next);
                sb.append(next instanceof CharSequence ? (CharSequence) next : next.toString());
                while (it.hasNext()) {
                    sb.append((CharSequence) str);
                    Object next2 = it.next();
                    Objects.requireNonNull(next2);
                    sb.append(next2 instanceof CharSequence ? (CharSequence) next2 : next2.toString());
                }
            }
        } catch (IOException e10) {
            throw new AssertionError(e10);
        }
    }

    public static void v1(int i10, int i11, int i12) {
        if (i10 < 0 || i11 < i10 || i11 > i12) {
            throw new IndexOutOfBoundsException((i10 < 0 || i10 > i12) ? y1(i10, i12, "start index") : (i11 < 0 || i11 > i12) ? y1(i11, i12, "end index") : B0("end index (%s) must not be less than start index (%s)", Integer.valueOf(i11), Integer.valueOf(i10)));
        }
    }

    public static void w(Object obj, Object obj2) {
        if (obj == null) {
            throw new NullPointerException("null key in entry: null=".concat(String.valueOf(obj2)));
        }
        if (obj2 != null) {
            return;
        }
        String string = obj.toString();
        throw new NullPointerException(defpackage.e.p(new StringBuilder(string.length() + 26), "null value in entry: ", string, "=null"));
    }

    public static final void w0(ByteBuffer byteBuffer, ByteBuffer byteBuffer2, ByteBuffer byteBuffer3, int i10) {
        if (i10 < 0 || byteBuffer2.remaining() < i10 || byteBuffer3.remaining() < i10 || byteBuffer.remaining() < i10) {
            throw new IllegalArgumentException("That combination of buffers, offsets and length to xor result in out-of-bond accesses.");
        }
        for (int i11 = 0; i11 < i10; i11++) {
            byteBuffer.put((byte) (byteBuffer2.get() ^ byteBuffer3.get()));
        }
    }

    public static int w1(int i10, byte[] bArr, int i11, int i12, ga2 ga2Var) throws zzicg {
        if ((i10 >>> 3) == 0) {
            throw new zzicg("Protocol message contained an invalid tag (zero).");
        }
        int i13 = i10 & 7;
        if (i13 == 0) {
            return o0(bArr, i11, ga2Var);
        }
        if (i13 == 1) {
            return i11 + 8;
        }
        if (i13 == 2) {
            return d(bArr, i11, ga2Var) + ga2Var.f11678a;
        }
        if (i13 != 3) {
            if (i13 == 5) {
                return i11 + 4;
            }
            throw new zzicg("Protocol message contained an invalid tag (zero).");
        }
        int i14 = (i10 & (-8)) | 4;
        int i15 = 0;
        while (i11 < i12) {
            i11 = d(bArr, i11, ga2Var);
            i15 = ga2Var.f11678a;
            if (i15 == i14) {
                break;
            }
            i11 = w1(i15, bArr, i11, i12, ga2Var);
        }
        if (i11 > i12 || i15 != i14) {
            throw new zzicg("Failed to parse the message.");
        }
        return i11;
    }

    public static void x(boolean z10) {
        if (!z10) {
            throw new IllegalArgumentException();
        }
    }

    public static final void x0(byte[] bArr, String str, ch1 ch1Var) {
        if (ch1Var == null) {
            return;
        }
        StringBuilder sb = new StringBuilder("os.arch:");
        sb.append(zzgrs.OS_ARCH.a());
        sb.append(";");
        try {
            String[] strArr = (String[]) Build.class.getField("SUPPORTED_ABIS").get(null);
            if (strArr != null) {
                sb.append("supported_abis:");
                sb.append(Arrays.toString(strArr));
                sb.append(";");
            }
        } catch (IllegalAccessException | NoSuchFieldException unused) {
        }
        sb.append("CPU_ABI:");
        sb.append(Build.CPU_ABI);
        sb.append(";CPU_ABI2:");
        sb.append(Build.CPU_ABI2);
        sb.append(";");
        if (bArr != null) {
            sb.append("ELF:");
            sb.append(Arrays.toString(bArr));
            sb.append(";");
        }
        if (str != null) {
            sb.append("dbg:");
            sb.append(str);
            sb.append(";");
        }
        ch1Var.d(4007, sb.toString());
    }

    public static e.t0 x1(List list) {
        bs1 bs1Var = zzguf.f19771b;
        list.getClass();
        return new e.t0(true, zzguf.s(list));
    }

    public static void y(long[] jArr, long[] jArr2, int i10) {
        for (int i11 = 0; i11 < 10; i11++) {
            int i12 = (int) jArr[i11];
            jArr[i11] = ((-i10) & (((int) jArr2[i11]) ^ i12)) ^ i12;
        }
    }

    public static byte[] y0(byte[] bArr) {
        int length;
        int i10 = 0;
        while (true) {
            length = bArr.length;
            if (i10 >= length || bArr[i10] != 0) {
                break;
            }
            i10++;
        }
        if (i10 == length) {
            i10 = length - 1;
        }
        int i11 = (bArr[i10] & 128) == 128 ? 1 : 0;
        int i12 = length - i10;
        byte[] bArr2 = new byte[i12 + i11];
        System.arraycopy(bArr, i10, bArr2, i11, i12);
        return bArr2;
    }

    public static String y1(int i10, int i11, String str) {
        if (i10 < 0) {
            return B0("%s (%s) must not be negative", str, Integer.valueOf(i10));
        }
        if (i11 >= 0) {
            return B0("%s (%s) must not be greater than size (%s)", str, Integer.valueOf(i10), Integer.valueOf(i11));
        }
        throw new IllegalArgumentException(defpackage.e.n(new StringBuilder(String.valueOf(i11).length() + 15), "negative size: ", i11));
    }

    public static boolean z(int i10) {
        Boolean bool;
        if (i10 - 1 == 0) {
            return !mz1.a();
        }
        if (mz1.a()) {
            try {
                bool = (Boolean) Class.forName("org.conscrypt.Conscrypt").getMethod("isBoringSslFIPSBuild", new Class[0]).invoke(null, new Object[0]);
            } catch (Exception unused) {
                mz1.f14387a.logp(Level.INFO, "com.google.crypto.tink.config.internal.TinkFipsUtil", "checkConscryptIsAvailableAndUsesFipsBoringSsl", "Conscrypt is not available or does not support checking for FIPS build.");
                bool = Boolean.FALSE;
            }
            if (!bool.booleanValue()) {
                return false;
            }
        }
        return true;
    }

    public static int z0(int i10, byte[] bArr) {
        int i11 = bArr[i10] & 255;
        int i12 = bArr[i10 + 1] & 255;
        int i13 = bArr[i10 + 2] & 255;
        return ((bArr[i10 + 3] & 255) << 24) | (i12 << 8) | i11 | (i13 << 16);
    }

    public static void z1(com.google.common.util.concurrent.w wVar, zu1 zu1Var, Executor executor) {
        zu1Var.getClass();
        wVar.g(new nw0(wVar, zu1Var, 20), executor);
    }

    public abstract String b();
}
