package p060t1;

import kotlinx.coroutines.internal.C1352a0;
import kotlinx.coroutines.internal.C1360d;
import p006b1.C0476f;
import p006b1.C0479g;
import p006b1.C0484l;
import p012d1.InterfaceC0629d;
import p012d1.InterfaceC0633f;

/* renamed from: t1.g0 */
/* loaded from: classes.dex */
public final class C1677g0 {
    /* renamed from: a */
    public static final <T> void m607a(AbstractC1674f0<? super T> abstractC1674f0, int i) {
        InterfaceC0629d<? super T> mo597b = abstractC1674f0.mo597b();
        boolean z = i == 4;
        if (z || !(mo597b instanceof C1360d) || m606b(i) != m606b(abstractC1674f0.f3901f)) {
            m604d(abstractC1674f0, mo597b, z);
            return;
        }
        AbstractC1717u abstractC1717u = ((C1360d) mo597b).f3024g;
        InterfaceC0633f mo595d = mo597b.mo595d();
        if (abstractC1717u.mo477f(mo595d)) {
            abstractC1717u.mo478d(mo595d, abstractC1674f0);
        } else {
            m603e(abstractC1674f0);
        }
    }

    /* renamed from: b */
    public static final boolean m606b(int i) {
        return i == 1 || i == 2;
    }

    /* renamed from: c */
    public static final boolean m605c(int i) {
        return i == 2;
    }

    /* renamed from: d */
    public static final <T> void m604d(AbstractC1674f0<? super T> abstractC1674f0, InterfaceC0629d<? super T> interfaceC0629d, boolean z) {
        Object mo594e;
        Object mo592h = abstractC1674f0.mo592h();
        Throwable mo596c = abstractC1674f0.mo596c(mo592h);
        if (mo596c != null) {
            C0476f.C0477a c0477a = C0476f.f1684d;
            mo594e = C0479g.m3622a(mo596c);
        } else {
            C0476f.C0477a c0477a2 = C0476f.f1684d;
            mo594e = abstractC1674f0.mo594e(mo592h);
        }
        Object m3626a = C0476f.m3626a(mo594e);
        if (!z) {
            interfaceC0629d.mo591i(m3626a);
            return;
        }
        C1360d c1360d = (C1360d) interfaceC0629d;
        InterfaceC0629d<T> interfaceC0629d2 = c1360d.f3025h;
        Object obj = c1360d.f3027j;
        InterfaceC0633f mo595d = interfaceC0629d2.mo595d();
        Object m1569c = C1352a0.m1569c(mo595d, obj);
        C1695l1<?> m515c = m1569c != C1352a0.f3012a ? C1715t.m515c(interfaceC0629d2, mo595d, m1569c) : null;
        try {
            c1360d.f3025h.mo591i(m3626a);
            C0484l c0484l = C0484l.f1690a;
        } finally {
            if (m515c == null || m515c.m539m0()) {
                C1352a0.m1571a(mo595d, m1569c);
            }
        }
    }

    /* renamed from: e */
    public static final void m603e(AbstractC1674f0<?> abstractC1674f0) {
        AbstractC1689k0 m573a = C1687j1.f3914a.m573a();
        if (m573a.m565t()) {
            m573a.m568p(abstractC1674f0);
            return;
        }
        m573a.m567r(true);
        try {
            m604d(abstractC1674f0, abstractC1674f0.mo597b(), true);
            do {
            } while (m573a.m563v());
        } finally {
            try {
            } finally {
            }
        }
    }
}