package androidx.datastore.core;

import java.util.concurrent.atomic.AtomicInteger;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.CoroutineSingletons;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import kotlinx.coroutines.g1;
import kotlinx.coroutines.y0;

/* JADX INFO: loaded from: classes.dex */
@Metadata(d1 = {"\u0000\f\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\u0010\u0003\u001a\u00020\u0002\"\u0004\b\u0000\u0010\u0000*\u00020\u0001H\u008a@"}, d2 = {"T", "Lkotlinx/coroutines/x;", "Lkd/e;", "<anonymous>"}, k = 3, mv = {1, 8, 0})
@DebugMetadata(c = "androidx.datastore.core.SimpleActor$offer$2", f = "SimpleActor.kt", i = {}, l = {121, 121}, m = "invokeSuspend", n = {}, s = {})
final class SimpleActor$offer$2 extends SuspendLambda implements Function2 {
    Object L$0;
    int label;
    final /* synthetic */ a0 this$0;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public SimpleActor$offer$2(a0 a0Var, Continuation continuation) {
        super(2, continuation);
        this.this$0 = a0Var;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Object obj, Continuation continuation) {
        return new SimpleActor$offer$2(this.this$0, continuation);
    }

    @Override // kotlin.jvm.functions.Function2
    public final Object invoke(Object obj, Object obj2) {
        return ((SimpleActor$offer$2) create((kotlinx.coroutines.x) obj, (Continuation) obj2)).invokeSuspend(kd.e.f29109a);
    }

    /* JADX WARN: Removed duplicated region for block: B:15:0x0049  */
    /* JADX WARN: Removed duplicated region for block: B:22:0x0067 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:23:0x0068  */
    /* JADX WARN: Removed duplicated region for block: B:26:0x0077 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:27:0x0078  */
    /* JADX WARN: Removed duplicated region for block: B:30:0x0088  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:27:0x0078 -> B:28:0x007a). Please report as a decompilation issue!!! */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws Throwable {
        SimpleActor$offer$2 simpleActor$offer$2;
        Function2 function2;
        CoroutineSingletons coroutineSingletons;
        SimpleActor$offer$2 simpleActor$offer$22;
        y0 y0Var;
        Object objZ;
        CoroutineSingletons coroutineSingletons2 = CoroutineSingletons.f29226a;
        int i10 = this.label;
        if (i10 == 0) {
            kotlin.a.d(obj);
            if (((AtomicInteger) this.this$0.f1908d.f35758b).get() <= 0) {
                throw new IllegalStateException("Check failed.".toString());
            }
            simpleActor$offer$2 = this;
            y0Var = (y0) simpleActor$offer$2.this$0.f1905a.getCoroutineContext().m(kotlinx.coroutines.u.f29565b);
            if (y0Var == null) {
            }
            a0 a0Var = simpleActor$offer$2.this$0;
            function2 = a0Var.f1906b;
            simpleActor$offer$2.L$0 = function2;
            simpleActor$offer$2.label = 1;
            objZ = a0Var.f1907c.z(simpleActor$offer$2);
            if (objZ == coroutineSingletons2) {
            }
        } else if (i10 == 1) {
            Function2 function22 = (Function2) this.L$0;
            kotlin.a.d(obj);
            function2 = function22;
            coroutineSingletons = coroutineSingletons2;
            simpleActor$offer$22 = this;
            simpleActor$offer$22.L$0 = null;
            simpleActor$offer$22.label = 2;
            if (function2.invoke(obj, simpleActor$offer$22) != coroutineSingletons) {
            }
        } else {
            if (i10 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            kotlin.a.d(obj);
            simpleActor$offer$2 = this;
            if (((AtomicInteger) simpleActor$offer$2.this$0.f1908d.f35758b).decrementAndGet() == 0) {
                return kd.e.f29109a;
            }
            y0Var = (y0) simpleActor$offer$2.this$0.f1905a.getCoroutineContext().m(kotlinx.coroutines.u.f29565b);
            if (y0Var == null && !y0Var.isActive()) {
                throw ((g1) y0Var).z();
            }
            a0 a0Var2 = simpleActor$offer$2.this$0;
            function2 = a0Var2.f1906b;
            simpleActor$offer$2.L$0 = function2;
            simpleActor$offer$2.label = 1;
            objZ = a0Var2.f1907c.z(simpleActor$offer$2);
            if (objZ == coroutineSingletons2) {
                return coroutineSingletons2;
            }
            CoroutineSingletons coroutineSingletons3 = coroutineSingletons2;
            simpleActor$offer$22 = simpleActor$offer$2;
            obj = objZ;
            coroutineSingletons = coroutineSingletons3;
            simpleActor$offer$22.L$0 = null;
            simpleActor$offer$22.label = 2;
            if (function2.invoke(obj, simpleActor$offer$22) != coroutineSingletons) {
                return coroutineSingletons;
            }
            simpleActor$offer$2 = simpleActor$offer$22;
            coroutineSingletons2 = coroutineSingletons;
            if (((AtomicInteger) simpleActor$offer$2.this$0.f1908d.f35758b).decrementAndGet() == 0) {
            }
            y0Var = (y0) simpleActor$offer$2.this$0.f1905a.getCoroutineContext().m(kotlinx.coroutines.u.f29565b);
            if (y0Var == null) {
            }
            a0 a0Var22 = simpleActor$offer$2.this$0;
            function2 = a0Var22.f1906b;
            simpleActor$offer$2.L$0 = function2;
            simpleActor$offer$2.label = 1;
            objZ = a0Var22.f1907c.z(simpleActor$offer$2);
            if (objZ == coroutineSingletons2) {
            }
        }
    }
}
