package kotlinx.coroutines.flow; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import kotlin.Unit; import kotlin.coroutines.Continuation; import kotlin.coroutines.CoroutineContext; import kotlin.jvm.internal.Intrinsics; import kotlinx.coroutines.channels.BufferOverflow; import kotlinx.coroutines.flow.internal.AbstractSharedFlow; import kotlinx.coroutines.flow.internal.AbstractSharedFlowSlot; import kotlinx.coroutines.flow.internal.FusibleFlow; import kotlinx.coroutines.flow.internal.NullSurrogateKt; import kotlinx.coroutines.internal.Symbol; /* loaded from: classes5.dex */ public final class StateFlowImpl extends AbstractSharedFlow implements MutableStateFlow, Flow, FusibleFlow { public static final AtomicReferenceFieldUpdater _state$FU = AtomicReferenceFieldUpdater.newUpdater(StateFlowImpl.class, Object.class, "_state"); private volatile Object _state; public int sequence; public final boolean updateState(Object obj, Object obj2) { int i; AbstractSharedFlowSlot[] slots; synchronized (this) { AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = _state$FU; Object obj3 = atomicReferenceFieldUpdater.get(this); if (obj != null && !Intrinsics.areEqual(obj3, obj)) { return false; } if (Intrinsics.areEqual(obj3, obj2)) { return true; } atomicReferenceFieldUpdater.set(this, obj2); int i2 = this.sequence; if ((i2 & 1) != 0) { this.sequence = i2 + 2; return true; } int i3 = i2 + 1; this.sequence = i3; AbstractSharedFlowSlot[] slots2 = getSlots(); Unit unit = Unit.INSTANCE; while (true) { StateFlowSlot[] stateFlowSlotArr = (StateFlowSlot[]) slots2; if (stateFlowSlotArr != null) { for (StateFlowSlot stateFlowSlot : stateFlowSlotArr) { if (stateFlowSlot != null) { stateFlowSlot.makePending(); } } } synchronized (this) { i = this.sequence; if (i == i3) { this.sequence = i3 + 1; return true; } slots = getSlots(); Unit unit2 = Unit.INSTANCE; } slots2 = slots; i3 = i; } } } public StateFlowImpl(Object obj) { this._state = obj; } @Override // kotlinx.coroutines.flow.MutableStateFlow, kotlinx.coroutines.flow.StateFlow public Object getValue() { Symbol symbol = NullSurrogateKt.NULL; Object obj = _state$FU.get(this); if (obj == symbol) { return null; } return obj; } @Override // kotlinx.coroutines.flow.MutableStateFlow public void setValue(Object obj) { if (obj == null) { obj = NullSurrogateKt.NULL; } updateState(null, obj); } @Override // kotlinx.coroutines.flow.MutableStateFlow public boolean compareAndSet(Object obj, Object obj2) { if (obj == null) { obj = NullSurrogateKt.NULL; } if (obj2 == null) { obj2 = NullSurrogateKt.NULL; } return updateState(obj, obj2); } @Override // kotlinx.coroutines.flow.MutableSharedFlow public boolean tryEmit(Object obj) { setValue(obj); return true; } @Override // kotlinx.coroutines.flow.MutableSharedFlow, kotlinx.coroutines.flow.FlowCollector public Object emit(Object obj, Continuation continuation) { setValue(obj); return Unit.INSTANCE; } @Override // kotlinx.coroutines.flow.MutableSharedFlow public void resetReplayCache() { throw new UnsupportedOperationException("MutableStateFlow.resetReplayCache is not supported"); } /* JADX WARN: Code restructure failed: missing block: B:19:0x00bc, code lost: if (kotlin.jvm.internal.Intrinsics.areEqual(r11, r12) == false) goto L42; */ /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Removed duplicated region for block: B:16:0x00b3 A[Catch: all -> 0x0043, TryCatch #0 {all -> 0x0043, blocks: (B:13:0x003e, B:14:0x00ab, B:16:0x00b3, B:18:0x00b8, B:20:0x00d9, B:22:0x00df, B:26:0x00be, B:29:0x00c5, B:38:0x0060, B:40:0x0073, B:41:0x009c), top: B:7:0x0024 }] */ /* JADX WARN: Removed duplicated region for block: B:18:0x00b8 A[Catch: all -> 0x0043, TryCatch #0 {all -> 0x0043, blocks: (B:13:0x003e, B:14:0x00ab, B:16:0x00b3, B:18:0x00b8, B:20:0x00d9, B:22:0x00df, B:26:0x00be, B:29:0x00c5, B:38:0x0060, B:40:0x0073, B:41:0x009c), top: B:7:0x0024 }] */ /* JADX WARN: Removed duplicated region for block: B:22:0x00df A[Catch: all -> 0x0043, TRY_LEAVE, TryCatch #0 {all -> 0x0043, blocks: (B:13:0x003e, B:14:0x00ab, B:16:0x00b3, B:18:0x00b8, B:20:0x00d9, B:22:0x00df, B:26:0x00be, B:29:0x00c5, B:38:0x0060, B:40:0x0073, B:41:0x009c), top: B:7:0x0024 }] */ /* JADX WARN: Removed duplicated region for block: B:28:0x00c2 */ /* JADX WARN: Removed duplicated region for block: B:31:0x00d7 A[RETURN] */ /* JADX WARN: Removed duplicated region for block: B:32:0x00d8 */ /* JADX WARN: Removed duplicated region for block: B:33:0x00c4 */ /* JADX WARN: Removed duplicated region for block: B:42:0x0077 */ /* JADX WARN: Removed duplicated region for block: B:9:0x0026 */ /* JADX WARN: Type inference failed for: r6v0 */ /* JADX WARN: Type inference failed for: r6v1 */ /* JADX WARN: Type inference failed for: r6v14 */ /* JADX WARN: Type inference failed for: r6v15 */ /* JADX WARN: Type inference failed for: r6v16 */ /* JADX WARN: Type inference failed for: r6v17 */ /* JADX WARN: Type inference failed for: r6v2, types: [kotlinx.coroutines.flow.internal.AbstractSharedFlowSlot] */ /* JADX WARN: Type inference failed for: r6v3 */ /* JADX WARN: Type inference failed for: r6v7, types: [java.lang.Object] */ /* JADX WARN: Type inference failed for: r8v1, types: [kotlinx.coroutines.flow.internal.AbstractSharedFlow] */ /* JADX WARN: Type inference failed for: r8v13 */ /* JADX WARN: Type inference failed for: r8v14 */ /* JADX WARN: Type inference failed for: r8v15 */ /* JADX WARN: Type inference failed for: r8v16 */ /* JADX WARN: Type inference failed for: r8v2 */ /* JADX WARN: Type inference failed for: r8v6, types: [java.lang.Object] */ /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:21:0x00dd -> B:14:0x00ab). Please report as a decompilation issue!!! */ /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:23:0x00ef -> B:14:0x00ab). Please report as a decompilation issue!!! */ @Override // kotlinx.coroutines.flow.SharedFlow, kotlinx.coroutines.flow.Flow /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public java.lang.Object collect(kotlinx.coroutines.flow.FlowCollector r11, kotlin.coroutines.Continuation r12) { /* Method dump skipped, instructions count: 246 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: kotlinx.coroutines.flow.StateFlowImpl.collect(kotlinx.coroutines.flow.FlowCollector, kotlin.coroutines.Continuation):java.lang.Object"); } @Override // kotlinx.coroutines.flow.internal.AbstractSharedFlow public StateFlowSlot createSlot() { return new StateFlowSlot(); } @Override // kotlinx.coroutines.flow.internal.AbstractSharedFlow public StateFlowSlot[] createSlotArray(int i) { return new StateFlowSlot[i]; } @Override // kotlinx.coroutines.flow.internal.FusibleFlow public Flow fuse(CoroutineContext coroutineContext, int i, BufferOverflow bufferOverflow) { return StateFlowKt.fuseStateFlow(this, coroutineContext, i, bufferOverflow); } }