package Q1;

import kotlin.jvm.internal.o;
import m3.AbstractC2467b;
import n2.AbstractC2613d;
import p5.AbstractC2732b;
import p5.AbstractC2747q;
import p5.I;
import w4.C3137A;

/* JADX INFO: loaded from: classes.dex */
public final class k extends c {
    /* JADX WARN: Removed duplicated region for block: B:47:0x0092 A[Catch: all -> 0x009e, TRY_ENTER, TRY_LEAVE, TryCatch #7 {all -> 0x009e, blocks: (B:47:0x0092, B:55:0x00a0, B:21:0x004f), top: B:82:0x004f }] */
    /* JADX WARN: Removed duplicated region for block: B:55:0x00a0 A[Catch: all -> 0x009e, TRY_ENTER, TRY_LEAVE, TryCatch #7 {all -> 0x009e, blocks: (B:47:0x0092, B:55:0x00a0, B:21:0x004f), top: B:82:0x004f }] */
    /* JADX WARN: Removed duplicated region for block: B:72:0x0081 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:74:0x00a3 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, C4.c cVar) throws Throwable {
        j jVar;
        AbstractC2747q abstractC2747qOpenReadWrite;
        AbstractC2747q abstractC2747q;
        Throwable th;
        I i6;
        AbstractC2747q abstractC2747q2;
        C3137A c3137a;
        Throwable th2;
        AbstractC2747q abstractC2747q3;
        C3137A c3137a2;
        if (cVar instanceof j) {
            jVar = (j) cVar;
            int i7 = jVar.f5908f;
            if ((i7 & Integer.MIN_VALUE) != 0) {
                jVar.f5908f = i7 - Integer.MIN_VALUE;
            } else {
                jVar = new j(this, cVar);
            }
        }
        Object obj2 = jVar.f5906d;
        B4.a aVar = B4.a.f492a;
        int i8 = jVar.f5908f;
        C3137A c3137a3 = C3137A.f25453a;
        Throwable th3 = null;
        if (i8 == 0) {
            AbstractC2467b.l(obj2);
            if (this.f5874c.f5866a.get()) {
                throw new IllegalStateException("This scope has already been closed.");
            }
            abstractC2747qOpenReadWrite = this.f5872a.openReadWrite(this.f5873b);
            try {
                I iB = AbstractC2732b.b(AbstractC2747q.g(abstractC2747qOpenReadWrite));
                try {
                    S1.j jVar2 = S1.j.f6146a;
                    jVar.f5903a = abstractC2747qOpenReadWrite;
                    jVar.f5904b = abstractC2747qOpenReadWrite;
                    jVar.f5905c = iB;
                    jVar.f5908f = 1;
                    jVar2.b(obj, iB);
                    if (c3137a3 == aVar) {
                        return aVar;
                    }
                    abstractC2747q = abstractC2747qOpenReadWrite;
                    abstractC2747q2 = abstractC2747q;
                    i6 = iB;
                } catch (Throwable th4) {
                    abstractC2747q = abstractC2747qOpenReadWrite;
                    th = th4;
                    i6 = iB;
                    if (i6 != null) {
                    }
                    th2 = th;
                    abstractC2747q3 = abstractC2747q;
                    c3137a2 = null;
                }
            } catch (Throwable th5) {
                th = th5;
                if (abstractC2747qOpenReadWrite != null) {
                }
                th3 = th;
                c3137a = null;
            }
        } else {
            if (i8 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            i6 = jVar.f5905c;
            abstractC2747q2 = jVar.f5904b;
            abstractC2747q = jVar.f5903a;
            try {
                AbstractC2467b.l(obj2);
            } catch (Throwable th6) {
                th = th6;
                if (i6 != null) {
                    try {
                        i6.close();
                    } catch (Throwable th7) {
                        try {
                            AbstractC2613d.b(th, th7);
                        } catch (Throwable th8) {
                            th = th8;
                            abstractC2747qOpenReadWrite = abstractC2747q;
                            if (abstractC2747qOpenReadWrite != null) {
                                try {
                                    abstractC2747qOpenReadWrite.close();
                                } catch (Throwable th9) {
                                    AbstractC2613d.b(th, th9);
                                }
                            }
                            th3 = th;
                            c3137a = null;
                        }
                    }
                }
                th2 = th;
                abstractC2747q3 = abstractC2747q;
                c3137a2 = null;
            }
        }
        abstractC2747q2.flush();
        if (i6 != null) {
            try {
                i6.close();
                th2 = null;
            } catch (Throwable th10) {
                th2 = th10;
            }
            abstractC2747q3 = abstractC2747q;
            c3137a2 = c3137a3;
            if (th2 == null) {
                throw th2;
            }
            o.e(c3137a2);
            if (abstractC2747q3 != null) {
                try {
                    abstractC2747q3.close();
                } catch (Throwable th11) {
                    th3 = th11;
                }
            }
            c3137a = c3137a3;
        } else {
            th2 = null;
            abstractC2747q3 = abstractC2747q;
            c3137a2 = c3137a3;
            if (th2 == null) {
            }
        }
        if (th3 != null) {
            throw th3;
        }
        o.e(c3137a);
        return c3137a3;
    }
}
