package o; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; /* loaded from: classes6.dex */ public final class ghJ implements ghG { static final AtomicReferenceFieldUpdater d = AtomicReferenceFieldUpdater.newUpdater(ghJ.class, Object.class, "_state"); volatile Object _state; public ghJ() { C15102ghH c15102ghH; c15102ghH = ghR.e; this._state = c15102ghH; } /* JADX WARN: Code restructure failed: missing block: B:59:0x00db, code lost: r1.e(new o.C15038gfQ(r8)); */ @Override // o.ghG /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final java.lang.Object c(o.InterfaceC14907gbi r13) { /* Method dump skipped, instructions count: 352 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: o.ghJ.c(o.gbi):java.lang.Object"); } /* loaded from: classes6.dex */ static final class IeS extends AbstractC14961gcz implements InterfaceC14894gbR { private Object b = null; private ghJ d; @Override // o.InterfaceC14894gbR public final /* synthetic */ C14866gag invoke(Throwable th) { this.d.d(null); return C14866gag.c; } /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ IeS(ghJ ghj) { super(1); this.d = ghj; } } @Override // o.ghG public final void d(Object obj) { C15102ghH c15102ghH; C15119ghh c15119ghh; ggU ggu; Object obj2; ggU ggu2; while (true) { Object obj3 = this._state; if (!(obj3 instanceof C15102ghH)) { if (obj3 instanceof AbstractC15115ghd) { ((AbstractC15115ghd) obj3).a(this); } else if (obj3 instanceof HBt) { if (obj != null) { HBt hBt = (HBt) obj3; if (hBt.owner != obj) { StringBuilder sb = new StringBuilder("Mutex is locked by "); sb.append(hBt.owner); sb.append(" but expected "); sb.append(obj); throw new IllegalStateException(sb.toString().toString()); } } HBt hBt2 = (HBt) obj3; while (true) { Object obj4 = hBt2._next; if (!(obj4 instanceof AbstractC15115ghd)) { ggu = (ggU) obj4; if (ggu == hBt2) { ggu = null; break; } if (ggu.bw_()) { break; } while (true) { obj2 = ggu._next; if (!(obj2 instanceof AbstractC15115ghd)) { break; } else { ((AbstractC15115ghd) obj2).a(ggu); } } do { ggu2 = ((C15113ghb) obj2).c; while (true) { obj2 = ggu2._next; if (!(obj2 instanceof AbstractC15115ghd)) { break; } else { ((AbstractC15115ghd) obj2).a(ggu2); } } } while (obj2 instanceof C15113ghb); ggu2.b(); } else { ((AbstractC15115ghd) obj4).a(hBt2); } } if (ggu == null) { Sts sts = new Sts(hBt2); AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = d; while (true) { if (atomicReferenceFieldUpdater.compareAndSet(this, obj3, sts)) { if (sts.a(this) == null) { return; } } else if (atomicReferenceFieldUpdater.get(this) != obj3) { break; } } } else { LWm lWm = (LWm) ggu; if (lWm.d()) { Object obj5 = lWm.a; if (obj5 == null) { obj5 = ghR.b; } hBt2.owner = obj5; lWm.a(); return; } } } else { throw new IllegalStateException("Illegal state ".concat(String.valueOf(obj3)).toString()); } } else { if (obj == null) { Object obj6 = ((C15102ghH) obj3).d; c15119ghh = ghR.a; if (obj6 == c15119ghh) { throw new IllegalStateException("Mutex is not locked".toString()); } } else { C15102ghH c15102ghH2 = (C15102ghH) obj3; if (c15102ghH2.d != obj) { StringBuilder sb2 = new StringBuilder("Mutex is locked by "); sb2.append(c15102ghH2.d); sb2.append(" but expected "); sb2.append(obj); throw new IllegalStateException(sb2.toString().toString()); } } AtomicReferenceFieldUpdater atomicReferenceFieldUpdater2 = d; c15102ghH = ghR.e; while (!atomicReferenceFieldUpdater2.compareAndSet(this, obj3, c15102ghH)) { if (atomicReferenceFieldUpdater2.get(this) != obj3) { break; } } return; } } } public final String toString() { while (true) { Object obj = this._state; if (obj instanceof C15102ghH) { StringBuilder sb = new StringBuilder("Mutex["); sb.append(((C15102ghH) obj).d); sb.append(']'); return sb.toString(); } if (!(obj instanceof AbstractC15115ghd)) { if (!(obj instanceof HBt)) { throw new IllegalStateException("Illegal state ".concat(String.valueOf(obj)).toString()); } StringBuilder sb2 = new StringBuilder("Mutex["); sb2.append(((HBt) obj).owner); sb2.append(']'); return sb2.toString(); } ((AbstractC15115ghd) obj).a(this); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static final class HBt extends ggR { public volatile Object owner; public HBt(Object obj) { this.owner = obj; } @Override // o.ggU public final String toString() { StringBuilder sb = new StringBuilder("LockedQueue["); sb.append(this.owner); sb.append(']'); return sb.toString(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public abstract class LWm extends ggU implements InterfaceC15056gfp { static final AtomicIntegerFieldUpdater d = AtomicIntegerFieldUpdater.newUpdater(LWm.class, "isTaken"); private ghJ c; public final Object a = null; private volatile int isTaken = 0; public abstract void a(); public abstract boolean d(); public LWm(ghJ ghj, Object obj) { this.c = ghj; } @Override // o.InterfaceC15056gfp public final void e() { bw_(); } } /* loaded from: classes6.dex */ final class RVV extends LWm { private final InterfaceC15027gev c; private ghJ h; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ /* JADX WARN: Multi-variable type inference failed */ public RVV(ghJ ghj, InterfaceC15027gev interfaceC15027gev) { super(ghj, null); this.h = ghj; this.c = interfaceC15027gev; } /* loaded from: classes6.dex */ static final class Sts extends AbstractC14961gcz implements InterfaceC14894gbR { private ghJ d; private RVV e; @Override // o.InterfaceC14894gbR public final /* synthetic */ C14866gag invoke(Throwable th) { this.d.d(this.e.a); return C14866gag.c; } /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ Sts(ghJ ghj, RVV rvv) { super(1); this.d = ghj; this.e = rvv; } } @Override // o.ghJ.LWm public final boolean d() { return LWm.d.compareAndSet(this, 0, 1) && this.c.c(C14866gag.c, new Sts(this.h, this)) != null; } @Override // o.ghJ.LWm public final void a() { InterfaceC15027gev interfaceC15027gev = this.c; C15119ghh c15119ghh = geC.b; interfaceC15027gev.c(); } @Override // o.ggU public final String toString() { StringBuilder sb = new StringBuilder("LockCont["); sb.append(this.a); sb.append(", "); sb.append(this.c); sb.append("] for "); sb.append(this.h); return sb.toString(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static final class Sts extends ggF { private HBt b; @Override // o.ggF public final /* synthetic */ void c(ghJ ghj, Object obj) { ghJ ghj2 = ghj; Object obj2 = obj == null ? ghR.e : this.b; AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = ghJ.d; while (!atomicReferenceFieldUpdater.compareAndSet(ghj2, this, obj2) && atomicReferenceFieldUpdater.get(ghj2) == this) { } } @Override // o.ggF public final /* synthetic */ Object e(ghJ ghj) { Object obj; C15119ghh c15119ghh; HBt hBt = this.b; while (true) { obj = hBt._next; if (!(obj instanceof AbstractC15115ghd)) { break; } ((AbstractC15115ghd) obj).a(hBt); } if (obj == hBt) { return null; } c15119ghh = ghR.d; return c15119ghh; } public Sts(HBt hBt) { this.b = hBt; } } }