package defpackage;

import java.util.concurrent.locks.ReentrantLock;
import kotlinx.coroutines.TimeoutCancellationException;

/* JADX INFO: renamed from: ᵖٴ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C2422 {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final InterfaceC0778 f9440;

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public final C2861 f9441;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public int f9443;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final int f9444;

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public final C4817[] f9445;

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public final C0920 f9447;

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public boolean f9448;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final ReentrantLock f9442 = new ReentrantLock();

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final C2415 f9446 = new C2415();

    public C2422(int i, InterfaceC0778 interfaceC0778) {
        this.f9444 = i;
        this.f9440 = interfaceC0778;
        this.f9445 = new C4817[i];
        this.f9441 = new C2861(i);
        this.f9447 = new C0920(i);
    }

    /* JADX WARN: Can't wrap try/catch for region: R(11:14|50|48|29|(0)(0)|38|19|44|20|21|(0)(0)) */
    /* JADX WARN: Code restructure failed: missing block: B:26:0x005b, code lost:
    
        r1 = move-exception;
     */
    /* JADX WARN: Code restructure failed: missing block: B:28:0x0060, code lost:
    
        r10 = r10;
        r9 = r9;
        r1 = r0;
        r0 = r1;
     */
    /* JADX WARN: Removed duplicated region for block: B:23:0x0053 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:24:0x0054  */
    /* JADX WARN: Removed duplicated region for block: B:31:0x0069 A[Catch: all -> 0x006d, TryCatch #2 {all -> 0x006d, blocks: (B:29:0x0065, B:31:0x0069, B:35:0x0071, B:39:0x0078), top: B:48:0x0065 }] */
    /* JADX WARN: Removed duplicated region for block: B:34:0x006f  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:24:0x0054 -> B:25:0x0056). Please report as a decompilation issue!!! */
    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object m6147(long j, ᵹˑˆ r9, AbstractC3500 abstractC3500) {
        C5442 c5442;
        C2761 c2761;
        C5442 c54422;
        Throwable th;
        Object obj;
        EnumC0111 enumC0111;
        if (abstractC3500 instanceof C5442) {
            c5442 = (C5442) abstractC3500;
            int i = c5442.f20640;
            if ((i & Integer.MIN_VALUE) != 0) {
                c5442.f20640 = i - Integer.MIN_VALUE;
            } else {
                c5442 = new C5442(this, abstractC3500);
            }
        }
        Object obj2 = c5442.f20635;
        int i2 = c5442.f20640;
        if (i2 == 0) {
            ᵟˌᵫ.ˊˌˊ(obj2);
            C2761 c27612 = new C2761();
            ʽᵦᵺ r1 = new ʽᵦᵺ(c27612, this, (InterfaceC2643) null, 20);
            c5442.f20638 = r9;
            c5442.f20639 = c27612;
            c5442.f20637 = j;
            c5442.f20640 = 1;
            obj = ˀᵳˎᵹ.ˈᵲᵢ(j, r1, c5442);
            enumC0111 = EnumC0111.f1384;
            if (obj != enumC0111) {
            }
        } else {
            if (i2 != 1) {
                ᵕᵩʽᵲ.ᵪᵹᵥᵻ("call to 'resume' before 'invoke' with coroutine");
                return null;
            }
            j = c5442.f20637;
            C2761 c27613 = c5442.f20639;
            ᵹˑˆ r12 = c5442.f20638;
            try {
                ᵟˌᵫ.ˊˌˊ(obj2);
            } catch (Throwable th2) {
                c2761 = c27613;
                r9 = r12;
                c54422 = c5442;
                th = th2;
                if (th instanceof TimeoutCancellationException) {
                }
                c5442 = c54422;
                C2761 c276122 = new C2761();
                ʽᵦᵺ r13 = new ʽᵦᵺ(c276122, this, (InterfaceC2643) null, 20);
                c5442.f20638 = r9;
                c5442.f20639 = c276122;
                c5442.f20637 = j;
                c5442.f20640 = 1;
                obj = ˀᵳˎᵹ.ˈᵲᵢ(j, r13, c5442);
                enumC0111 = EnumC0111.f1384;
                if (obj != enumC0111) {
                }
            }
            c2761 = c27613;
            r9 = r12;
            c54422 = c5442;
            th = null;
            try {
                if (th instanceof TimeoutCancellationException) {
                    r9.mo1021();
                } else {
                    if (th != null) {
                        throw th;
                    }
                    Object obj3 = c2761.f10617;
                    if (obj3 != null) {
                        return obj3;
                    }
                }
                c5442 = c54422;
                C2761 c2761222 = new C2761();
                ʽᵦᵺ r132 = new ʽᵦᵺ(c2761222, this, (InterfaceC2643) null, 20);
                c5442.f20638 = r9;
                c5442.f20639 = c2761222;
                c5442.f20637 = j;
                c5442.f20640 = 1;
                obj = ˀᵳˎᵹ.ˈᵲᵢ(j, r132, c5442);
                enumC0111 = EnumC0111.f1384;
                if (obj != enumC0111) {
                    return enumC0111;
                }
                r12 = r9;
                c27613 = c2761222;
                c2761 = c27613;
                r9 = r12;
                c54422 = c5442;
                th = null;
                if (th instanceof TimeoutCancellationException) {
                }
                c5442 = c54422;
                C2761 c27612222 = new C2761();
                ʽᵦᵺ r1322 = new ʽᵦᵺ(c27612222, this, (InterfaceC2643) null, 20);
                c5442.f20638 = r9;
                c5442.f20639 = c27612222;
                c5442.f20637 = j;
                c5442.f20640 = 1;
                obj = ˀᵳˎᵹ.ˈᵲᵢ(j, r1322, c5442);
                enumC0111 = EnumC0111.f1384;
                if (obj != enumC0111) {
                }
            } catch (Throwable th3) {
                C4817 c4817 = (C4817) c2761.f10617;
                if (c4817 != null) {
                    m6149(c4817);
                }
                throw th3;
            }
        }
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final void m6148() {
        ReentrantLock reentrantLock = this.f9442;
        reentrantLock.lock();
        try {
            this.f9448 = true;
            for (C4817 c4817 : this.f9445) {
                if (c4817 != null) {
                    c4817.close();
                }
            }
        } finally {
            reentrantLock.unlock();
        }
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final void m6149(C4817 c4817) {
        ReentrantLock reentrantLock = this.f9442;
        reentrantLock.lock();
        try {
            this.f9447.addLast(c4817);
            reentrantLock.unlock();
            this.f9441.m4184();
        } catch (Throwable th) {
            reentrantLock.unlock();
            throw th;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:35:0x007c, code lost:
    
        if (r12 == r10) goto L36;
     */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0015  */
    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object m6150(AbstractC3500 abstractC3500) {
        C1944 c1944;
        C0920 c0920 = this.f9447;
        if (abstractC3500 instanceof C1944) {
            c1944 = (C1944) abstractC3500;
            int i = c1944.f7740;
            if ((i & Integer.MIN_VALUE) != 0) {
                c1944.f7740 = i - Integer.MIN_VALUE;
            } else {
                c1944 = new C1944(this, abstractC3500);
            }
        }
        Object obj = c1944.f7738;
        int i2 = c1944.f7740;
        ReentrantLock reentrantLock = this.f9442;
        C2861 c2861 = this.f9441;
        InterfaceC2643 interfaceC2643 = null;
        EnumC0111 enumC0111 = EnumC0111.f1384;
        try {
            try {
                if (i2 == 0) {
                    ᵟˌᵫ.ˊˌˊ(obj);
                    c1944.f7740 = 1;
                    if (c2861.m4183(c1944) != enumC0111) {
                    }
                    return enumC0111;
                }
                if (i2 != 1) {
                    if (i2 != 2) {
                        ᵕᵩʽᵲ.ᵪᵹᵥᵻ("call to 'resume' before 'invoke' with coroutine");
                        return null;
                    }
                    ᵟˌᵫ.ˊˌˊ(obj);
                    C4817 c4817 = (C4817) obj;
                    reentrantLock.lock();
                    try {
                        if (this.f9448) {
                            c4817.close();
                            ˋˀᵧ.ᵸˆˁ(21, "Connection pool is closed");
                            throw null;
                        }
                        C4817[] c4817Arr = this.f9445;
                        int i3 = this.f9443;
                        this.f9443 = i3 + 1;
                        c4817Arr[i3] = c4817;
                        return c4817;
                    } finally {
                        reentrantLock.unlock();
                    }
                }
                ᵟˌᵫ.ˊˌˊ(obj);
                if (this.f9448) {
                    ˋˀᵧ.ᵸˆˁ(21, "Connection pool is closed");
                    throw null;
                }
                if (!c0920.isEmpty()) {
                    return c0920.removeLast();
                }
                reentrantLock.unlock();
                if (this.f9443 >= this.f9444) {
                    throw new IllegalStateException("Check failed.");
                }
                C2415 c2415 = this.f9446;
                C4974 c4974 = new C4974(this, interfaceC2643, 3);
                c1944.f7740 = 2;
                obj = ᵽˊᵘᵬ.ᵔᵖᵹᵫ(c2415, c4974, c1944);
            } catch (Throwable th) {
                throw th;
            }
            reentrantLock.lock();
        } catch (Throwable th2) {
            c2861.m4184();
            throw th2;
        }
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final void m6151(StringBuilder sb) {
        C0920 c0920 = this.f9447;
        ReentrantLock reentrantLock = this.f9442;
        reentrantLock.lock();
        try {
            C0970 c0970 = ᵽˊᵘᵬ.ᵷᵺʾᵖ();
            int i = c0920.f4034;
            for (int i2 = 0; i2 < i; i2++) {
                c0970.add(c0920.get(i2));
            }
            C0970 c09702 = ᵽˊᵘᵬ.ᵲᵶᵳˈ(c0970);
            sb.append("\t" + toString() + " (");
            sb.append("capacity=" + this.f9444 + ", ");
            C2861 c2861 = this.f9441;
            c2861.getClass();
            sb.append("permits=" + Math.max(C1461.f5937.get(c2861), 0) + ", ");
            sb.append("queue=(size=" + c09702.mo3166() + ")[" + AbstractC4126.m8996(c09702, null, null, null, null, 63) + "]");
            sb.append(")");
            sb.append('\n');
            C4817[] c4817Arr = this.f9445;
            int length = c4817Arr.length;
            int i3 = 0;
            for (int i4 = 0; i4 < length; i4++) {
                C4817 c4817 = c4817Arr[i4];
                i3++;
                sb.append("\t\t[" + i3 + "] - " + (c4817 != null ? c4817.f18318.toString() : null));
                sb.append('\n');
                if (c4817 != null) {
                    c4817.m10044(sb);
                }
            }
            reentrantLock.unlock();
        } catch (Throwable th) {
            reentrantLock.unlock();
            throw th;
        }
    }
}
