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

import A0.a;

/* JADX INFO: loaded from: classes3.dex */
final class zzanb {
    private static final zzanc zza;

    static {
        if (zzana.zzc()) {
            zzana.zzd();
        }
        zza = new zzanf();
    }

    public static /* synthetic */ int zza(byte[] bArr, int i6, int i7) {
        byte b5 = bArr[i6 - 1];
        int i8 = i7 - i6;
        if (i8 == 0) {
            if (b5 > -12) {
                return -1;
            }
            return b5;
        }
        if (i8 == 1) {
            byte b6 = bArr[i6];
            if (b5 > -12 || b6 > -65) {
                return -1;
            }
            return (b6 << 8) ^ b5;
        }
        if (i8 != 2) {
            throw new AssertionError();
        }
        byte b7 = bArr[i6];
        byte b8 = bArr[i6 + 1];
        if (b5 > -12 || b7 > -65 || b8 > -65) {
            return -1;
        }
        return (b8 << 16) ^ ((b7 << 8) ^ b5);
    }

    public static String zzb(byte[] bArr, int i6, int i7) {
        return zza.zza(bArr, i6, i7);
    }

    public static boolean zzc(byte[] bArr, int i6, int i7) {
        return zza.zza(0, bArr, i6, i7) == 0;
    }

    public static int zza(String str, byte[] bArr, int i6, int i7) {
        return zza.zza(str, bArr, i6, i7);
    }

    public static int zza(String str) {
        int length = str.length();
        int i6 = 0;
        int i7 = 0;
        while (i7 < length && str.charAt(i7) < 128) {
            i7++;
        }
        int i8 = length;
        while (true) {
            if (i7 >= length) {
                break;
            }
            char cCharAt = str.charAt(i7);
            if (cCharAt < 2048) {
                i8 += (127 - cCharAt) >>> 31;
                i7++;
            } else {
                int length2 = str.length();
                while (i7 < length2) {
                    char cCharAt2 = str.charAt(i7);
                    if (cCharAt2 < 2048) {
                        i6 += (127 - cCharAt2) >>> 31;
                    } else {
                        i6 += 2;
                        if (55296 <= cCharAt2 && cCharAt2 <= 57343) {
                            if (Character.codePointAt(str, i7) < 65536) {
                                throw new zzane(i7, length2);
                            }
                            i7++;
                        }
                    }
                    i7++;
                }
                i8 += i6;
            }
        }
        if (i8 >= length) {
            return i8;
        }
        throw new IllegalArgumentException(a.m("UTF-8 length does not fit in int: ", ((long) i8) + 4294967296L));
    }
}
