package g;

import g.y;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Iterator;
import java.util.concurrent.ExecutorService;
import javax.annotation.Nullable;

/* JADX INFO: loaded from: classes.dex */
public final class l {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    @Nullable
    public ExecutorService f6435a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Deque<y.b> f6436b = new ArrayDeque();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Deque<y.b> f6437c = new ArrayDeque();

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final Deque<y> f6438d = new ArrayDeque();

    public final <T> void a(Deque<T> deque, T t) {
        synchronized (this) {
            if (!deque.remove(t)) {
                throw new AssertionError("Call wasn't in-flight!");
            }
        }
        b();
    }

    /* JADX WARN: Removed duplicated region for block: B:25:0x0054  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean b() {
        /*
            r15 = this;
            java.util.ArrayList r0 = new java.util.ArrayList
            r0.<init>()
            monitor-enter(r15)
            java.util.Deque<g.y$b> r1 = r15.f6436b     // Catch: java.lang.Throwable -> Lc5
            java.util.Iterator r1 = r1.iterator()     // Catch: java.lang.Throwable -> Lc5
        Lc:
            boolean r2 = r1.hasNext()     // Catch: java.lang.Throwable -> Lc5
            if (r2 == 0) goto L37
            java.lang.Object r2 = r1.next()     // Catch: java.lang.Throwable -> Lc5
            g.y$b r2 = (g.y.b) r2     // Catch: java.lang.Throwable -> Lc5
            java.util.Deque<g.y$b> r3 = r15.f6437c     // Catch: java.lang.Throwable -> Lc5
            int r3 = r3.size()     // Catch: java.lang.Throwable -> Lc5
            r4 = 64
            if (r3 < r4) goto L23
            goto L37
        L23:
            int r3 = r15.c(r2)     // Catch: java.lang.Throwable -> Lc5
            r4 = 5
            if (r3 < r4) goto L2b
            goto Lc
        L2b:
            r1.remove()     // Catch: java.lang.Throwable -> Lc5
            r0.add(r2)     // Catch: java.lang.Throwable -> Lc5
            java.util.Deque<g.y$b> r3 = r15.f6437c     // Catch: java.lang.Throwable -> Lc5
            r3.add(r2)     // Catch: java.lang.Throwable -> Lc5
            goto Lc
        L37:
            monitor-enter(r15)     // Catch: java.lang.Throwable -> Lc5
            java.util.Deque<g.y$b> r1 = r15.f6437c     // Catch: java.lang.Throwable -> Lc2
            int r1 = r1.size()     // Catch: java.lang.Throwable -> Lc2
            java.util.Deque<g.y> r2 = r15.f6438d     // Catch: java.lang.Throwable -> Lc2
            int r2 = r2.size()     // Catch: java.lang.Throwable -> Lc2
            int r1 = r1 + r2
            monitor-exit(r15)     // Catch: java.lang.Throwable -> Lc5
            r2 = 0
            if (r1 <= 0) goto L4b
            r1 = 1
            goto L4c
        L4b:
            r1 = r2
        L4c:
            monitor-exit(r15)     // Catch: java.lang.Throwable -> Lc5
            int r3 = r0.size()
            r4 = r2
        L52:
            if (r4 >= r3) goto Lc1
            java.lang.Object r5 = r0.get(r4)
            g.y$b r5 = (g.y.b) r5
            monitor-enter(r15)
            java.util.concurrent.ExecutorService r6 = r15.f6435a     // Catch: java.lang.Throwable -> Lbe
            if (r6 != 0) goto L7d
            java.util.concurrent.ThreadPoolExecutor r6 = new java.util.concurrent.ThreadPoolExecutor     // Catch: java.lang.Throwable -> Lbe
            r8 = 0
            r9 = 2147483647(0x7fffffff, float:NaN)
            r10 = 60
            java.util.concurrent.TimeUnit r12 = java.util.concurrent.TimeUnit.SECONDS     // Catch: java.lang.Throwable -> Lbe
            java.util.concurrent.SynchronousQueue r13 = new java.util.concurrent.SynchronousQueue     // Catch: java.lang.Throwable -> Lbe
            r13.<init>()     // Catch: java.lang.Throwable -> Lbe
            java.lang.String r7 = "OkHttp Dispatcher"
            byte[] r14 = g.i0.c.f6154a     // Catch: java.lang.Throwable -> Lbe
            g.i0.d r14 = new g.i0.d     // Catch: java.lang.Throwable -> Lbe
            r14.<init>(r7, r2)     // Catch: java.lang.Throwable -> Lbe
            r7 = r6
            r7.<init>(r8, r9, r10, r12, r13, r14)     // Catch: java.lang.Throwable -> Lbe
            r15.f6435a = r6     // Catch: java.lang.Throwable -> Lbe
        L7d:
            java.util.concurrent.ExecutorService r6 = r15.f6435a     // Catch: java.lang.Throwable -> Lbe
            monitor-exit(r15)
            java.util.Objects.requireNonNull(r5)
            r6.execute(r5)     // Catch: java.lang.Throwable -> L87 java.util.concurrent.RejectedExecutionException -> L89
            goto Laf
        L87:
            r0 = move-exception
            goto Lb2
        L89:
            r6 = move-exception
            java.io.InterruptedIOException r7 = new java.io.InterruptedIOException     // Catch: java.lang.Throwable -> L87
            java.lang.String r8 = "executor rejected"
            r7.<init>(r8)     // Catch: java.lang.Throwable -> L87
            r7.initCause(r6)     // Catch: java.lang.Throwable -> L87
            g.y r6 = g.y.this     // Catch: java.lang.Throwable -> L87
            g.n r6 = r6.f6512e     // Catch: java.lang.Throwable -> L87
            java.util.Objects.requireNonNull(r6)     // Catch: java.lang.Throwable -> L87
            g.e r6 = r5.f6516c     // Catch: java.lang.Throwable -> L87
            g.y r8 = g.y.this     // Catch: java.lang.Throwable -> L87
            j.t$a r6 = (j.t.a) r6     // Catch: java.lang.Throwable -> L87
            r6.a(r8, r7)     // Catch: java.lang.Throwable -> L87
            g.y r6 = g.y.this
            g.w r6 = r6.f6509b
            g.l r6 = r6.f6492d
            java.util.Deque<g.y$b> r7 = r6.f6437c
            r6.a(r7, r5)
        Laf:
            int r4 = r4 + 1
            goto L52
        Lb2:
            g.y r1 = g.y.this
            g.w r1 = r1.f6509b
            g.l r1 = r1.f6492d
            java.util.Deque<g.y$b> r2 = r1.f6437c
            r1.a(r2, r5)
            throw r0
        Lbe:
            r0 = move-exception
            monitor-exit(r15)
            throw r0
        Lc1:
            return r1
        Lc2:
            r0 = move-exception
            monitor-exit(r15)     // Catch: java.lang.Throwable -> Lc5
            throw r0     // Catch: java.lang.Throwable -> Lc5
        Lc5:
            r0 = move-exception
            monitor-exit(r15)     // Catch: java.lang.Throwable -> Lc5
            throw r0
        */
        throw new UnsupportedOperationException("Method not decompiled: g.l.b():boolean");
    }

    public final int c(y.b bVar) {
        Iterator<y.b> it = this.f6437c.iterator();
        int i2 = 0;
        while (it.hasNext()) {
            y yVar = y.this;
            if (!yVar.f6514g && yVar.f6513f.f6518a.f6457e.equals(y.this.f6513f.f6518a.f6457e)) {
                i2++;
            }
        }
        return i2;
    }
}
