package kotlinx.coroutines.internal;

import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import p039m1.C1470g;
import p039m1.C1474k;
import p060t1.C1679h;
import p060t1.C1732z;

/* renamed from: kotlinx.coroutines.internal.l */
/* loaded from: classes.dex */
public class C1369l {

    /* renamed from: d */
    public static final /* synthetic */ AtomicReferenceFieldUpdater f3043d = AtomicReferenceFieldUpdater.newUpdater(C1369l.class, Object.class, "_next");

    /* renamed from: e */
    public static final /* synthetic */ AtomicReferenceFieldUpdater f3044e = AtomicReferenceFieldUpdater.newUpdater(C1369l.class, Object.class, "_prev");

    /* renamed from: f */
    public static final /* synthetic */ AtomicReferenceFieldUpdater f3045f = AtomicReferenceFieldUpdater.newUpdater(C1369l.class, Object.class, "_removedRef");
    volatile /* synthetic */ Object _next = this;
    volatile /* synthetic */ Object _prev = this;
    private volatile /* synthetic */ Object _removedRef = null;

    /* renamed from: kotlinx.coroutines.internal.l$a */
    /* loaded from: classes.dex */
    public static abstract class AbstractC1370a extends AbstractC1358c<C1369l> {

        /* renamed from: b */
        public final C1369l f3046b;

        /* renamed from: c */
        public C1369l f3047c;

        public AbstractC1370a(C1369l c1369l) {
            this.f3046b = c1369l;
        }

        @Override // kotlinx.coroutines.internal.AbstractC1358c
        /* renamed from: h */
        public void mo1516d(C1369l c1369l, Object obj) {
            boolean z = obj == null;
            C1369l c1369l2 = z ? this.f3046b : this.f3047c;
            if (c1369l2 != null && C1679h.m602a(C1369l.f3043d, c1369l, this, c1369l2) && z) {
                C1369l c1369l3 = this.f3046b;
                C1369l c1369l4 = this.f3047c;
                C1470g.m1295b(c1369l4);
                c1369l3.m1525j(c1369l4);
            }
        }
    }

    /* renamed from: g */
    public final boolean m1528g(C1369l c1369l) {
        f3044e.lazySet(c1369l, this);
        f3043d.lazySet(c1369l, this);
        while (m1524k() == this) {
            if (C1679h.m602a(f3043d, this, this, c1369l)) {
                c1369l.m1525j(this);
                return true;
            }
        }
        return false;
    }

    /* JADX WARN: Code restructure failed: missing block: B:28:0x0048, code lost:
        if (p060t1.C1679h.m602a(kotlinx.coroutines.internal.C1369l.f3043d, r3, r2, ((kotlinx.coroutines.internal.C1381t) r4).f3064a) != false) goto L23;
     */
    /* renamed from: h */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final C1369l m1527h(AbstractC1380s abstractC1380s) {
        while (true) {
            C1369l c1369l = (C1369l) this._prev;
            C1369l c1369l2 = c1369l;
            while (true) {
                C1369l c1369l3 = null;
                while (true) {
                    Object obj = c1369l2._next;
                    if (obj == this) {
                        if (c1369l == c1369l2 || C1679h.m602a(f3044e, this, c1369l, c1369l2)) {
                            return c1369l2;
                        }
                    } else if (mo1521n()) {
                        return null;
                    } else {
                        if (obj == abstractC1380s) {
                            return c1369l2;
                        }
                        if (obj instanceof AbstractC1380s) {
                            if (abstractC1380s != null && abstractC1380s.m1486b((AbstractC1380s) obj)) {
                                return null;
                            }
                            ((AbstractC1380s) obj).mo1485c(c1369l2);
                        } else if (!(obj instanceof C1381t)) {
                            c1369l3 = c1369l2;
                            c1369l2 = (C1369l) obj;
                        } else if (c1369l3 != null) {
                            break;
                        } else {
                            c1369l2 = (C1369l) c1369l2._prev;
                        }
                    }
                }
                c1369l2 = c1369l3;
            }
        }
    }

    /* renamed from: i */
    public final C1369l m1526i(C1369l c1369l) {
        while (c1369l.mo1521n()) {
            c1369l = (C1369l) c1369l._prev;
        }
        return c1369l;
    }

    /* renamed from: j */
    public final void m1525j(C1369l c1369l) {
        C1369l c1369l2;
        do {
            c1369l2 = (C1369l) c1369l._prev;
            if (m1524k() != c1369l) {
                return;
            }
        } while (!C1679h.m602a(f3044e, c1369l, c1369l2, this));
        if (mo1521n()) {
            c1369l.m1527h(null);
        }
    }

    /* renamed from: k */
    public final Object m1524k() {
        while (true) {
            Object obj = this._next;
            if (!(obj instanceof AbstractC1380s)) {
                return obj;
            }
            ((AbstractC1380s) obj).mo1485c(this);
        }
    }

    /* renamed from: l */
    public final C1369l m1523l() {
        return C1368k.m1530b(m1524k());
    }

    /* renamed from: m */
    public final C1369l m1522m() {
        C1369l m1527h = m1527h(null);
        return m1527h == null ? m1526i((C1369l) this._prev) : m1527h;
    }

    /* renamed from: n */
    public boolean mo1521n() {
        return m1524k() instanceof C1381t;
    }

    /* renamed from: o */
    public boolean m1520o() {
        return m1519p() == null;
    }

    /* renamed from: p */
    public final C1369l m1519p() {
        Object m1524k;
        C1369l c1369l;
        do {
            m1524k = m1524k();
            if (m1524k instanceof C1381t) {
                return ((C1381t) m1524k).f3064a;
            }
            if (m1524k == this) {
                return (C1369l) m1524k;
            }
            c1369l = (C1369l) m1524k;
        } while (!C1679h.m602a(f3043d, this, m1524k, c1369l.m1518q()));
        c1369l.m1527h(null);
        return null;
    }

    /* renamed from: q */
    public final C1381t m1518q() {
        C1381t c1381t = (C1381t) this._removedRef;
        if (c1381t == null) {
            C1381t c1381t2 = new C1381t(this);
            f3045f.lazySet(this, c1381t2);
            return c1381t2;
        }
        return c1381t;
    }

    /* renamed from: r */
    public final int m1517r(C1369l c1369l, C1369l c1369l2, AbstractC1370a abstractC1370a) {
        f3044e.lazySet(c1369l, this);
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = f3043d;
        atomicReferenceFieldUpdater.lazySet(c1369l, c1369l2);
        abstractC1370a.f3047c = c1369l2;
        if (C1679h.m602a(atomicReferenceFieldUpdater, this, c1369l2, abstractC1370a)) {
            return abstractC1370a.mo1485c(this) == null ? 1 : 2;
        }
        return 0;
    }

    public String toString() {
        return new C1474k(this) { // from class: kotlinx.coroutines.internal.l.b
            @Override // p051q1.InterfaceC1568d
            public Object get() {
                return C1732z.m496a(this.f3209e);
            }
        } + '@' + C1732z.m495b(this);
    }
}