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

import defpackage.qy3;

/* JADX INFO: loaded from: classes2.dex */
public final class zzfz<V> {
    private static final Object zza = new Object();
    private final String zzb;
    private final zzfx<V> zzc;
    private final V zzd;
    private final Object zze;

    @qy3
    private volatile V zzf;

    @qy3
    private volatile V zzg;

    /* JADX WARN: Removed duplicated region for block: B:45:0x005e  */
    /* JADX WARN: Removed duplicated region for block: B:68:0x0061 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final V zza(V v) {
        zzfx<V> zzfxVar;
        synchronized (this.zze) {
        }
        if (v != null) {
            return v;
        }
        if (zzga.zza == null) {
            return this.zzd;
        }
        synchronized (zza) {
            try {
                if (zzab.zza()) {
                    return this.zzg == null ? this.zzd : this.zzg;
                }
                try {
                } catch (SecurityException unused) {
                }
                for (zzfz zzfzVar : zzbh.zzdm) {
                    if (zzab.zza()) {
                        throw new IllegalStateException("Refreshing flag cache must be done on a worker thread.");
                    }
                    V vZza = null;
                    try {
                        zzfx<V> zzfxVar2 = zzfzVar.zzc;
                        if (zzfxVar2 != null) {
                            vZza = zzfxVar2.zza();
                        }
                    } catch (IllegalStateException unused2) {
                    }
                    synchronized (zza) {
                        zzfzVar.zzg = vZza;
                    }
                    zzfxVar = this.zzc;
                    if (zzfxVar != null) {
                        return this.zzd;
                    }
                    try {
                        return zzfxVar.zza();
                    } catch (IllegalStateException unused3) {
                        return this.zzd;
                    } catch (SecurityException unused4) {
                        return this.zzd;
                    }
                }
                zzfxVar = this.zzc;
                if (zzfxVar != null) {
                }
            } finally {
            }
        }
    }

    private zzfz(String str, V v, V v2, zzfx<V> zzfxVar) {
        this.zze = new Object();
        this.zzf = null;
        this.zzg = null;
        this.zzb = str;
        this.zzd = v;
        this.zzc = zzfxVar;
    }

    public final String zza() {
        return this.zzb;
    }
}
