package o; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; /* loaded from: classes6.dex */ public final class geB { public static final geA e(InterfaceC14907gbi interfaceC14907gbi) { geA gea; geA gea2; if (!(interfaceC14907gbi instanceof ggM)) { return new geA<>(interfaceC14907gbi, 1); } ggM ggm = (ggM) interfaceC14907gbi; loop0: while (true) { Object obj = ggm._reusableCancellableContinuation; gea = null; if (obj == null) { ggm._reusableCancellableContinuation = C15069ggJ.b; gea2 = null; break; } if (obj instanceof geA) { AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = ggM.c; C15119ghh c15119ghh = C15069ggJ.b; while (!atomicReferenceFieldUpdater.compareAndSet(ggm, obj, c15119ghh)) { if (atomicReferenceFieldUpdater.get(ggm) != obj) { break; } } gea2 = (geA) obj; break loop0; } if (obj != C15069ggJ.b && !(obj instanceof Throwable)) { throw new IllegalStateException("Inconsistent state ".concat(String.valueOf(obj)).toString()); } } if (gea2 != null) { C15045gfe.b(); C15045gfe.b(); Object obj2 = gea2._state; C15045gfe.b(); if (!(obj2 instanceof geH) || ((geH) obj2).b == null) { gea2._decision = 0; gea2._state = C15024ges.e; gea = gea2; } else { InterfaceC15056gfp interfaceC15056gfp = gea2.e; if (interfaceC15056gfp != null) { interfaceC15056gfp.e(); gea2.e = gfL.d; } } if (gea != null) { return gea; } } return new geA<>(interfaceC14907gbi, 2); } }