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

import com.google.android.gms.internal.measurement.zzjt;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;

/* loaded from: classes3.dex */
final class zzli<T> implements zzlu<T> {
    private final zzlc zza;
    private final zzmk<?, ?> zzb;
    private final boolean zzc;
    private final zzji<?> zzd;

    private zzli(zzmk<?, ?> zzmkVar, zzji<?> zzjiVar, zzlc zzlcVar) {
        this.zzb = zzmkVar;
        this.zzc = zzjiVar.zza(zzlcVar);
        this.zzd = zzjiVar;
        this.zza = zzlcVar;
    }

    @Override // com.google.android.gms.internal.measurement.zzlu
    public final int zza(T t10) {
        zzmk<?, ?> zzmkVar = this.zzb;
        int zzb = zzmkVar.zzb(zzmkVar.zzd(t10)) + 0;
        return this.zzc ? zzb + this.zzd.zza(t10).zza() : zzb;
    }

    @Override // com.google.android.gms.internal.measurement.zzlu
    public final int zzb(T t10) {
        int hashCode = this.zzb.zzd(t10).hashCode();
        return this.zzc ? (hashCode * 53) + this.zzd.zza(t10).hashCode() : hashCode;
    }

    @Override // com.google.android.gms.internal.measurement.zzlu
    public final void zzd(T t10) {
        this.zzb.zzf(t10);
        this.zzd.zzc(t10);
    }

    @Override // com.google.android.gms.internal.measurement.zzlu
    public final boolean zze(T t10) {
        return this.zzd.zza(t10).zzg();
    }

