package Y;

import W.InterfaceC0334a;
import a0.C0388b;
import a0.C0392f;
import com.google.android.gms.internal.measurement.C1;
import java.io.Closeable;
import java.io.FileNotFoundException;
import s7.l;
import x7.B;
import x7.t;
import x7.x;

/* JADX INFO: loaded from: classes.dex */
public class c implements InterfaceC0334a {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final t f7259a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final x f7260b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final a f7261c;

    public c(t tVar, x xVar) {
        P6.g.e(tVar, "fileSystem");
        P6.g.e(xVar, "path");
        this.f7259a = tVar;
        this.f7260b = xVar;
        this.f7261c = new a();
    }

    /* JADX WARN: Code restructure failed: missing block: B:54:0x00b8, code lost:
    
        if (r9 == r1) goto L55;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:36:0x007b  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX WARN: Removed duplicated region for block: B:83:0x0075 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:87:0x0086 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Type inference failed for: r2v0, types: [int] */
    /* JADX WARN: Type inference failed for: r2v1 */
    /* JADX WARN: Type inference failed for: r2v10, types: [Y.c] */
    /* JADX WARN: Type inference failed for: r2v5 */
    /* JADX WARN: Type inference failed for: r2v8 */
    /* JADX WARN: Type inference failed for: r8v0, types: [Y.c, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r8v1 */
    /* JADX WARN: Type inference failed for: r8v2, types: [java.io.Closeable] */
    /* JADX WARN: Type inference failed for: r8v24 */
    /* JADX WARN: Type inference failed for: r8v25 */
    /* JADX WARN: Type inference failed for: r8v4, types: [Y.c] */
    /* JADX WARN: Type inference failed for: r8v9, types: [java.io.Closeable] */
    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$UnknownArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static Object a(c cVar, G6.c cVar2) {
        b bVar;
        B b8;
        Throwable th;
        Throwable th2;
        if (cVar2 instanceof b) {
            bVar = (b) cVar2;
            int i = bVar.f7258x;
            if ((i & Integer.MIN_VALUE) != 0) {
                bVar.f7258x = i - Integer.MIN_VALUE;
            } else {
                bVar = new b(cVar, cVar2);
            }
        }
        Object objB = bVar.f7256v;
        F6.a aVar = F6.a.f2580q;
        ?? r22 = bVar.f7258x;
        C0392f c0392f = C0392f.f7586a;
        Throwable th3 = null;
        try {
            try {
            } catch (Throwable th4) {
                if (cVar != 0) {
                    try {
                        cVar.close();
                    } catch (Throwable th5) {
                        android.support.v4.media.session.a.a(th4, th5);
                    }
                }
                th3 = th4;
                objB = null;
            }
        } catch (FileNotFoundException unused) {
            cVar = r22;
        }
        if (r22 == 0) {
            C1.N(objB);
            if (cVar.f7261c.f7253a.get()) {
                throw new IllegalStateException("This scope has already been closed.");
            }
            try {
                B bC = l.c(cVar.f7259a.k(cVar.f7260b));
                try {
                    bVar.f7254t = cVar;
                    bVar.f7255u = bC;
                    bVar.f7258x = 1;
                    C0388b c0388bB = c0392f.b(bC);
                    if (c0388bB != aVar) {
                        b8 = bC;
                        objB = c0388bB;
                        if (b8 == null) {
                        }
                    }
                } catch (Throwable th6) {
                    r22 = cVar;
                    b8 = bC;
                    th = th6;
                    if (b8 != null) {
                        try {
                            b8.close();
                        } catch (Throwable th7) {
                            android.support.v4.media.session.a.a(th, th7);
                        }
                    }
                    th2 = th;
                    objB = null;
                }
            } catch (FileNotFoundException unused2) {
                t tVar = cVar.f7259a;
                x xVar = cVar.f7260b;
                if (!tVar.e(xVar)) {
                    return new C0388b(true);
                }
                B bC2 = l.c(cVar.f7259a.k(xVar));
                bVar.f7254t = bC2;
                bVar.f7255u = null;
                bVar.f7258x = 2;
                objB = c0392f.b(bC2);
                cVar = bC2;
            }
            return aVar;
        }
        if (r22 != 1) {
            if (r22 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            Closeable closeable = (Closeable) bVar.f7254t;
            C1.N(objB);
            cVar = closeable;
            if (cVar != 0) {
                try {
                    cVar.close();
                } catch (Throwable th8) {
                    th3 = th8;
                }
            }
            if (th3 != null) {
                throw th3;
            }
            P6.g.b(objB);
            return objB;
        }
        b8 = bVar.f7255u;
        r22 = (c) bVar.f7254t;
        try {
            C1.N(objB);
            if (b8 == null) {
                try {
                    b8.close();
                    th2 = null;
                } catch (Throwable th9) {
                    th2 = th9;
                }
            } else {
                th2 = null;
            }
        } catch (Throwable th10) {
            th = th10;
            if (b8 != null) {
            }
            th2 = th;
            objB = null;
        }
        if (th2 != null) {
            throw th2;
        }
        P6.g.b(objB);
        return objB;
    }

    @Override // W.InterfaceC0334a
    public final void close() {
        this.f7261c.f7253a.set(true);
    }
}
