package defpackage;

import java.util.ArrayList;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import kotlinx.coroutines.CompletionHandlerException;
import kotlinx.coroutines.JobCancellationException;
import kotlinx.coroutines.TimeoutCancellationException;
import sun.misc.Unsafe;

/* renamed from: ˀᵡ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public class C0577 implements InterfaceC3506 {

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public static final /* synthetic */ AtomicReferenceFieldUpdater f2956;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public static final /* synthetic */ AtomicReferenceFieldUpdater f2957 = AtomicReferenceFieldUpdater.newUpdater(C0577.class, Object.class, "_state$volatile");

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public static final /* synthetic */ long f2958;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public static final /* synthetic */ long f2959;
    private volatile /* synthetic */ Object _parentHandle$volatile;
    private volatile /* synthetic */ Object _state$volatile;

    static {
        Unsafe unsafe = AbstractC3747.f13986;
        f2958 = unsafe.objectFieldOffset(C0577.class.getDeclaredField("_state$volatile"));
        f2956 = AtomicReferenceFieldUpdater.newUpdater(C0577.class, Object.class, "_parentHandle$volatile");
        f2959 = unsafe.objectFieldOffset(C0577.class.getDeclaredField("_parentHandle$volatile"));
    }

    public C0577(boolean z) {
        this._state$volatile = z ? AbstractC2891.f11212 : AbstractC2891.f11213;
    }

    /* renamed from: ᵽʛ, reason: contains not printable characters */
    public static C3022 m2417(C5029 c5029) {
        while (c5029.mo6553()) {
            c5029 = c5029.m10488();
        }
        while (true) {
            c5029 = c5029.m10485();
            if (!c5029.mo6553()) {
                if (c5029 instanceof C3022) {
                    return (C3022) c5029;
                }
                if (c5029 instanceof C2604) {
                    return null;
                }
            }
        }
    }

    /* renamed from: ﹶـ, reason: contains not printable characters */
    public static String m2418(Object obj) {
        if (!(obj instanceof C3469)) {
            return obj instanceof InterfaceC3148 ? ((InterfaceC3148) obj).mo1089() ? "Active" : "New" : obj instanceof C1411 ? "Cancelled" : "Completed";
        }
        C3469 c3469 = (C3469) obj;
        return c3469.m7899() ? "Cancelling" : C3469.f13007.get(c3469) == 1 ? "Completing" : "Active";
    }

    @Override // defpackage.InterfaceC1022
    public final InterfaceC2320 getKey() {
        return ʾᵠᵦ.ᵾᵬ;
    }

    @Override // defpackage.InterfaceC3506
    public final boolean isCancelled() {
        Object objM2422 = m2422();
        if (objM2422 instanceof C1411) {
            return true;
        }
        return (objM2422 instanceof C3469) && ((C3469) objM2422).m7899();
    }

    @Override // defpackage.InterfaceC3506
    public final boolean start() {
        int iM2423;
        do {
            iM2423 = m2423(m2422());
            if (iM2423 == 0) {
                return false;
            }
        } while (iM2423 != 1);
        return true;
    }

    public final String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(mo2448() + '{' + m2418(m2422()) + '}');
        sb.append('@');
        sb.append(ˁـᵛ.ᵳٴᵶ(this));
        return sb.toString();
    }

    /* renamed from: ʾᵻᵭٴ, reason: contains not printable characters */
    public final void m2419(AbstractC2594 abstractC2594) {
        abstractC2594.m10486(new C2604());
        C5029 c5029M10485 = abstractC2594.m10485();
        while (true) {
            f2957.getClass();
            Unsafe unsafe = AbstractC3747.f13986;
            long j = f2958;
            C0577 c0577 = this;
            AbstractC2594 abstractC25942 = abstractC2594;
            if (unsafe.compareAndSwapObject(c0577, j, abstractC25942, c5029M10485) || unsafe.getObjectVolatile(c0577, j) != abstractC25942) {
                return;
            }
            this = c0577;
            abstractC2594 = abstractC25942;
        }
    }

    /* renamed from: ˀˁᵨ, reason: contains not printable characters */
    public final void m2420(C2604 c2604, Throwable th) {
        c2604.m10483(new C2746(4), 4);
        CompletionHandlerException completionHandlerException = null;
        for (C5029 c5029M10485 = (C5029) c2604.m10491(); !ᵲᵝᵪ.ᵹᵝᵶ(c5029M10485, c2604); c5029M10485 = c5029M10485.m10485()) {
            if ((c5029M10485 instanceof AbstractC2594) && ((AbstractC2594) c5029M10485).mo1525()) {
                try {
                    ((AbstractC2594) c5029M10485).mo1526(th);
                } catch (Throwable th2) {
                    if (completionHandlerException != null) {
                        ᵳـᵔʤ.ᵴᵳ(completionHandlerException, th2);
                    } else {
                        completionHandlerException = new CompletionHandlerException("Exception in completion handler " + c5029M10485 + " for " + this, th2);
                    }
                }
            }
        }
        if (completionHandlerException != null) {
            mo2435(completionHandlerException);
        }
        m2433(th);
    }

    /* renamed from: ˀᵗᵝᵭ, reason: contains not printable characters */
    public final Object m2421(C3469 c3469, Object obj) throws Throwable {
        C3469 c34692;
        Throwable th;
        Throwable thM2449;
        C0577 c0577;
        C3469 c34693;
        C1411 c1411 = obj instanceof C1411 ? (C1411) obj : null;
        Throwable th2 = c1411 != null ? c1411.f5777 : null;
        synchronized (c3469) {
            try {
                c3469.m7899();
                ArrayList arrayListM7898 = c3469.m7898(th2);
                thM2449 = m2449(c3469, arrayListM7898);
                if (thM2449 != null) {
                    try {
                        if (arrayListM7898.size() > 1) {
                            Set setNewSetFromMap = Collections.newSetFromMap(new IdentityHashMap(arrayListM7898.size()));
                            int size = arrayListM7898.size();
                            int i = 0;
                            while (i < size) {
                                Object obj2 = arrayListM7898.get(i);
                                i++;
                                Throwable th3 = (Throwable) obj2;
                                if (th3 != thM2449 && th3 != thM2449 && !(th3 instanceof CancellationException) && setNewSetFromMap.add(th3)) {
                                    ᵳـᵔʤ.ᵴᵳ(thM2449, th3);
                                }
                            }
                        }
                    } catch (Throwable th4) {
                        th = th4;
                        c34692 = c3469;
                        throw th;
                    }
                }
            } catch (Throwable th5) {
                c34692 = c3469;
                th = th5;
            }
        }
        if (thM2449 != null && thM2449 != th2) {
            obj = new C1411(thM2449, false);
        }
        if (thM2449 != null && (m2433(thM2449) || mo2458(thM2449))) {
            C1411 c14112 = (C1411) obj;
            c14112.getClass();
            C1411.f5776.compareAndSet(c14112, 0, 1);
        }
        mo2425(obj);
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = f2957;
        Object c0096 = obj instanceof InterfaceC3148 ? new C0096((InterfaceC3148) obj) : obj;
        while (true) {
            atomicReferenceFieldUpdater.getClass();
            Unsafe unsafe = AbstractC3747.f13986;
            long j = f2958;
            c0577 = this;
            c34693 = c3469;
            if (unsafe.compareAndSwapObject(c0577, j, c34693, c0096) || unsafe.getObjectVolatile(c0577, j) != c34693) {
                break;
            }
            this = c0577;
            c3469 = c34693;
        }
        c0577.m2456(c34693, obj);
        return obj;
    }

    @Override // defpackage.InterfaceC2262
    /* renamed from: ˀᵗᵩ */
    public final InterfaceC2262 mo1762(InterfaceC2262 interfaceC2262) {
        return ˁˈᵸ.ˎˑː(this, interfaceC2262);
    }

    /* renamed from: ˁˑᵰ, reason: contains not printable characters */
    public final Object m2422() {
        f2957.getClass();
        return AbstractC3747.f13986.getObjectVolatile(this, f2958);
    }

    /* renamed from: ˆᵴᵜˏ, reason: contains not printable characters */
    public final int m2423(Object obj) {
        Unsafe unsafe;
        boolean z = obj instanceof C0047;
        long j = f2958;
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = f2957;
        if (!z) {
            C0577 c0577 = this;
            Object obj2 = obj;
            if (!(obj2 instanceof C2907)) {
                return 0;
            }
            C2604 c2604 = ((C2907) obj2).f11315;
            do {
                atomicReferenceFieldUpdater.getClass();
                C0577 c05772 = c0577;
                unsafe = AbstractC3747.f13986;
                Object obj3 = obj2;
                boolean zCompareAndSwapObject = unsafe.compareAndSwapObject(c05772, f2958, obj3, c2604);
                c0577 = c05772;
                obj2 = obj3;
                if (zCompareAndSwapObject) {
                    c0577.mo2429();
                    return 1;
                }
            } while (unsafe.getObjectVolatile(c0577, j) == obj2);
            return -1;
        }
        if (((C0047) obj).f1206) {
            return 0;
        }
        while (true) {
            atomicReferenceFieldUpdater.getClass();
            Unsafe unsafe2 = AbstractC3747.f13986;
            C0577 c05773 = this;
            Object obj4 = obj;
            if (unsafe2.compareAndSwapObject(c05773, f2958, obj4, AbstractC2891.f11212)) {
                c05773.mo2429();
                return 1;
            }
            if (unsafe2.getObjectVolatile(c05773, j) != obj4) {
                return -1;
            }
            this = c05773;
            obj = obj4;
        }
    }

    /* renamed from: ˆᵼᵷˊ, reason: contains not printable characters */
    public boolean mo2424() {
        return this instanceof C1955;
    }

    @Override // defpackage.InterfaceC3506
    /* renamed from: ˊʽˎ */
    public final InterfaceC3451 mo2235(InterfaceC0362 interfaceC0362) {
        return m2432(true, new C3197(interfaceC0362));
    }

    /* renamed from: ˊʾˊ, reason: contains not printable characters */
    public void mo2425(Object obj) {
    }

    /* renamed from: ˊᵸˊ, reason: contains not printable characters */
    public final boolean m2426() {
        return !(m2422() instanceof InterfaceC3148);
    }

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public Object m2427() {
        return m2430();
    }

    /* renamed from: ˌᵪ, reason: contains not printable characters */
    public final boolean m2428(Object obj) {
        Object objM2450;
        do {
            objM2450 = m2450(m2422(), obj);
            if (objM2450 == AbstractC2891.f11215) {
                return false;
            }
            if (objM2450 == AbstractC2891.f11216) {
                return true;
            }
        } while (objM2450 == AbstractC2891.f11214);
        mo2453(objM2450);
        return true;
    }

    /* renamed from: ˌᵹᵨˑ, reason: contains not printable characters */
    public void mo2429() {
    }

    /* renamed from: ˎˑː, reason: contains not printable characters */
    public final Object m2430() throws Throwable {
        Object objM2422 = m2422();
        if (objM2422 instanceof InterfaceC3148) {
            ᵹˉᵞ.ᵳٴᵶ("This job has not completed yet");
            return null;
        }
        if (objM2422 instanceof C1411) {
            throw ((C1411) objM2422).f5777;
        }
        return AbstractC2891.m7055(objM2422);
    }

    /* renamed from: ˎᵬˀ, reason: contains not printable characters */
    public Object m2431(InterfaceC4943 interfaceC4943) {
        return m2437(interfaceC4943);
    }

    @Override // defpackage.InterfaceC3506
    /* renamed from: ˏᵙ */
    public boolean mo2236() {
        Object objM2422 = m2422();
        return (objM2422 instanceof InterfaceC3148) && ((InterfaceC3148) objM2422).mo1089();
    }

    /* JADX WARN: Code restructure failed: missing block: B:45:0x008d, code lost:
    
        return r8;
     */
    /* renamed from: ˑᵝﹳᵜ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final defpackage.InterfaceC3451 m2432(boolean r7, defpackage.AbstractC2594 r8) {
        /*
            r6 = this;
            r8.f10068 = r6
        L2:
            java.lang.Object r4 = r6.m2422()
            boolean r0 = r4 instanceof defpackage.C0047
            if (r0 == 0) goto L33
            r0 = r4
            ʼʼ r0 = (defpackage.C0047) r0
            boolean r1 = r0.f1206
            if (r1 == 0) goto L2d
        L11:
            java.util.concurrent.atomic.AtomicReferenceFieldUpdater r0 = defpackage.C0577.f2957
            r0.getClass()
            sun.misc.Unsafe r0 = defpackage.AbstractC3747.f13986
            long r2 = defpackage.C0577.f2958
            r1 = r6
            r5 = r8
            boolean r6 = r0.compareAndSwapObject(r1, r2, r4, r5)
            if (r6 == 0) goto L23
            goto L74
        L23:
            java.lang.Object r6 = r0.getObjectVolatile(r1, r2)
            if (r6 == r4) goto L2a
            goto L75
        L2a:
            r6 = r1
            r8 = r5
            goto L11
        L2d:
            r1 = r6
            r5 = r8
            r1.m2436(r0)
            goto L75
        L33:
            r1 = r6
            r5 = r8
            boolean r6 = r4 instanceof defpackage.InterfaceC3148
            ʾᵖʚ r8 = defpackage.C0281.f1879
            r0 = 0
            if (r6 == 0) goto L78
            r6 = r4
            ᵠᵮʛ r6 = (defpackage.InterfaceC3148) r6
            ᵙᵠʿᵬ r2 = r6.mo1090()
            if (r2 != 0) goto L4b
            ᵙᐧᵕ r4 = (defpackage.AbstractC2594) r4
            r1.m2419(r4)
            goto L75
        L4b:
            boolean r3 = r5.mo1525()
            if (r3 == 0) goto L6d
            boolean r3 = r6 instanceof defpackage.C3469
            if (r3 == 0) goto L58
            ᵤᵻٴʧ r6 = (defpackage.C3469) r6
            goto L59
        L58:
            r6 = r0
        L59:
            if (r6 == 0) goto L5f
            java.lang.Throwable r0 = r6.m7897()
        L5f:
            if (r0 != 0) goto L67
            r6 = 5
            boolean r6 = r2.m10483(r5, r6)
            goto L72
        L67:
            if (r7 == 0) goto L8d
            r5.mo1526(r0)
            return r8
        L6d:
            r6 = 1
            boolean r6 = r2.m10483(r5, r6)
        L72:
            if (r6 == 0) goto L75
        L74:
            return r5
        L75:
            r6 = r1
            r8 = r5
            goto L2
        L78:
            if (r7 == 0) goto L8d
            java.lang.Object r6 = r1.m2422()
            boolean r7 = r6 instanceof defpackage.C1411
            if (r7 == 0) goto L85
            ˊᵻᵘ r6 = (defpackage.C1411) r6
            goto L86
        L85:
            r6 = r0
        L86:
            if (r6 == 0) goto L8a
            java.lang.Throwable r0 = r6.f5777
        L8a:
            r5.mo1526(r0)
        L8d:
            return r8
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C0577.m2432(boolean, ᵙᐧᵕ):ᵤᵢᵪ");
    }

    @Override // defpackage.InterfaceC2262
    /* renamed from: ˑᵥˁ */
    public final InterfaceC2262 mo1763(InterfaceC2320 interfaceC2320) {
        return ᵯˉˋ.ᵡˎ(this, interfaceC2320);
    }

    /* renamed from: ˑᵱ, reason: contains not printable characters */
    public final boolean m2433(Throwable th) {
        if (mo2424()) {
            return true;
        }
        boolean z = th instanceof CancellationException;
        InterfaceC0883 interfaceC0883M2451 = m2451();
        return (interfaceC0883M2451 == null || interfaceC0883M2451 == C0281.f1879) ? z : interfaceC0883M2451.mo1617(th) || z;
    }

    /* renamed from: ᐧﾞ, reason: contains not printable characters */
    public final C2604 m2434(InterfaceC3148 interfaceC3148) {
        C2604 c2604Mo1090 = interfaceC3148.mo1090();
        if (c2604Mo1090 != null) {
            return c2604Mo1090;
        }
        if (interfaceC3148 instanceof C0047) {
            return new C2604();
        }
        if (interfaceC3148 instanceof AbstractC2594) {
            m2419((AbstractC2594) interfaceC3148);
            return null;
        }
        C4069.m8939(interfaceC3148, "State should have list: ");
        return null;
    }

    /* renamed from: ᵙᵢᵨᵳ, reason: contains not printable characters */
    public void mo2435(CompletionHandlerException completionHandlerException) {
        throw completionHandlerException;
    }

    @Override // defpackage.InterfaceC2262
    /* renamed from: ᵛˈᵤ */
    public final InterfaceC1022 mo1764(InterfaceC2320 interfaceC2320) {
        return ᵯˉˋ.ᵯٴᵦ(this, interfaceC2320);
    }

    /* JADX WARN: Code restructure failed: missing block: B:35:0x007a, code lost:
    
        return r5;
     */
    @Override // defpackage.InterfaceC3506
    /* renamed from: ᵞʡ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final defpackage.InterfaceC0883 mo2237(defpackage.C0577 r7) {
        /*
            r6 = this;
            ᵟʿ r5 = new ᵟʿ
            r5.<init>(r7)
            r5.f10068 = r6
        L7:
            java.lang.Object r4 = r6.m2422()
            boolean r7 = r4 instanceof defpackage.C0047
            if (r7 == 0) goto L35
            r7 = r4
            ʼʼ r7 = (defpackage.C0047) r7
            boolean r0 = r7.f1206
            if (r0 == 0) goto L30
        L16:
            java.util.concurrent.atomic.AtomicReferenceFieldUpdater r7 = defpackage.C0577.f2957
            r7.getClass()
            sun.misc.Unsafe r0 = defpackage.AbstractC3747.f13986
            long r2 = defpackage.C0577.f2958
            r1 = r6
            boolean r6 = r0.compareAndSwapObject(r1, r2, r4, r5)
            if (r6 == 0) goto L27
            goto L7a
        L27:
            java.lang.Object r6 = r0.getObjectVolatile(r1, r2)
            if (r6 == r4) goto L2e
            goto L4b
        L2e:
            r6 = r1
            goto L16
        L30:
            r1 = r6
            r1.m2436(r7)
            goto L4b
        L35:
            r1 = r6
            boolean r6 = r4 instanceof defpackage.InterfaceC3148
            ʾᵖʚ r7 = defpackage.C0281.f1879
            r0 = 0
            if (r6 == 0) goto L7c
            r6 = r4
            ᵠᵮʛ r6 = (defpackage.InterfaceC3148) r6
            ᵙᵠʿᵬ r6 = r6.mo1090()
            if (r6 != 0) goto L4d
            ᵙᐧᵕ r4 = (defpackage.AbstractC2594) r4
            r1.m2419(r4)
        L4b:
            r6 = r1
            goto L7
        L4d:
            r2 = 7
            boolean r2 = r6.m10483(r5, r2)
            if (r2 == 0) goto L55
            goto L7a
        L55:
            r2 = 3
            boolean r6 = r6.m10483(r5, r2)
            java.lang.Object r1 = r1.m2422()
            boolean r2 = r1 instanceof defpackage.C3469
            if (r2 == 0) goto L69
            ᵤᵻٴʧ r1 = (defpackage.C3469) r1
            java.lang.Throwable r0 = r1.m7897()
            goto L75
        L69:
            boolean r2 = r1 instanceof defpackage.C1411
            if (r2 == 0) goto L70
            ˊᵻᵘ r1 = (defpackage.C1411) r1
            goto L71
        L70:
            r1 = r0
        L71:
            if (r1 == 0) goto L75
            java.lang.Throwable r0 = r1.f5777
        L75:
            r5.mo1526(r0)
            if (r6 == 0) goto L7b
        L7a:
            return r5
        L7b:
            return r7
        L7c:
            java.lang.Object r6 = r1.m2422()
            boolean r1 = r6 instanceof defpackage.C1411
            if (r1 == 0) goto L87
            ˊᵻᵘ r6 = (defpackage.C1411) r6
            goto L88
        L87:
            r6 = r0
        L88:
            if (r6 == 0) goto L8c
            java.lang.Throwable r0 = r6.f5777
        L8c:
            r5.mo1526(r0)
            return r7
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C0577.mo2237(ˀᵡ):ˆᵱ");
    }

    /* renamed from: ᵠᵿː, reason: contains not printable characters */
    public final void m2436(C0047 c0047) {
        C2604 c2604 = new C2604();
        Object c2907 = c0047.f1206 ? c2604 : new C2907(c2604);
        while (true) {
            f2957.getClass();
            Unsafe unsafe = AbstractC3747.f13986;
            long j = f2958;
            C0577 c0577 = this;
            C0047 c00472 = c0047;
            if (unsafe.compareAndSwapObject(c0577, j, c00472, c2907) || unsafe.getObjectVolatile(c0577, j) != c00472) {
                return;
            }
            this = c0577;
            c0047 = c00472;
        }
    }

    /* renamed from: ᵡʠ, reason: contains not printable characters */
    public final Object m2437(InterfaceC4943 interfaceC4943) throws Throwable {
        Object objM2422;
        do {
            objM2422 = m2422();
            if (!(objM2422 instanceof InterfaceC3148)) {
                if (objM2422 instanceof C1411) {
                    throw ((C1411) objM2422).f5777;
                }
                return AbstractC2891.m7055(objM2422);
            }
        } while (m2423(objM2422) < 0);
        C1699 c1699 = new C1699(ᵱᵞᵪ.ᵞʡ(interfaceC4943), this);
        c1699.m9415();
        c1699.m9401(new C3033(2, ᵭʝʜ.ˑᵱ(this, true, new C1032(c1699))));
        return c1699.m9405();
    }

    @Override // defpackage.InterfaceC2262
    /* renamed from: ᵡˎ */
    public final Object mo1765(Object obj, InterfaceC3759 interfaceC3759) {
        return interfaceC3759.mo1246(obj, this);
    }

    /* renamed from: ᵡᵘˎʽ, reason: contains not printable characters */
    public final void m2438(InterfaceC3506 interfaceC3506) {
        C0281 c0281 = C0281.f1879;
        if (interfaceC3506 == null) {
            m2442(c0281);
            return;
        }
        interfaceC3506.start();
        InterfaceC0883 interfaceC0883Mo2237 = interfaceC3506.mo2237(this);
        m2442(interfaceC0883Mo2237);
        if (m2426()) {
            interfaceC0883Mo2237.mo1618();
            m2442(c0281);
        }
    }

    /* renamed from: ᵡᵶᵡ, reason: contains not printable characters */
    public final Object m2439(Object obj) {
        Object objM2450;
        do {
            objM2450 = m2450(m2422(), obj);
            if (objM2450 == AbstractC2891.f11215) {
                String str = "Job " + this + " is already complete or completing, but is being completed with " + obj;
                C1411 c1411 = obj instanceof C1411 ? (C1411) obj : null;
                throw new IllegalStateException(str, c1411 != null ? c1411.f5777 : null);
            }
        } while (objM2450 == AbstractC2891.f11214);
        return objM2450;
    }

    @Override // defpackage.InterfaceC3506
    /* renamed from: ᵢˇᵭ */
    public final CancellationException mo2238() {
        CancellationException cancellationException;
        Object objM2422 = m2422();
        if (objM2422 instanceof C3469) {
            Throwable thM7897 = ((C3469) objM2422).m7897();
            if (thM7897 == null) {
                C4069.m8939(this, "Job is still new or active: ");
                return null;
            }
            String strConcat = getClass().getSimpleName().concat(" is cancelling");
            cancellationException = thM7897 instanceof CancellationException ? (CancellationException) thM7897 : null;
            return cancellationException == null ? new JobCancellationException(strConcat, thM7897, this) : cancellationException;
        }
        if (objM2422 instanceof InterfaceC3148) {
            C4069.m8939(this, "Job is still new or active: ");
            return null;
        }
        if (!(objM2422 instanceof C1411)) {
            return new JobCancellationException(getClass().getSimpleName().concat(" has completed normally"), null, this);
        }
        Throwable th = ((C1411) objM2422).f5777;
        cancellationException = th instanceof CancellationException ? (CancellationException) th : null;
        return cancellationException == null ? new JobCancellationException(mo2445(), th, this) : cancellationException;
    }

    /* renamed from: ᵣᵟᵔ, reason: contains not printable characters */
    public final boolean m2440(InterfaceC3148 interfaceC3148, Object obj) {
        Object c0096 = obj instanceof InterfaceC3148 ? new C0096((InterfaceC3148) obj) : obj;
        while (true) {
            f2957.getClass();
            Unsafe unsafe = AbstractC3747.f13986;
            long j = f2958;
            C0577 c0577 = this;
            InterfaceC3148 interfaceC31482 = interfaceC3148;
            if (unsafe.compareAndSwapObject(c0577, j, interfaceC31482, c0096)) {
                c0577.mo2425(obj);
                c0577.m2456(interfaceC31482, obj);
                return true;
            }
            if (unsafe.getObjectVolatile(c0577, j) != interfaceC31482) {
                return false;
            }
            this = c0577;
            interfaceC3148 = interfaceC31482;
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r0v12, types: [java.lang.Throwable] */
    /* JADX WARN: Type inference failed for: r0v8, types: [java.lang.Throwable] */
    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public final Throwable m2441(Object obj) {
        CancellationException cancellationExceptionM7897;
        if (obj == null ? true : obj instanceof Throwable) {
            Throwable th = (Throwable) obj;
            return th == null ? new JobCancellationException(mo2445(), null, this) : th;
        }
        C0577 c0577 = (C0577) obj;
        Object objM2422 = c0577.m2422();
        if (objM2422 instanceof C3469) {
            cancellationExceptionM7897 = ((C3469) objM2422).m7897();
        } else if (objM2422 instanceof C1411) {
            cancellationExceptionM7897 = ((C1411) objM2422).f5777;
        } else {
            if (objM2422 instanceof InterfaceC3148) {
                C4069.m8939(objM2422, "Cannot be cancelling child in this state: ");
                return null;
            }
            cancellationExceptionM7897 = null;
        }
        CancellationException cancellationException = cancellationExceptionM7897 instanceof CancellationException ? cancellationExceptionM7897 : null;
        return cancellationException == null ? new JobCancellationException("Parent job is ".concat(m2418(objM2422)), cancellationExceptionM7897, c0577) : cancellationException;
    }

    /* renamed from: ᵤᵼˑʠ, reason: contains not printable characters */
    public final void m2442(InterfaceC0883 interfaceC0883) {
        f2956.getClass();
        AbstractC3747.f13986.putObjectVolatile(this, f2959, interfaceC0883);
    }

    /* renamed from: ᵥʩᵩˑ, reason: contains not printable characters */
    public final boolean m2443(InterfaceC3148 interfaceC3148, Throwable th) {
        C2604 c2604M2434 = m2434(interfaceC3148);
        if (c2604M2434 == null) {
            return false;
        }
        C3469 c3469 = new C3469(c2604M2434, th);
        while (true) {
            f2957.getClass();
            Unsafe unsafe = AbstractC3747.f13986;
            long j = f2958;
            C0577 c0577 = this;
            InterfaceC3148 interfaceC31482 = interfaceC3148;
            if (unsafe.compareAndSwapObject(c0577, j, interfaceC31482, c3469)) {
                c0577.m2420(c2604M2434, th);
                return true;
            }
            if (unsafe.getObjectVolatile(c0577, j) != interfaceC31482) {
                return false;
            }
            this = c0577;
            interfaceC3148 = interfaceC31482;
        }
    }

    @Override // defpackage.InterfaceC3506
    /* renamed from: ᵥᵯˎ */
    public void mo2239(CancellationException cancellationException) {
        if (cancellationException == null) {
            cancellationException = new JobCancellationException(mo2445(), null, this);
        }
        mo2447(cancellationException);
    }

    /* renamed from: ᵧـˌᵎ, reason: contains not printable characters */
    public boolean mo2444() {
        return true;
    }

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public String mo2445() {
        return "Job was cancelled";
    }

    /* renamed from: ᵨٴ, reason: contains not printable characters */
    public final boolean m2446(C3469 c3469, C3022 c3022, Object obj) {
        while (ᵭʝʜ.ˑᵱ(c3022.f11654, false, new C1203(this, c3469, c3022, obj)) == C0281.f1879) {
            c3022 = m2417(c3022);
            if (c3022 == null) {
                return false;
            }
        }
        return true;
    }

    /* renamed from: ᵨᵳʝ, reason: contains not printable characters */
    public void mo2447(CancellationException cancellationException) {
        m2452(cancellationException);
    }

    /* renamed from: ᵫᵮʾ, reason: contains not printable characters */
    public String mo2448() {
        return getClass().getSimpleName();
    }

    /* renamed from: ᵮᵠـˌ, reason: contains not printable characters */
    public final Throwable m2449(C3469 c3469, ArrayList arrayList) {
        Object obj;
        Object obj2 = null;
        if (arrayList.isEmpty()) {
            if (c3469.m7899()) {
                return new JobCancellationException(mo2445(), null, this);
            }
            return null;
        }
        int size = arrayList.size();
        int i = 0;
        int i2 = 0;
        while (true) {
            if (i2 >= size) {
                obj = null;
                break;
            }
            obj = arrayList.get(i2);
            i2++;
            if (!(((Throwable) obj) instanceof CancellationException)) {
                break;
            }
        }
        Throwable th = (Throwable) obj;
        if (th != null) {
            return th;
        }
        Throwable th2 = (Throwable) arrayList.get(0);
        if (th2 instanceof TimeoutCancellationException) {
            int size2 = arrayList.size();
            while (true) {
                if (i >= size2) {
                    break;
                }
                Object obj3 = arrayList.get(i);
                i++;
                Throwable th3 = (Throwable) obj3;
                if (th3 != th2 && (th3 instanceof TimeoutCancellationException)) {
                    obj2 = obj3;
                    break;
                }
            }
            Throwable th4 = (Throwable) obj2;
            if (th4 != null) {
                return th4;
            }
        }
        return th2;
    }

    /* renamed from: ᵯٴᵦ */
    public void mo1422(Object obj) {
        mo2453(obj);
    }

    /* renamed from: ᵲᵟ, reason: contains not printable characters */
    public final Object m2450(Object obj, Object obj2) {
        if (!(obj instanceof InterfaceC3148)) {
            return AbstractC2891.f11215;
        }
        if (((obj instanceof C0047) || (obj instanceof AbstractC2594)) && !(obj instanceof C3022) && !(obj2 instanceof C1411)) {
            return m2440((InterfaceC3148) obj, obj2) ? obj2 : AbstractC2891.f11214;
        }
        InterfaceC3148 interfaceC3148 = (InterfaceC3148) obj;
        C2604 c2604M2434 = m2434(interfaceC3148);
        if (c2604M2434 == null) {
            return AbstractC2891.f11214;
        }
        C3469 c3469 = interfaceC3148 instanceof C3469 ? (C3469) interfaceC3148 : null;
        if (c3469 == null) {
            c3469 = new C3469(c2604M2434, null);
        }
        synchronized (c3469) {
            AtomicIntegerFieldUpdater atomicIntegerFieldUpdater = C3469.f13007;
            if (atomicIntegerFieldUpdater.get(c3469) == 1) {
                return AbstractC2891.f11215;
            }
            atomicIntegerFieldUpdater.set(c3469, 1);
            if (c3469 != interfaceC3148) {
                AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = f2957;
                while (!atomicReferenceFieldUpdater.compareAndSet(this, interfaceC3148, c3469)) {
                    if (atomicReferenceFieldUpdater.get(this) != interfaceC3148) {
                        return AbstractC2891.f11214;
                    }
                }
            }
            boolean zM7899 = c3469.m7899();
            C1411 c1411 = obj2 instanceof C1411 ? (C1411) obj2 : null;
            if (c1411 != null) {
                c3469.m7901(c1411.f5777);
            }
            Throwable thM7897 = zM7899 ? null : c3469.m7897();
            if (thM7897 != null) {
                m2420(c2604M2434, thM7897);
            }
            C3022 c3022M2417 = m2417(c2604M2434);
            if (c3022M2417 != null && m2446(c3469, c3022M2417, obj2)) {
                return AbstractC2891.f11216;
            }
            c2604M2434.m10483(new C2746(2), 2);
            C3022 c3022M24172 = m2417(c2604M2434);
            return (c3022M24172 == null || !m2446(c3469, c3022M24172, obj2)) ? m2421(c3469, obj2) : AbstractC2891.f11216;
        }
    }

    @Override // defpackage.InterfaceC3506
    /* renamed from: ᵳᵹᵺˋ */
    public final InterfaceC3451 mo2240(boolean z, boolean z2, ᵶʔᵢˊ r3) {
        return m2432(z2, z ? new C1366(r3) : new C3197(r3));
    }

    /* renamed from: ᵶʔᵢˊ, reason: contains not printable characters */
    public final InterfaceC0883 m2451() {
        f2956.getClass();
        return (InterfaceC0883) AbstractC3747.f13986.getObjectVolatile(this, f2959);
    }

    @Override // defpackage.InterfaceC3506
    /* renamed from: ᵷᵱ */
    public final Object mo2241(AbstractC1989 abstractC1989) {
        Object objM2422;
        C3637 c3637;
        do {
            objM2422 = m2422();
            boolean z = objM2422 instanceof InterfaceC3148;
            c3637 = C3637.f13536;
            if (!z) {
                ᵭʝʜ.ˌᵜᵹᵩ(abstractC1989.mo2135());
                return c3637;
            }
        } while (m2423(objM2422) < 0);
        C4385 c4385 = new C4385(1, ᵱᵞᵪ.ᵞʡ(abstractC1989));
        c4385.m9415();
        c4385.m9401(new C3033(2, ᵭʝʜ.ˑᵱ(this, true, new C0222(c4385))));
        Object objM9405 = c4385.m9405();
        EnumC3346 enumC3346 = EnumC3346.f12524;
        if (objM9405 != enumC3346) {
            objM9405 = c3637;
        }
        return objM9405 == enumC3346 ? objM9405 : c3637;
    }

    /* JADX WARN: Code restructure failed: missing block: B:28:0x0059, code lost:
    
        r0 = r8;
     */
    /* JADX WARN: Removed duplicated region for block: B:18:0x003c A[PHI: r0
      0x003c: PHI (r0v1 java.lang.Object) = (r0v0 java.lang.Object), (r0v9 java.lang.Object) binds: [B:3:0x0008, B:16:0x0038] A[DONT_GENERATE, DONT_INLINE]] */
    /* renamed from: ᵸʓᵠ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean m2452(java.lang.Object r8) {
        /*
            Method dump skipped, instructions count: 217
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C0577.m2452(java.lang.Object):boolean");
    }

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public void mo2453(Object obj) {
    }

    /* renamed from: ᵺʙ, reason: contains not printable characters */
    public boolean mo2454() {
        return this instanceof C2138;
    }

    /* renamed from: ᵺᵠ, reason: contains not printable characters */
    public final void m2455(AbstractC2594 abstractC2594) {
        C0577 c0577;
        while (true) {
            Object objM2422 = this.m2422();
            if (!(objM2422 instanceof AbstractC2594)) {
                if (!(objM2422 instanceof InterfaceC3148) || ((InterfaceC3148) objM2422).mo1090() == null) {
                    return;
                }
                abstractC2594.m10489();
                return;
            }
            if (objM2422 != abstractC2594) {
                return;
            }
            while (true) {
                f2957.getClass();
                Unsafe unsafe = AbstractC3747.f13986;
                long j = f2958;
                c0577 = this;
                if (unsafe.compareAndSwapObject(c0577, j, objM2422, AbstractC2891.f11212)) {
                    return;
                }
                if (unsafe.getObjectVolatile(c0577, j) != objM2422) {
                    break;
                } else {
                    this = c0577;
                }
            }
            this = c0577;
        }
    }

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public final void m2456(InterfaceC3148 interfaceC3148, Object obj) {
        InterfaceC0883 interfaceC0883M2451 = m2451();
        if (interfaceC0883M2451 != null) {
            interfaceC0883M2451.mo1618();
            m2442(C0281.f1879);
        }
        CompletionHandlerException completionHandlerException = null;
        C1411 c1411 = obj instanceof C1411 ? (C1411) obj : null;
        Throwable th = c1411 != null ? c1411.f5777 : null;
        if (interfaceC3148 instanceof AbstractC2594) {
            try {
                ((AbstractC2594) interfaceC3148).mo1526(th);
                return;
            } catch (Throwable th2) {
                mo2435(new CompletionHandlerException("Exception in completion handler " + interfaceC3148 + " for " + this, th2));
                return;
            }
        }
        C2604 c2604Mo1090 = interfaceC3148.mo1090();
        if (c2604Mo1090 != null) {
            c2604Mo1090.m10483(new C2746(1), 1);
            for (C5029 c5029M10485 = (C5029) c2604Mo1090.m10491(); !ᵲᵝᵪ.ᵹᵝᵶ(c5029M10485, c2604Mo1090); c5029M10485 = c5029M10485.m10485()) {
                if (c5029M10485 instanceof AbstractC2594) {
                    try {
                        ((AbstractC2594) c5029M10485).mo1526(th);
                    } catch (Throwable th3) {
                        if (completionHandlerException != null) {
                            ᵳـᵔʤ.ᵴᵳ(completionHandlerException, th3);
                        } else {
                            completionHandlerException = new CompletionHandlerException("Exception in completion handler " + c5029M10485 + " for " + this, th3);
                        }
                    }
                }
            }
            if (completionHandlerException != null) {
                mo2435(completionHandlerException);
            }
        }
    }

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public boolean mo2457(Throwable th) {
        if (th instanceof CancellationException) {
            return true;
        }
        return m2452(th) && mo2444();
    }

    /* renamed from: ﾞⁱ, reason: contains not printable characters */
    public boolean mo2458(Throwable th) {
        return false;
    }
}
