package b0;

import d2.h0;
import java.util.List;
import java.util.concurrent.CancellationException;
import rm.n0;
import tp.y1;

/* loaded from: classes.dex */
public abstract class o {

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class a extends kotlin.coroutines.jvm.internal.d {

        /* renamed from: p, reason: collision with root package name */
        Object f6423p;

        /* renamed from: q, reason: collision with root package name */
        /* synthetic */ Object f6424q;

        /* renamed from: r, reason: collision with root package name */
        int f6425r;

        a(vm.d dVar) {
            super(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f6424q = obj;
            this.f6425r |= Integer.MIN_VALUE;
            return o.b(null, this);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class b extends kotlin.coroutines.jvm.internal.k implements dn.p {

        /* renamed from: q, reason: collision with root package name */
        int f6426q;

        /* renamed from: r, reason: collision with root package name */
        private /* synthetic */ Object f6427r;

        /* renamed from: s, reason: collision with root package name */
        final /* synthetic */ vm.g f6428s;

        /* renamed from: t, reason: collision with root package name */
        final /* synthetic */ dn.p f6429t;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        b(vm.g gVar, dn.p pVar, vm.d dVar) {
            super(2, dVar);
            this.f6428s = gVar;
            this.f6429t = pVar;
        }

        @Override // dn.p
        /* renamed from: b, reason: merged with bridge method [inline-methods] */
        public final Object invoke(d2.b bVar, vm.d dVar) {
            return ((b) create(bVar, dVar)).invokeSuspend(n0.f34904a);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            b bVar = new b(this.f6428s, this.f6429t, dVar);
            bVar.f6427r = obj;
            return bVar;
        }

        /* JADX WARN: Multi-variable type inference failed */
        /* JADX WARN: Removed duplicated region for block: B:11:0x0074  */
        /* JADX WARN: Removed duplicated region for block: B:14:0x0043 A[EXC_TOP_SPLITTER, SYNTHETIC] */
        /* JADX WARN: Removed duplicated region for block: B:21:0x005b A[RETURN] */
        /* JADX WARN: Removed duplicated region for block: B:28:0x0068  */
        /* JADX WARN: Removed duplicated region for block: B:31:0x0073  */
        /* JADX WARN: Type inference failed for: r1v0, types: [int] */
        /* JADX WARN: Type inference failed for: r1v1 */
        /* JADX WARN: Type inference failed for: r1v10 */
        /* JADX WARN: Type inference failed for: r1v2, types: [java.lang.Object, d2.b] */
        /* JADX WARN: Type inference failed for: r1v22 */
        /* JADX WARN: Type inference failed for: r1v3, types: [java.lang.Object, d2.b] */
        /* JADX WARN: Type inference failed for: r1v7 */
        /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:20:0x0059 -> B:8:0x0028). Please report as a decompilation issue!!! */
        /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:29:0x0070 -> B:8:0x0028). Please report as a decompilation issue!!! */
        @Override // kotlin.coroutines.jvm.internal.a
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final Object invokeSuspend(Object obj) {
            Object f10;
            Object b10;
            d2.b bVar;
            d2.b bVar2;
            f10 = wm.d.f();
            ?? r12 = this.f6426q;
            try {
            } catch (CancellationException e10) {
                e = e10;
                if (y1.l(this.f6428s)) {
                    throw e;
                }
                this.f6427r = r12;
                this.f6426q = 3;
                Object b11 = o.b(r12, this);
                bVar2 = r12;
                if (b11 == f10) {
                    return f10;
                }
                bVar = bVar2;
                if (y1.l(this.f6428s)) {
                }
            }
            if (r12 == 0) {
                rm.y.b(obj);
                bVar = (d2.b) this.f6427r;
                if (y1.l(this.f6428s)) {
                }
            } else if (r12 != 1) {
                if (r12 == 2) {
                    d2.b bVar3 = (d2.b) this.f6427r;
                    rm.y.b(obj);
                    bVar2 = bVar3;
                } else {
                    if (r12 != 3) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    d2.b bVar4 = (d2.b) this.f6427r;
                    rm.y.b(obj);
                    bVar2 = bVar4;
                }
                bVar = bVar2;
                if (y1.l(this.f6428s)) {
                    try {
                    } catch (CancellationException e11) {
                        r12 = bVar;
                        e = e11;
                        if (y1.l(this.f6428s)) {
                        }
                    }
                    dn.p pVar = this.f6429t;
                    this.f6427r = bVar;
                    this.f6426q = 1;
                    if (pVar.invoke(bVar, this) == f10) {
                        return f10;
                    }
                    r12 = bVar;
                    this.f6427r = r12;
                    this.f6426q = 2;
                    b10 = o.b(r12, this);
                    bVar2 = r12;
                    if (b10 == f10) {
                        return f10;
                    }
                    bVar = bVar2;
                    if (y1.l(this.f6428s)) {
                        return n0.f34904a;
                    }
                }
            } else {
                d2.b bVar5 = (d2.b) this.f6427r;
                rm.y.b(obj);
                r12 = bVar5;
                this.f6427r = r12;
                this.f6426q = 2;
                b10 = o.b(r12, this);
                bVar2 = r12;
                if (b10 == f10) {
                }
                bVar = bVar2;
                if (y1.l(this.f6428s)) {
                }
            }
        }
    }

    public static final boolean a(d2.b bVar) {
        List c10 = bVar.Q().c();
        int size = c10.size();
        boolean z10 = false;
        int i10 = 0;
        while (true) {
            if (i10 >= size) {
                break;
            }
            if (((d2.y) c10.get(i10)).i()) {
                z10 = true;
                break;
            }
            i10++;
        }
        return !z10;
    }

    /* JADX WARN: Code restructure failed: missing block: B:17:0x006a, code lost:
    
        if (r4 == false) goto L26;
     */
    /* JADX WARN: Code restructure failed: missing block: B:18:0x003e, code lost:
    
        r8 = d2.o.Final;
        r0.f6423p = r7;
        r0.f6425r = 1;
        r8 = r7.P(r8, r0);
     */
    /* JADX WARN: Code restructure failed: missing block: B:19:0x0048, code lost:
    
        if (r8 != r1) goto L19;
     */
    /* JADX WARN: Code restructure failed: missing block: B:20:0x004a, code lost:
    
        return r1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:23:0x006e, code lost:
    
        return rm.n0.f34904a;
     */
    /* JADX WARN: Code restructure failed: missing block: B:28:0x003c, code lost:
    
        if (a(r7) == false) goto L16;
     */
    /* JADX WARN: Removed duplicated region for block: B:27:0x0035  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0023  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:18:0x0048 -> B:10:0x004b). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Object b(d2.b bVar, vm.d dVar) {
        a aVar;
        Object f10;
        int i10;
        if (dVar instanceof a) {
            aVar = (a) dVar;
            int i11 = aVar.f6425r;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                aVar.f6425r = i11 - Integer.MIN_VALUE;
                Object obj = aVar.f6424q;
                f10 = wm.d.f();
                i10 = aVar.f6425r;
                if (i10 != 0) {
                    rm.y.b(obj);
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    bVar = (d2.b) aVar.f6423p;
                    rm.y.b(obj);
                    List c10 = ((d2.m) obj).c();
                    int size = c10.size();
                    boolean z10 = false;
                    int i12 = 0;
                    while (true) {
                        if (i12 >= size) {
                            break;
                        }
                        if (((d2.y) c10.get(i12)).i()) {
                            z10 = true;
                            break;
                        }
                        i12++;
                    }
                }
            }
        }
        aVar = new a(dVar);
        Object obj2 = aVar.f6424q;
        f10 = wm.d.f();
        i10 = aVar.f6425r;
        if (i10 != 0) {
        }
    }

    public static final Object c(h0 h0Var, dn.p pVar, vm.d dVar) {
        Object f10;
        Object i12 = h0Var.i1(new b(dVar.getContext(), pVar, null), dVar);
        f10 = wm.d.f();
        return i12 == f10 ? i12 : n0.f34904a;
    }
}
