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

import java.io.IOException;

/* JADX INFO: loaded from: classes2.dex */
public final /* synthetic */ class j0 implements t6.f, d0 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final /* synthetic */ j0 f19939a = new j0();

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

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final j0 f19943e = new j0();

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final j0 f19944f = new j0();

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:50:0x0077 A[ORIG_RETURN, RETURN] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static boolean a(int i10, byte[] bArr) {
        int i11 = 0;
        while (i11 < i10 && bArr[i11] >= 0) {
            i11++;
        }
        if (i11 < i10) {
            while (i11 < i10) {
                int i12 = i11 + 1;
                int iA = bArr[i11];
                if (iA >= 0) {
                    i11 = i12;
                } else if (iA < -32) {
                    if (i12 < i10) {
                        if (iA < -62) {
                            return false;
                        }
                        i11 += 2;
                        if (bArr[i12] > -65) {
                            return false;
                        }
                    } else if (iA != 0) {
                        return false;
                    }
                } else if (iA < -16) {
                    if (i12 >= i10 - 1) {
                        iA = o1.a(bArr, i12, i10);
                        if (iA != 0) {
                        }
                    } else {
                        int i13 = i11 + 2;
                        char c6 = bArr[i12];
                        if (c6 > -65) {
                            return false;
                        }
                        if (iA == -32 && c6 < -96) {
                            return false;
                        }
                        if (iA == -19 && c6 >= -96) {
                            return false;
                        }
                        i11 += 3;
                        if (bArr[i13] > -65) {
                            return false;
                        }
                    }
                } else if (i12 >= i10 - 2) {
                    iA = o1.a(bArr, i12, i10);
                    if (iA != 0) {
                    }
                } else {
                    int i14 = i11 + 2;
                    int i15 = bArr[i12];
                    if (i15 > -65) {
                        return false;
                    }
                    if ((((i15 + 112) + (iA << 28)) >> 30) != 0) {
                        return false;
                    }
                    int i16 = i11 + 3;
                    if (bArr[i14] > -65) {
                        return false;
                    }
                    i11 += 4;
                    if (bArr[i16] > -65) {
                        return false;
                    }
                }
            }
        }
        return true;
    }

    @Override // t6.f
    public Object apply(Object obj) {
        c cVar = (c) obj;
        try {
            int iE = cVar.e();
            byte[] bArr = new byte[iE];
            t tVar = new t(bArr, iE);
            c1 c1VarA = a1.f19902c.a(c.class);
            u uVar = tVar.f19979a;
            if (uVar == null) {
                uVar = new u(tVar);
            }
            c1VarA.e(cVar, uVar);
            if (iE - tVar.f19982d == 0) {
                return bArr;
            }
            throw new IllegalStateException("Did not write as much data as expected.");
        } catch (IOException e10) {
            throw new RuntimeException(com.google.android.gms.measurement.internal.u1.k("Serializing ", cVar.getClass().getName(), " to a byte array threw an IOException (should never happen)."), e10);
        }
    }
}
