content: package kotlinx.coroutines.selects;
  
  import androidx.concurrent.futures.AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0;
  import java.util.concurrent.CancellationException;
  import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
  import kotlin.Metadata;
  import kotlin.Result;
  import kotlin.ResultKt;
  import kotlin.Unit;
  import kotlin.coroutines.Continuation;
  import kotlin.coroutines.CoroutineContext;
  import kotlin.coroutines.intrinsics.IntrinsicsKt;
  import kotlin.coroutines.jvm.internal.CoroutineStackFrame;
  import kotlin.jvm.functions.Function0;
  import kotlin.jvm.functions.Function1;
  import kotlin.jvm.functions.Function2;
  import kotlin.jvm.internal.DefaultConstructorMarker;
  import kotlin.jvm.internal.Intrinsics;
  import kotlinx.coroutines.CancellableContinuationImplKt;
  import kotlinx.coroutines.CompletedExceptionally;
  import kotlinx.coroutines.CompletionStateKt;
  import kotlinx.coroutines.CoroutineExceptionHandlerKt;
  import kotlinx.coroutines.DebugKt;
  import kotlinx.coroutines.DelayKt;
  import kotlinx.coroutines.DisposableHandle;
  import kotlinx.coroutines.Job;
  import kotlinx.coroutines.JobCancellingNode;
  import kotlinx.coroutines.internal.AtomicDesc;
  import kotlinx.coroutines.internal.AtomicKt;
  import kotlinx.coroutines.internal.AtomicOp;
  import kotlinx.coroutines.internal.LockFreeLinkedListHead;
  import kotlinx.coroutines.internal.LockFreeLinkedListNode;
  import kotlinx.coroutines.internal.OpDescriptor;
  import kotlinx.coroutines.internal.StackTraceRecoveryKt;
  import kotlinx.coroutines.intrinsics.UndispatchedKt;
  import kotlinx.coroutines.selects.SelectBuilder;
  import mt.Log1F380D;
  
  @Metadata(d1 = {"\u0000®\u0001\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0003\n\u0002\b\u0004\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u000e\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\b\u0001\u0018\u0000*\u0006\b\u0000\u0010\u0001 \u00002\u00020Y2\b\u0012\u0004\u0012\u00028\u00000Z2\b\u0012\u0004\u0012\u00028\u00000[2\b\u0012\u0004\u0012\u00028\u00000\u00022\u00060Bj\u0002`C:\u0004TUVWB\u0015\u0012\f\u0010\u0003\u001a\b\u0012\u0004\u0012\u00028\u00000\u0002¢\u0006\u0004\b\u0004\u0010\u0005J\u0017\u0010\t\u001a\u00020\b2\u0006\u0010\u0007\u001a\u00020\u0006H\u0016¢\u0006\u0004\b\t\u0010\nJ\u000f\u0010\u000b\u001a\u00020\bH\u0002¢\u0006\u0004\b\u000b\u0010\fJ.\u0010\u0011\u001a\u00020\b2\u000e\u0010\u000f\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u000e0\r2\f\u0010\u0010\u001a\b\u0012\u0004\u0012\u00020\b0\rH\b¢\u0006\u0004\b\u0011\u0010\u0012J\u0011\u0010\u0013\u001a\u0004\u0018\u00010\u000eH\u0001¢\u0006\u0004\b\u0013\u0010\u0014J\u0017\u0010\u0017\u001a\n\u0018\u00010\u0015j\u0004\u0018\u0001`\u0016H\u0016¢\u0006\u0004\b\u0017\u0010\u0018J\u0017\u0010\u001b\u001a\u00020\b2\u0006\u0010\u001a\u001a\u00020\u0019H\u0001¢\u0006\u0004\b\u001b\u0010\u001cJ\u000f\u0010\u001d\u001a\u00020\bH\u0002¢\u0006\u0004\b\u001d\u0010\fJ8\u0010!\u001a\u00020\b2\u0006\u0010\u001f\u001a\u00020\u001e2\u001c\u0010\u0010\u001a\u0018\b\u0001\u0012\n\u0012\b\u0012\u0004\u0012\u00028\u00000\u0002\u0012\u0006\u0012\u0004\u0018\u00010\u000e0 H\u0016ø\u0001\u0000¢\u0006\u0004\b!\u0010\"J\u0019\u0010%\u001a\u0004\u0018\u00010\u000e2\u0006\u0010$\u001a\u00020#H\u0016¢\u0006\u0004\b%\u0010&J\u0017\u0010(\u001a\u00020\b2\u0006\u0010'\u001a\u00020\u0019H\u0016¢\u0006\u0004\b(\u0010\u001cJ \u0010+\u001a\u00020\b2\f\u0010*\u001a\b\u0012\u0004\u0012\u00028\u00000)H\u0016ø\u0001\u0000¢\u0006\u0004\b+\u0010,J\u000f\u0010.\u001a\u00020-H\u0016¢\u0006\u0004\b.\u0010/J\u000f\u00101\u001a\u000200H\u0016¢\u0006\u0004\b1\u00102J\u001b\u00105\u001a\u0004\u0018\u00010\u000e2\b\u00104\u001a\u0004\u0018\u000103H\u0016¢\u0006\u0004\b5\u00106J5\u00108\u001a\u00020\b*\u0002072\u001c\u0010\u0010\u001a\u0018\b\u0001\u0012\n\u0012\b\u0012\u0004\u0012\u00028\u00000\u0002\u0012\u0006\u0012\u0004\u0018\u00010\u000e0 H\u0002ø\u0001\u0000¢\u0006\u0004\b8\u00109JG\u00108\u001a\u00020\b\"\u0004\b\u0001\u0010:*\b\u0012\u0004\u0012\u00028\u00010;2\"\u0010\u0010\u001a\u001e\b\u0001\u0012\u0004\u0012\u00028\u0001\u0012\n\u0012\b\u0012\u0004\u0012\u00028\u00000\u0002\u0012\u0006\u0012\u0004\u0018\u00010\u000e0<H\u0002ø\u0001\u0000¢\u0006\u0004\b8\u0010=J[\u00108\u001a\u00020\b\"\u0004\b\u0001\u0010>\"\u0004\b\u0002\u0010:*\u000e\u0012\u0004\u0012\u00028\u0001\u0012\u0004\u0012\u00028\u00020?2\u0006\u0010@\u001a\u00028\u00012\"\u0010\u0010\u001a\u001e\b\u0001\u0012\u0004\u0012\u00028\u0002\u0012\n\u0012\b\u0012\u0004\u0012\u00028\u00000\u0002\u0012\u0006\u0012\u0004\u0018\u00010\u000e0<H\u0002ø\u0001\u0000¢\u0006\u0004\b8\u0010AR\u001c\u0010F\u001a\n\u0018\u00010Bj\u0004\u0018\u0001`C8VX\u0004¢\u0006\u0006\u001a\u0004\bD\u0010ER\u001a\u0010I\u001a\b\u0012\u0004\u0012\u00028\u00000\u00028VX\u0004¢\u0006\u0006\u001a\u0004\bG\u0010HR\u0014\u0010M\u001a\u00020J8VX\u0004¢\u0006\u0006\u001a\u0004\bK\u0010LR\u0014\u0010N\u001a\u0002008VX\u0004¢\u0006\u0006\u001a\u0004\bN\u00102R(\u0010R\u001a\u0004\u0018\u00010\u00062\b\u0010\u000f\u001a\u0004\u0018\u00010\u00068B@BX\u000e¢\u0006\f\u001a\u0004\bO\u0010P\"\u0004\bQ\u0010\nR\u001a\u0010\u0003\u001a\b\u0012\u0004\u0012\u00028\u00000\u00028\u0002X\u0004¢\u0006\u0006\n\u0004\b\u0003\u0010S\u0002\u0004\n\u0002\b\u0019¨\u0006X"}, d2 = {"Lkotlinx/coroutines/selects/SelectBuilderImpl;", "R", "Lkotlin/coroutines/Continuation;", "uCont", "<init>", "(Lkotlin/coroutines/Continuation;)V", "Lkotlinx/coroutines/DisposableHandle;", "handle", "", "disposeOnSelect", "(Lkotlinx/coroutines/DisposableHandle;)V", "doAfterSelect", "()V", "Lkotlin/Function0;", "", "value", "block", "doResume", "(Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;)V", "getResult", "()Ljava/lang/Object;", "Ljava/lang/StackTraceElement;", "Lkotlinx/coroutines/internal/StackTraceElement;", "getStackTraceElement", "()Ljava/lang/StackTraceElement;", "", "e", "handleBuilderException", "(Ljava/lang/Throwable;)V", "initCancellability", "", "timeMillis", "Lkotlin/Function1;", "onTimeout", "(JLkotlin/jvm/functions/Function1;)V", "Lkotlinx/coroutines/internal/AtomicDesc;", "desc", "performAtomicTrySelect", "(Lkotlinx/coroutines/internal/AtomicDesc;)Ljava/lang/Object;", "exception", "resumeSelectWithException", "Lkotlin/Result;", "result", "resumeWith", "(Ljava/lang/Object;)V", "", "toString", "()Ljava/lang/String;", "", "trySelect", "()Z", "Lkotlinx/coroutines/internal/LockFreeLinkedListNode$PrepareOp;", "otherOp", "trySelectOther", "(Lkotlinx/coroutines/internal/LockFreeLinkedListNode$PrepareOp;)Ljava/lang/Object;", "Lkotlinx/coroutines/selects/SelectClause0;", "invoke", "(Lkotlinx/coroutines/selects/SelectClause0;Lkotlin/jvm/functions/Function1;)V", "Q", "Lkotlinx/coroutines/selects/SelectClause1;", "Lkotlin/Function2;", "(Lkotlinx/coroutines/selects/SelectClause1;Lkotlin/jvm/functions/Function2;)V", "P", "Lkotlinx/coroutines/selects/SelectClause2;", "param", "(Lkotlinx/coroutines/selects/SelectClause2;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)V", "Lkotlin/coroutines/jvm/internal/CoroutineStackFrame;", "Lkotlinx/coroutines/internal/CoroutineStackFrame;", "getCallerFrame", "()Lkotlin/coroutines/jvm/internal/CoroutineStackFrame;", "callerFrame", "getCompletion", "()Lkotlin/coroutines/Continuation;", "completion", "Lkotlin/coroutines/CoroutineContext;", "getContext", "()Lkotlin/coroutines/CoroutineContext;", "context", "isSelected", "getParentHandle", "()Lkotlinx/coroutines/DisposableHandle;", "setParentHandle", "parentHandle", "Lkotlin/coroutines/Continuation;", "AtomicSelectOp", "DisposeNode", "PairSelectOp", "SelectOnCancelling", "kotlinx-coroutines-core", "Lkotlinx/coroutines/internal/LockFreeLinkedListHead;", "Lkotlinx/coroutines/selects/SelectBuilder;", "Lkotlinx/coroutines/selects/SelectInstance;"}, k = 1, mv = {1, 6, 0}, xi = 48)
  /* compiled from: 01AD */
  public final class SelectBuilderImpl<R> extends LockFreeLinkedListHead implements SelectBuilder<R>, SelectInstance<R>, Continuation<R>, CoroutineStackFrame {
      private static final /* synthetic */ AtomicReferenceFieldUpdater _result$FU;
      static final /* synthetic */ AtomicReferenceFieldUpdater _state$FU;
      private volatile /* synthetic */ Object _parentHandle = null;
      private volatile /* synthetic */ Object _result = SelectKt.UNDECIDED;
      volatile /* synthetic */ Object _state = SelectKt.getNOT_SELECTED();
      private final Continuation<R> uCont;
  
      @Metadata(d1 = {"\u00004\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\t\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\u0006\n\u0002\u0010\u000e\n\u0002\b\u0002\b\u0002\u0018\u00002\n\u0012\u0006\u0012\u0004\u0018\u00010\u00020\u0001B\u0019\u0012\n\u0010\u0003\u001a\u0006\u0012\u0002\b\u00030\u0004\u0012\u0006\u0010\u0005\u001a\u00020\u0006¢\u0006\u0002\u0010\u0007J\u001c\u0010\f\u001a\u00020\r2\b\u0010\u000e\u001a\u0004\u0018\u00010\u00022\b\u0010\u000f\u001a\u0004\u0018\u00010\u0002H\u0016J\u0012\u0010\u0010\u001a\u00020\r2\b\u0010\u000f\u001a\u0004\u0018\u00010\u0002H\u0002J\u0014\u0010\u0011\u001a\u0004\u0018\u00010\u00022\b\u0010\u000e\u001a\u0004\u0018\u00010\u0002H\u0016J\n\u0010\u0012\u001a\u0004\u0018\u00010\u0002H\u0002J\b\u0010\u0013\u001a\u00020\u0014H\u0016J\b\u0010\u0015\u001a\u00020\rH\u0002R\u0010\u0010\u0005\u001a\u00020\u00068\u0006X\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\u0003\u001a\u0006\u0012\u0002\b\u00030\u00048\u0006X\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\b\u001a\u00020\tX\u0004¢\u0006\b\n\u0000\u001a\u0004\b\n\u0010\u000b¨\u0006\u0016"}, d2 = {"Lkotlinx/coroutines/selects/SelectBuilderImpl$AtomicSelectOp;", "Lkotlinx/coroutines/internal/AtomicOp;", "", "impl", "Lkotlinx/coroutines/selects/SelectBuilderImpl;", "desc", "Lkotlinx/coroutines/internal/AtomicDesc;", "(Lkotlinx/coroutines/selects/SelectBuilderImpl;Lkotlinx/coroutines/internal/AtomicDesc;)V", "opSequence", "", "getOpSequence", "()J", "complete", "", "affected", "failure", "completeSelect", "prepare", "prepareSelectOp", "toString", "", "undoPrepare", "kotlinx-coroutines-core"}, k = 1, mv = {1, 6, 0}, xi = 48)
      /* compiled from: Select.kt */
      private static final class AtomicSelectOp extends AtomicOp<Object> {
          public final AtomicDesc desc;
          public final SelectBuilderImpl<?> impl;
          private final long opSequence = SelectKt.selectOpSequenceNumber.next();
  
          public AtomicSelectOp(SelectBuilderImpl<?> impl2, AtomicDesc desc2) {
              this.impl = impl2;
              this.desc = desc2;
              desc2.setAtomicOp(this);
          }
  
          private final void completeSelect(Object failure) {
              boolean z = failure == null;
              if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(SelectBuilderImpl._state$FU, this.impl, this, z ? null : SelectKt.getNOT_SELECTED()) && z) {
                  this.impl.doAfterSelect();
              }
          }
  
          private final Object prepareSelectOp() {
              SelectBuilderImpl<?> selectBuilderImpl = this.impl;
              while (true) {
                  Object obj = selectBuilderImpl._state;
                  if (obj == this) {
                      return null;
                  }
                  if (obj instanceof OpDescriptor) {
                      ((OpDescriptor) obj).perform(this.impl);
                  } else if (obj != SelectKt.getNOT_SELECTED()) {
                      return SelectKt.getALREADY_SELECTED();
                  } else {
                      if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(SelectBuilderImpl._state$FU, this.impl, SelectKt.getNOT_SELECTED(), this)) {
                          return null;
                      }
                  }
              }
          }
  
          private final void undoPrepare() {
              AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(SelectBuilderImpl._state$FU, this.impl, this, SelectKt.getNOT_SELECTED());
          }
  
          public void complete(Object affected, Object failure) {
              completeSelect(failure);
              this.desc.complete(this, failure);
          }
  
          public long getOpSequence() {
              return this.opSequence;
          }
  
          public Object prepare(Object affected) {
              Object prepareSelectOp;
              if (affected == null && (prepareSelectOp = prepareSelectOp()) != null) {
                  return prepareSelectOp;
              }
              try {
                  return this.desc.prepare(this);
              } catch (Throwable th) {
                  if (affected == null) {
                      undoPrepare();
                  }
                  throw th;
              }
          }
  
          public String toString() {
              return "AtomicSelectOp(sequence=" + getOpSequence() + ')';
          }
      }
  
      @Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0002\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004R\u0010\u0010\u0002\u001a\u00020\u00038\u0006X\u0004¢\u0006\u0002\n\u0000¨\u0006\u0005"}, d2 = {"Lkotlinx/coroutines/selects/SelectBuilderImpl$DisposeNode;", "Lkotlinx/coroutines/internal/LockFreeLinkedListNode;", "handle", "Lkotlinx/coroutines/DisposableHandle;", "(Lkotlinx/coroutines/DisposableHandle;)V", "kotlinx-coroutines-core"}, k = 1, mv = {1, 6, 0}, xi = 48)
      /* compiled from: Select.kt */
      private static final class DisposeNode extends LockFreeLinkedListNode {
          public final DisposableHandle handle;
  
          public DisposeNode(DisposableHandle handle2) {
              this.handle = handle2;
          }
      }
  
      @Metadata(d1 = {"\u0000\"\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0000\n\u0002\b\u0002\b\u0002\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\u0014\u0010\t\u001a\u0004\u0018\u00010\n2\b\u0010\u000b\u001a\u0004\u0018\u00010\nH\u0016R\u0018\u0010\u0005\u001a\u0006\u0012\u0002\b\u00030\u00068VX\u0004¢\u0006\u0006\u001a\u0004\b\u0007\u0010\bR\u0010\u0010\u0002\u001a\u00020\u00038\u0006X\u0004¢\u0006\u0002\n\u0000¨\u0006\f"}, d2 = {"Lkotlinx/coroutines/selects/SelectBuilderImpl$PairSelectOp;", "Lkotlinx/coroutines/internal/OpDescriptor;", "otherOp", "Lkotlinx/coroutines/internal/LockFreeLinkedListNode$PrepareOp;", "(Lkotlinx/coroutines/internal/LockFreeLinkedListNode$PrepareOp;)V", "atomicOp", "Lkotlinx/coroutines/internal/AtomicOp;", "getAtomicOp", "()Lkotlinx/coroutines/internal/AtomicOp;", "perform", "", "affected", "kotlinx-coroutines-core"}, k = 1, mv = {1, 6, 0}, xi = 48)
      /* compiled from: Select.kt */
      private static final class PairSelectOp extends OpDescriptor {
          public final LockFreeLinkedListNode.PrepareOp otherOp;
  
          public PairSelectOp(LockFreeLinkedListNode.PrepareOp otherOp2) {
              this.otherOp = otherOp2;
          }
  
          public AtomicOp<?> getAtomicOp() {
              return this.otherOp.getAtomicOp();
          }
  
          public Object perform(Object affected) {
              if (affected != null) {
                  SelectBuilderImpl selectBuilderImpl = (SelectBuilderImpl) affected;
                  this.otherOp.finishPrepare();
                  Object decide = this.otherOp.getAtomicOp().decide((Object) null);
                  AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(SelectBuilderImpl._state$FU, selectBuilderImpl, this, decide == null ? this.otherOp.desc : SelectKt.getNOT_SELECTED());
                  return decide;
              }
              throw new NullPointerException("null cannot be cast to non-null type kotlinx.coroutines.selects.SelectBuilderImpl<*>");
          }
      }
  
      @Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u0003\n\u0000\b\u0004\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0013\u0010\u0003\u001a\u00020\u00042\b\u0010\u0005\u001a\u0004\u0018\u00010\u0006H\u0002¨\u0006\u0007"}, d2 = {"Lkotlinx/coroutines/selects/SelectBuilderImpl$SelectOnCancelling;", "Lkotlinx/coroutines/JobCancellingNode;", "(Lkotlinx/coroutines/selects/SelectBuilderImpl;)V", "invoke", "", "cause", "", "kotlinx-coroutines-core"}, k = 1, mv = {1, 6, 0}, xi = 48)
      /* compiled from: Select.kt */
      private final class SelectOnCancelling extends JobCancellingNode {
          public SelectOnCancelling() {
          }
  
          public /* bridge */ /* synthetic */ Object invoke(Object p1) {
              invoke((Throwable) p1);
              return Unit.INSTANCE;
          }
  
          public void invoke(Throwable cause) {
              if (SelectBuilderImpl.this.trySelect()) {
                  SelectBuilderImpl.this.resumeSelectWithException(getJob().getCancellationException());
              }
          }
      }
  
      static {
          Class<SelectBuilderImpl> cls = SelectBuilderImpl.class;
          _state$FU = AtomicReferenceFieldUpdater.newUpdater(cls, Object.class, "_state");
          _result$FU = AtomicReferenceFieldUpdater.newUpdater(cls, Object.class, "_result");
      }
  
      public SelectBuilderImpl(Continuation<? super R> uCont2) {
          this.uCont = uCont2;
      }
  
      /* access modifiers changed from: private */
      public final void doAfterSelect() {
          DisposableHandle parentHandle = getParentHandle();
          if (parentHandle != null) {
              parentHandle.dispose();
          }
          LockFreeLinkedListHead lockFreeLinkedListHead = this;
          for (LockFreeLinkedListNode lockFreeLinkedListNode = (LockFreeLinkedListNode) lockFreeLinkedListHead.getNext(); !Intrinsics.areEqual((Object) lockFreeLinkedListNode, (Object) lockFreeLinkedListHead); lockFreeLinkedListNode = lockFreeLinkedListNode.getNextNode()) {
              if (lockFreeLinkedListNode instanceof DisposeNode) {
                  ((DisposeNode) lockFreeLinkedListNode).handle.dispose();
              }
          }
      }
  
      private final void doResume(Function0<? extends Object> value, Function0<Unit> block) {
          if (!DebugKt.getASSERTIONS_ENABLED() || isSelected()) {
              while (true) {
                  Object obj = this._result;
                  if (obj == SelectKt.UNDECIDED) {
                      if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(_result$FU, this, SelectKt.UNDECIDED, value.invoke())) {
                          return;
                      }
                  } else if (obj != IntrinsicsKt.getCOROUTINE_SUSPENDED()) {
                      throw new IllegalStateException("Already resumed");
                  } else if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(_result$FU, this, IntrinsicsKt.getCOROUTINE_SUSPENDED(), SelectKt.RESUMED)) {
                      block.invoke();
                      return;
                  }
              }
          } else {
              throw new AssertionError();
          }
      }
  
      private final DisposableHandle getParentHandle() {
          return (DisposableHandle) this._parentHandle;
      }
  
      private final void initCancellability() {
          Job job = (Job) getContext().get(Job.Key);
          if (job != null) {
              DisposableHandle invokeOnCompletion$default = Job.DefaultImpls.invokeOnCompletion$default(job, true, false, new SelectOnCancelling(), 2, (Object) null);
              setParentHandle(invokeOnCompletion$default);
              if (isSelected()) {
                  invokeOnCompletion$default.dispose();
              }
          }
      }
  
      private final void setParentHandle(DisposableHandle value) {
          this._parentHandle = value;
      }
  
      public void disposeOnSelect(DisposableHandle handle) {
          DisposeNode disposeNode = new DisposeNode(handle);
          if (!isSelected()) {
              addLast(disposeNode);
              if (!isSelected()) {
                  return;
              }
          }
          handle.dispose();
      }
  
      public CoroutineStackFrame getCallerFrame() {
          Continuation<R> continuation = this.uCont;
          if (continuation instanceof CoroutineStackFrame) {
              return (CoroutineStackFrame) continuation;
          }
          return null;
      }
  
      public Continuation<R> getCompletion() {
          return this;
      }
  
      public CoroutineContext getContext() {
          return this.uCont.getContext();
      }
  
      public final Object getResult() {
          if (!isSelected()) {
              initCancellability();
          }
          Object obj = this._result;
          if (obj == SelectKt.UNDECIDED) {
              if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(_result$FU, this, SelectKt.UNDECIDED, IntrinsicsKt.getCOROUTINE_SUSPENDED())) {
                  return IntrinsicsKt.getCOROUTINE_SUSPENDED();
              }
              obj = this._result;
          }
          if (obj == SelectKt.RESUMED) {
              throw new IllegalStateException("Already resumed");
          } else if (!(obj instanceof CompletedExceptionally)) {
              return obj;
          } else {
              throw ((CompletedExceptionally) obj).cause;
          }
      }
  
      public StackTraceElement getStackTraceElement() {
          return null;
      }
  
      public final void handleBuilderException(Throwable e) {
          if (trySelect()) {
              Result.Companion companion = Result.Companion;
              resumeWith(Result.m36constructorimpl(ResultKt.createFailure(e)));
          } else if (!(e instanceof CancellationException)) {
              Object result = getResult();
              if (result instanceof CompletedExceptionally) {
                  Throwable th = ((CompletedExceptionally) result).cause;
                  if (DebugKt.getRECOVER_STACK_TRACES()) {
                      th = StackTraceRecoveryKt.unwrapImpl(th);
                  }
                  if (th == (!DebugKt.getRECOVER_STACK_TRACES() ? e : StackTraceRecoveryKt.unwrapImpl(e))) {
                      return;
                  }
              }
              CoroutineExceptionHandlerKt.handleCoroutineException(getContext(), e);
          }
      }
  
      public void invoke(SelectClause0 $this$invoke, Function1<? super Continuation<? super R>, ? extends Object> block) {
          $this$invoke.registerSelectClause0(this, block);
      }
  
      public <Q> void invoke(SelectClause1<? extends Q> $this$invoke, Function2<? super Q, ? super Continuation<? super R>, ? extends Object> block) {
          $this$invoke.registerSelectClause1(this, block);
      }
  
      public <P, Q> void invoke(SelectClause2<? super P, ? extends Q> $this$invoke, P param, Function2<? super Q, ? super Continuation<? super R>, ? extends Object> block) {
          $this$invoke.registerSelectClause2(this, param, block);
      }
  
      public <P, Q> void invoke(SelectClause2<? super P, ? extends Q> $this$invoke, Function2<? super Q, ? super Continuation<? super R>, ? extends Object> block) {
          SelectBuilder.DefaultImpls.invoke(this, $this$invoke, block);
      }
  
      public boolean isSelected() {
          while (true) {
              Object obj = this._state;
              if (obj == SelectKt.getNOT_SELECTED()) {
                  return false;
              }
              if (!(obj instanceof OpDescriptor)) {
                  return true;
              }
              ((OpDescriptor) obj).perform(this);
          }
      }
  
      public void onTimeout(long timeMillis, Function1<? super Continuation<? super R>, ? extends Object> block) {
          if (timeMillis > 0) {
              disposeOnSelect(DelayKt.getDelay(getContext()).invokeOnTimeout(timeMillis, new SelectBuilderImpl$onTimeout$$inlined$Runnable$1(this, block), getContext()));
          } else if (trySelect()) {
              UndispatchedKt.startCoroutineUnintercepted(block, getCompletion());
          }
      }
  
      public Object performAtomicTrySelect(AtomicDesc desc) {
          return new AtomicSelectOp(this, desc).perform((Object) null);
      }
  
      public void resumeSelectWithException(Throwable exception) {
          if (!DebugKt.getASSERTIONS_ENABLED() || isSelected()) {
              while (true) {
                  Object obj = this._result;
                  if (obj == SelectKt.UNDECIDED) {
                      Continuation<R> continuation = this.uCont;
                      if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(_result$FU, this, SelectKt.UNDECIDED, new CompletedExceptionally((!DebugKt.getRECOVER_STACK_TRACES() || !(continuation instanceof CoroutineStackFrame)) ? exception : StackTraceRecoveryKt.recoverFromStackFrame(exception, (CoroutineStackFrame) continuation), false, 2, (DefaultConstructorMarker) null))) {
                          return;
                      }
                  } else if (obj != IntrinsicsKt.getCOROUTINE_SUSPENDED()) {
                      throw new IllegalStateException("Already resumed");
                  } else if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(_result$FU, this, IntrinsicsKt.getCOROUTINE_SUSPENDED(), SelectKt.RESUMED)) {
                      Continuation<R> intercepted = IntrinsicsKt.intercepted(this.uCont);
                      Result.Companion companion = Result.Companion;
                      intercepted.resumeWith(Result.m36constructorimpl(ResultKt.createFailure(exception)));
                      return;
                  }
              }
          } else {
              throw new AssertionError();
          }
      }
  
      public void resumeWith(Object result) {
          if (!DebugKt.getASSERTIONS_ENABLED() || isSelected()) {
              while (true) {
                  Object obj = this._result;
                  if (obj == SelectKt.UNDECIDED) {
                      if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(_result$FU, this, SelectKt.UNDECIDED, CompletionStateKt.toState$default(result, (Function1) null, 1, (Object) null))) {
                          return;
                      }
                  } else if (obj != IntrinsicsKt.getCOROUTINE_SUSPENDED()) {
                      throw new IllegalStateException("Already resumed");
                  } else if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(_result$FU, this, IntrinsicsKt.getCOROUTINE_SUSPENDED(), SelectKt.RESUMED)) {
                      if (Result.m42isFailureimpl(result)) {
                          Continuation<R> continuation = this.uCont;
                          Throwable r8 = Result.m39exceptionOrNullimpl(result);
                          Intrinsics.checkNotNull(r8);
                          Result.Companion companion = Result.Companion;
                          continuation.resumeWith(Result.m36constructorimpl(ResultKt.createFailure((!DebugKt.getRECOVER_STACK_TRACES() || !(continuation instanceof CoroutineStackFrame)) ? r8 : StackTraceRecoveryKt.recoverFromStackFrame(r8, (CoroutineStackFrame) continuation))));
                          return;
                      }
                      this.uCont.resumeWith(result);
                      return;
                  }
              }
          } else {
              throw new AssertionError();
          }
      }
  
      public String toString() {
          return "SelectInstance(state=" + this._state + ", result=" + this._result + ')';
      }
  
      public boolean trySelect() {
          Object trySelectOther = trySelectOther((LockFreeLinkedListNode.PrepareOp) null);
          if (trySelectOther == CancellableContinuationImplKt.RESUME_TOKEN) {
              return true;
          }
          if (trySelectOther == null) {
              return false;
          }
          String stringPlus = Intrinsics.stringPlus("Unexpected trySelectIdempotent result ", trySelectOther);
          Log1F380D.a((Object) stringPlus);
          throw new IllegalStateException(stringPlus.toString());
      }
  
      public Object trySelectOther(LockFreeLinkedListNode.PrepareOp otherOp) {
          while (true) {
              Object obj = this._state;
              if (obj == SelectKt.getNOT_SELECTED()) {
                  if (otherOp == null) {
                      if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(_state$FU, this, SelectKt.getNOT_SELECTED(), (Object) null)) {
                          break;
                      }
                  } else {
                      PairSelectOp pairSelectOp = new PairSelectOp(otherOp);
                      if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(_state$FU, this, SelectKt.getNOT_SELECTED(), pairSelectOp)) {
                          Object perform = pairSelectOp.perform(this);
                          if (perform != null) {
                              return perform;
                          }
                      }
                  }
              } else if (obj instanceof OpDescriptor) {
                  if (otherOp != null) {
                      AtomicOp<?> atomicOp = otherOp.getAtomicOp();
                      if ((atomicOp instanceof AtomicSelectOp) && ((AtomicSelectOp) atomicOp).impl == this) {
                          throw new IllegalStateException("Cannot use matching select clauses on the same object".toString());
                      } else if (atomicOp.isEarlierThan((OpDescriptor) obj)) {
                          return AtomicKt.RETRY_ATOMIC;
                      }
                  }
                  ((OpDescriptor) obj).perform(this);
              } else if (otherOp != null && obj == otherOp.desc) {
                  return CancellableContinuationImplKt.RESUME_TOKEN;
              } else {
                  return null;
              }
          }
          doAfterSelect();
          return CancellableContinuationImplKt.RESUME_TOKEN;
      }
  }
  