package defpackage;

import java.util.concurrent.atomic.AtomicInteger;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;

/* JADX INFO: renamed from: xs8, reason: from Kotlin metadata and case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
@Metadata(d1 = {"\u0000\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0003\u001a\u00020\u0002\"\u0004\b\u0000\u0010\u0000*\u00020\u0001H\u008a@¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"T", "Lak1;", "Le6a;", "<anonymous>", "(Lak1;)V"}, k = 3, mv = {1, 5, 1})
@DebugMetadata(c = "androidx.datastore.core.SimpleActor$offer$2", f = "SimpleActor.kt", i = {}, l = {122, 122}, m = "invokeSuspend", n = {}, s = {})
final class C0745xs8 extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public Object a;
    public int b;
    public final /* synthetic */ ys8 c;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C0745xs8(ys8 ys8Var, Continuation continuation) {
        super(2, continuation);
        this.c = ys8Var;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Object obj, Continuation continuation) {
        return new C0745xs8(this.c, continuation);
    }

    @Override // defpackage.gr3
    public final Object invoke(Object obj, Object obj2) {
        return ((C0745xs8) create((ak1) obj, (Continuation) obj2)).invokeSuspend(e6a.a);
    }

    /* JADX WARN: Code restructure failed: missing block: B:16:0x004e, code lost:
    
        if (r3.invoke(r8, r7) != r2) goto L18;
     */
    /* JADX WARN: Removed duplicated region for block: B:15:0x0045 A[PHI: r3 r8
      0x0045: PHI (r3v1 gr3) = (r3v2 gr3), (r3v4 gr3) binds: [B:13:0x0042, B:9:0x001c] A[DONT_GENERATE, DONT_INLINE]
      0x0045: PHI (r8v3 java.lang.Object) = (r8v8 java.lang.Object), (r8v0 java.lang.Object) binds: [B:13:0x0042, B:9:0x001c] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:16:0x004e -> B:18:0x0051). 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 {
        gr3 gr3Var;
        ys8 ys8Var = this.c;
        AtomicInteger atomicInteger = ys8Var.d;
        ck1 ck1Var = ck1.a;
        int i = this.b;
        if (i == 0) {
            s38.b(obj);
            if (atomicInteger.get() <= 0) {
                throw new IllegalStateException("Check failed.");
            }
            kx4.c(ys8Var.a.getJ());
            gr3Var = ys8Var.b;
            zg0 zg0Var = ys8Var.c;
            this.a = gr3Var;
            this.b = 1;
            obj = zg0Var.ah(this);
            if (obj != ck1Var) {
            }
            return ck1Var;
        }
        if (i != 1) {
            if (i != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(obj);
            if (atomicInteger.decrementAndGet() == 0) {
                return e6a.a;
            }
            kx4.c(ys8Var.a.getJ());
            gr3Var = ys8Var.b;
            zg0 zg0Var2 = ys8Var.c;
            this.a = gr3Var;
            this.b = 1;
            obj = zg0Var2.ah(this);
            if (obj != ck1Var) {
                this.a = null;
                this.b = 2;
            }
            return ck1Var;
        }
        gr3Var = (gr3) this.a;
        s38.b(obj);
        this.a = null;
        this.b = 2;
    }
}