    @Override // com.google.android.gms.internal.measurement.zzlu
    public final boolean zzb(T t10, T t11) {
        if (!this.zzb.zzd(t10).equals(this.zzb.zzd(t11))) {
            return false;
        }
        if (this.zzc) {
            return this.zzd.zza(t10).equals(this.zzd.zza(t11));
        }
        return true;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static <T> zzli<T> zza(zzmk<?, ?> zzmkVar, zzji<?> zzjiVar, zzlc zzlcVar) {
        return new zzli<>(zzmkVar, zzjiVar, zzlcVar);
    }

    @Override // com.google.android.gms.internal.measurement.zzlu
    public final T zza() {
        zzlc zzlcVar = this.zza;
        if (zzlcVar instanceof zzjt) {
            return (T) ((zzjt) zzlcVar).zzce();
        }
        return (T) zzlcVar.zzci().zzaj();
    }

    @Override // com.google.android.gms.internal.measurement.zzlu
    public final void zza(T t10, T t11) {
        zzlw.zza(this.zzb, t10, t11);
        if (this.zzc) {
            zzlw.zza(this.zzd, t10, t11);
        }
    }

    @Override // com.google.android.gms.internal.measurement.zzlu
    public final void zza(T t10, zzlr zzlrVar, zzjg zzjgVar) throws IOException {
        boolean z10;
        zzmk<?, ?> zzmkVar = this.zzb;
        zzji<?> zzjiVar = this.zzd;
        Object zzc = zzmkVar.zzc(t10);
        zzjm<?> zzb = zzjiVar.zzb(t10);
        do {
            try {
                if (zzlrVar.zzc() == Integer.MAX_VALUE) {
                    return;
                }
                int zzd = zzlrVar.zzd();
                int i10 = 0;
                if (zzd == 11) {
                    Object obj = null;
                    zzik zzikVar = null;
                    while (zzlrVar.zzc() != Integer.MAX_VALUE) {
                        int zzd2 = zzlrVar.zzd();
                        if (zzd2 == 16) {
                            i10 = zzlrVar.zzj();
                            obj = zzjiVar.zza(zzjgVar, this.zza, i10);
                        } else if (zzd2 == 26) {
                            if (obj != null) {
                                zzjiVar.zza(zzlrVar, obj, zzjgVar, zzb);
                            } else {
                                zzikVar = zzlrVar.zzp();
                            }
                        } else if (!zzlrVar.zzt()) {
                            break;
                        }
                    }
                    if (zzlrVar.zzd() != 12) {
                        throw zzkb.zzb();
                    }
                    if (zzikVar != null) {
                        if (obj != null) {
                            zzjiVar.zza(zzikVar, obj, zzjgVar, zzb);
                        } else {
                            zzmkVar.zza((zzmk<?, ?>) zzc, i10, zzikVar);
                        }
                    }
                } else if ((zzd & 7) == 2) {
                    Object zza = zzjiVar.zza(zzjgVar, this.zza, zzd >>> 3);
                    if (zza != null) {
                        zzjiVar.zza(zzlrVar, zza, zzjgVar, zzb);
                    } else {
                        z10 = zzmkVar.zza((zzmk<?, ?>) zzc, zzlrVar, 0);
                    }
                } else {
                    z10 = zzlrVar.zzt();
                }
                z10 = true;
            } finally {
                zzmkVar.zzb((Object) t10, (T) zzc);
            }
        } while (z10);
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:22:0x0094  */
    /* JADX WARN: Removed duplicated region for block: B:24:0x0099 A[EDGE_INSN: B:24:0x0099->B:25:0x0099 BREAK  A[LOOP:1: B:10:0x0053->B:18:0x0053], SYNTHETIC] */
    @Override // com.google.android.gms.internal.measurement.zzlu
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void zza(T t10, byte[] bArr, int i10, int i11, zzij zzijVar) throws IOException {
        zzjt zzjtVar = (zzjt) t10;
        zzmj zzmjVar = zzjtVar.zzb;
        if (zzmjVar == zzmj.zzc()) {
            zzmjVar = zzmj.zzd();
            zzjtVar.zzb = zzmjVar;
        }
        ((zzjt.zzd) t10).zza();
        zzjt.zzf zzfVar = null;
        while (i10 < i11) {
            int zzc = zzig.zzc(bArr, i10, zzijVar);
            int i12 = zzijVar.zza;
            if (i12 == 11) {
                int i13 = 0;
                zzik zzikVar = null;
                while (zzc < i11) {
                    zzc = zzig.zzc(bArr, zzc, zzijVar);
                    int i14 = zzijVar.zza;
                    int i15 = i14 >>> 3;
                    int i16 = i14 & 7;
                    if (i15 != 2) {
                        if (i15 == 3) {
                            if (zzfVar != null) {
                                zzlq.zza();
                                throw new NoSuchMethodError();
                            }
                            if (i16 == 2) {
                                zzc = zzig.zza(bArr, zzc, zzijVar);
                                zzikVar = (zzik) zzijVar.zzc;
                            }
                        }
                        if (i14 != 12) {
                            break;
                        } else {
                            zzc = zzig.zza(i14, bArr, zzc, i11, zzijVar);
                        }
                    } else if (i16 == 0) {
                        zzc = zzig.zzc(bArr, zzc, zzijVar);
                        i13 = zzijVar.zza;
                        zzfVar = (zzjt.zzf) this.zzd.zza(zzijVar.zzd, this.zza, i13);
                    } else if (i14 != 12) {
                    }
                }
                if (zzikVar != null) {
                    zzmjVar.zza((i13 << 3) | 2, zzikVar);
                }
                i10 = zzc;
            } else if ((i12 & 7) == 2) {
                zzfVar = (zzjt.zzf) this.zzd.zza(zzijVar.zzd, this.zza, i12 >>> 3);
                if (zzfVar == null) {
                    i10 = zzig.zza(i12, bArr, zzc, i11, zzmjVar, zzijVar);
                } else {
                    zzlq.zza();
                    throw new NoSuchMethodError();
                }
            } else {
                i10 = zzig.zza(i12, bArr, zzc, i11, zzijVar);
            }
        }
        if (i10 != i11) {
            throw zzkb.zzg();
        }
    }

    @Override // com.google.android.gms.internal.measurement.zzlu
    public final void zza(T t10, zznb zznbVar) throws IOException {
        Iterator<Map.Entry<?, Object>> zzd = this.zzd.zza(t10).zzd();
        while (zzd.hasNext()) {
            Map.Entry<?, Object> next = zzd.next();
            zzjo zzjoVar = (zzjo) next.getKey();
            if (zzjoVar.zzc() == zzmz.MESSAGE && !zzjoVar.zze() && !zzjoVar.zzd()) {
                if (next instanceof zzkf) {
                    zznbVar.zza(zzjoVar.zza(), (Object) ((zzkf) next).zza().zzb());
                } else {
                    zznbVar.zza(zzjoVar.zza(), next.getValue());
                }
            } else {
                throw new IllegalStateException("Found invalid MessageSet item.");
            }
        }
        zzmk<?, ?> zzmkVar = this.zzb;
        zzmkVar.zza((zzmk<?, ?>) zzmkVar.zzd(t10), zznbVar);
    }
}
