package Y;

import A6.n;
import a0.C0392f;
import com.google.android.gms.internal.measurement.C1;
import java.io.RandomAccessFile;
import s7.l;
import x7.A;
import x7.s;
import x7.t;
import x7.x;

/* JADX INFO: loaded from: classes.dex */
public final class k extends c {
    /* JADX WARN: Removed duplicated region for block: B:47:0x00b0 A[Catch: all -> 0x00bc, TRY_ENTER, TRY_LEAVE, TryCatch #7 {all -> 0x00bc, blocks: (B:47:0x00b0, B:55:0x00be, B:21:0x006d), top: B:82:0x006d }] */
    /* JADX WARN: Removed duplicated region for block: B:55:0x00be A[Catch: all -> 0x00bc, TRY_ENTER, TRY_LEAVE, TryCatch #7 {all -> 0x00bc, blocks: (B:47:0x00b0, B:55:0x00be, B:21:0x006d), top: B:82:0x006d }] */
    /* JADX WARN: Removed duplicated region for block: B:72:0x009f A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:74:0x00c1 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object b(Object obj, G6.c cVar) throws Throwable {
        j jVar;
        s sVar;
        s sVar2;
        Throwable th;
        A a3;
        s sVar3;
        n nVar;
        Throwable th2;
        s sVar4;
        n nVar2;
        if (cVar instanceof j) {
            jVar = (j) cVar;
            int i = jVar.f7295y;
            if ((i & Integer.MIN_VALUE) != 0) {
                jVar.f7295y = i - Integer.MIN_VALUE;
            } else {
                jVar = new j(this, cVar);
            }
        }
        Object obj2 = jVar.f7293w;
        F6.a aVar = F6.a.f2580q;
        int i5 = jVar.f7295y;
        n nVar3 = n.f457a;
        Throwable th3 = null;
        if (i5 == 0) {
            C1.N(obj2);
            if (this.f7261c.f7253a.get()) {
                throw new IllegalStateException("This scope has already been closed.");
            }
            t tVar = this.f7259a;
            tVar.getClass();
            x xVar = this.f7260b;
            P6.g.e(xVar, "file");
            tVar.getClass();
            P6.g.e(xVar, "file");
            sVar = new s(true, new RandomAccessFile(xVar.f(), "rw"));
            try {
                A aB = l.b(s.a(sVar));
                try {
                    C0392f c0392f = C0392f.f7586a;
                    jVar.f7290t = sVar;
                    jVar.f7291u = sVar;
                    jVar.f7292v = aB;
                    jVar.f7295y = 1;
                    c0392f.c(obj, aB);
                    if (nVar3 == aVar) {
                        return aVar;
                    }
                    sVar2 = sVar;
                    sVar3 = sVar2;
                    a3 = aB;
                } catch (Throwable th4) {
                    sVar2 = sVar;
                    th = th4;
                    a3 = aB;
                    if (a3 != null) {
                    }
                    th2 = th;
                    sVar4 = sVar2;
                    nVar2 = null;
                }
            } catch (Throwable th5) {
                th = th5;
                if (sVar != null) {
                }
                th3 = th;
                nVar = null;
            }
        } else {
            if (i5 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            a3 = jVar.f7292v;
            sVar3 = jVar.f7291u;
            sVar2 = jVar.f7290t;
            try {
                C1.N(obj2);
            } catch (Throwable th6) {
                th = th6;
                if (a3 != null) {
                    try {
                        a3.close();
                    } catch (Throwable th7) {
                        try {
                            android.support.v4.media.session.a.a(th, th7);
                        } catch (Throwable th8) {
                            th = th8;
                            sVar = sVar2;
                            if (sVar != null) {
                                try {
                                    sVar.close();
                                } catch (Throwable th9) {
                                    android.support.v4.media.session.a.a(th, th9);
                                }
                            }
                            th3 = th;
                            nVar = null;
                        }
                    }
                }
                th2 = th;
                sVar4 = sVar2;
                nVar2 = null;
            }
        }
        sVar3.flush();
        if (a3 != null) {
            try {
                a3.close();
                th2 = null;
            } catch (Throwable th10) {
                th2 = th10;
            }
            sVar4 = sVar2;
            nVar2 = nVar3;
            if (th2 == null) {
                throw th2;
            }
            P6.g.b(nVar2);
            if (sVar4 != null) {
                try {
                    sVar4.close();
                } catch (Throwable th11) {
                    th3 = th11;
                }
            }
            nVar = nVar3;
        } else {
            th2 = null;
            sVar4 = sVar2;
            nVar2 = nVar3;
            if (th2 == null) {
            }
        }
        if (th3 != null) {
            throw th3;
        }
        P6.g.b(nVar);
        return nVar3;
    }
}
