package defpackage;

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

/* JADX INFO: renamed from: ᵢˏ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C3276 {

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

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

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

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

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

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public final C2861 f12563;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public int f12564;

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final C5510[] f12565;

    public C3276(int i, InterfaceC1841 interfaceC1841) {
        this.f12562 = i;
        this.f12558 = interfaceC1841;
        this.f12565 = new C5510[i];
        int i2 = AbstractC3387.f13023;
        this.f12563 = new C2861(i);
        this.f12559 = new C4349(i);
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final void m7509() {
        ReentrantLock reentrantLock = this.f12560;
        reentrantLock.lock();
        try {
            this.f12561 = true;
            for (C5510 c5510 : this.f12565) {
                if (c5510 != null) {
                    c5510.close();
                }
            }
        } finally {
            reentrantLock.unlock();
        }
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final void m7510(StringBuilder sb) {
        C4349 c4349 = this.f12559;
        ReentrantLock reentrantLock = this.f12560;
        reentrantLock.lock();
        try {
            C0970 c0970 = ᵽˊᵘᵬ.ᵷᵺʾᵖ();
            int iM9371 = c4349.m9371();
            for (int i = 0; i < iM9371; i++) {
                if (i < 0 || i >= c4349.m9371()) {
                    throw new ArrayIndexOutOfBoundsException();
                }
                c0970.add(((Object[]) c4349.f16540)[(c4349.f16538 + i) & c4349.f16542]);
            }
            C0970 c09702 = ᵽˊᵘᵬ.ᵲᵶᵳˈ(c0970);
            sb.append('\t' + toString() + " (");
            sb.append("capacity=" + this.f12562 + ", ");
            StringBuilder sb2 = new StringBuilder();
            sb2.append("permits=");
            C2861 c2861 = this.f12563;
            c2861.getClass();
            sb2.append(Math.max(C1461.f5937.get(c2861), 0));
            sb2.append(", ");
            sb.append(sb2.toString());
            sb.append("queue=(size=" + c09702.mo3166() + ")[" + AbstractC4126.m8996(c09702, null, null, null, null, 63) + "], ");
            sb.append(")");
            sb.append('\n');
            C5510[] c5510Arr = this.f12565;
            int length = c5510Arr.length;
            int i2 = 0;
            for (int i3 = 0; i3 < length; i3++) {
                C5510 c5510 = c5510Arr[i3];
                i2++;
                StringBuilder sb3 = new StringBuilder();
                sb3.append("\t\t[");
                sb3.append(i2);
                sb3.append("] - ");
                sb3.append(c5510 != null ? c5510.f20805.toString() : null);
                sb.append(sb3.toString());
                sb.append('\n');
                if (c5510 != null) {
                    c5510.m11145(sb);
                }
            }
            reentrantLock.unlock();
        } catch (Throwable th) {
            reentrantLock.unlock();
            throw th;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object m7511(AbstractC3500 abstractC3500) throws DispatchException {
        C1336 c1336;
        if (abstractC3500 instanceof C1336) {
            c1336 = (C1336) abstractC3500;
            int i = c1336.f5566;
            if ((i & Integer.MIN_VALUE) != 0) {
                c1336.f5566 = i - Integer.MIN_VALUE;
            } else {
                c1336 = new C1336(this, abstractC3500);
            }
        }
        Object obj = c1336.f5568;
        int i2 = c1336.f5566;
        if (i2 == 0) {
            ᵟˌᵫ.ˊˌˊ(obj);
            c1336.f5567 = this;
            c1336.f5566 = 1;
            Object objM4183 = this.f12563.m4183(c1336);
            EnumC0111 enumC0111 = EnumC0111.f1384;
            if (objM4183 == enumC0111) {
                return enumC0111;
            }
        } else {
            if (i2 != 1) {
                ᵕᵩʽᵲ.ᵪᵹᵥᵻ("call to 'resume' before 'invoke' with coroutine");
                return null;
            }
            this = c1336.f5567;
            ᵟˌᵫ.ˊˌˊ(obj);
        }
        try {
            ReentrantLock reentrantLock = this.f12560;
            C4349 c4349 = this.f12559;
            reentrantLock.lock();
            try {
                if (this.f12561) {
                    ˋˀᵧ.ᵸˆˁ(21, "Connection pool is closed");
                    throw null;
                }
                if (c4349.f16538 == c4349.f16539 && this.f12564 < this.f12562) {
                    C5510 c5510 = new C5510((InterfaceC2047) this.f12558.mo1021());
                    C5510[] c5510Arr = this.f12565;
                    int i3 = this.f12564;
                    this.f12564 = i3 + 1;
                    c5510Arr[i3] = c5510;
                    c4349.m9340(c5510);
                }
                int i4 = c4349.f16538;
                if (i4 == c4349.f16539) {
                    throw new ArrayIndexOutOfBoundsException();
                }
                Object[] objArr = (Object[]) c4349.f16540;
                Object obj2 = objArr[i4];
                objArr[i4] = null;
                c4349.f16538 = (i4 + 1) & c4349.f16542;
                return (C5510) obj2;
            } finally {
                reentrantLock.unlock();
            }
        } catch (Throwable th) {
            this.f12563.m4184();
            throw th;
        }
    }
}
