package o; import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; /* renamed from: o.fXu, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public final class C13347fXu extends fUX { private fSS> a; private int d; private boolean e; public C13347fXu(InterfaceC13169fSq interfaceC13169fSq, fSS> fss, int i, boolean z) { super(interfaceC13169fSq); this.a = fss; this.d = i; this.e = z; } @Override // o.AbstractC13163fSk public final void subscribeActual(InterfaceC13174fSv interfaceC13174fSv) { if (C13328fXb.d(this.c, interfaceC13174fSv, this.a)) { return; } this.c.subscribe(new Sts(interfaceC13174fSv, this.a, this.d, this.e)); } /* renamed from: o.fXu$Sts */ /* loaded from: classes6.dex */ static final class Sts extends AtomicInteger implements InterfaceC13174fSv, fSJ { private static IeS h; final boolean a; fSJ b; volatile boolean d; volatile long e; private InterfaceC13174fSv g; private volatile boolean i; private int j; /* renamed from: o, reason: collision with root package name */ private fSS> f9127o; private AtomicReference> f = new AtomicReference<>(); final C13355fYI c = new C13355fYI(); static { IeS ieS = new IeS<>(null, -1L, 1); h = ieS; EnumC13192fTf.e(ieS); } Sts(InterfaceC13174fSv interfaceC13174fSv, fSS> fss, int i, boolean z) { this.g = interfaceC13174fSv; this.f9127o = fss; this.j = i; this.a = z; } @Override // o.InterfaceC13174fSv public final void onSubscribe(fSJ fsj) { if (EnumC13192fTf.d(this.b, fsj)) { this.b = fsj; this.g.onSubscribe(this); } } @Override // o.InterfaceC13174fSv public final void onNext(T t) { long j = this.e + 1; this.e = j; IeS ieS = this.f.get(); if (ieS != null) { EnumC13192fTf.e(ieS); } try { InterfaceC13169fSq interfaceC13169fSq = (InterfaceC13169fSq) Objects.requireNonNull(this.f9127o.a(t), "The ObservableSource returned is null"); IeS ieS2 = new IeS<>(this, j, this.j); while (true) { IeS ieS3 = this.f.get(); if (ieS3 != h) { AtomicReference> atomicReference = this.f; while (!atomicReference.compareAndSet(ieS3, ieS2)) { if (atomicReference.get() != ieS3) { break; } } interfaceC13169fSq.subscribe(ieS2); return; } return; } } catch (Throwable th) { C13147fSI.c(th); this.b.dispose(); onError(th); } } @Override // o.InterfaceC13174fSv public final void onComplete() { if (this.d) { return; } this.d = true; b(); } @Override // o.fSJ public final void dispose() { if (this.i) { return; } this.i = true; this.b.dispose(); IeS ieS = (IeS) this.f.getAndSet(h); if (ieS != null) { EnumC13192fTf.e(ieS); } Throwable b = fYR.b(this.c); if (b == null || b == fYR.b) { return; } C13418fZu.c(b); } /* JADX WARN: Code restructure failed: missing block: B:109:0x000f, code lost: continue; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ final void b() { /* Method dump skipped, instructions count: 255 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: o.C13347fXu.Sts.b():void"); } @Override // o.InterfaceC13174fSv public final void onError(Throwable th) { IeS ieS; if (!this.d && fYR.c(this.c, th)) { if (!this.a && (ieS = (IeS) this.f.getAndSet(h)) != null) { EnumC13192fTf.e(ieS); } this.d = true; b(); return; } C13418fZu.c(th); } @Override // o.fSJ public final boolean isDisposed() { return this.i; } } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.fXu$IeS */ /* loaded from: classes6.dex */ public static final class IeS extends AtomicReference implements InterfaceC13174fSv { private Sts a; private long b; volatile boolean c; private int d; volatile InterfaceC13414fZq e; IeS(Sts sts, long j, int i) { this.a = sts; this.b = j; this.d = i; } @Override // o.InterfaceC13174fSv public final void onSubscribe(fSJ fsj) { if (EnumC13192fTf.a(this, fsj)) { if (fsj instanceof InterfaceC13412fZo) { InterfaceC13412fZo interfaceC13412fZo = (InterfaceC13412fZo) fsj; int b = interfaceC13412fZo.b(7); if (b == 1) { this.e = interfaceC13412fZo; this.c = true; this.a.b(); return; } else if (b == 2) { this.e = interfaceC13412fZo; return; } } this.e = new C13416fZs(this.d); } } @Override // o.InterfaceC13174fSv public final void onNext(R r) { if (this.b == this.a.e) { if (r != null) { this.e.b(r); } this.a.b(); } } @Override // o.InterfaceC13174fSv public final void onComplete() { if (this.b == this.a.e) { this.c = true; this.a.b(); } } @Override // o.InterfaceC13174fSv public final void onError(Throwable th) { Sts sts = this.a; if (this.b == sts.e && fYR.c(sts.c, th)) { if (!sts.a) { sts.b.dispose(); sts.d = true; } this.c = true; sts.b(); return; } C13418fZu.c(th); } } }