package o;

import com.google.android.gms.common.api.Api;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.An, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C0013An extends Thread {
    public static final /* synthetic */ AtomicIntegerFieldUpdater t = AtomicIntegerFieldUpdater.newUpdater(C0013An.class, "workerCtl$volatile");
    private volatile int indexInArray;
    public final Bm0 l;
    public final B10 m;
    public int n;
    private volatile Object nextParkedWorker;

    /* renamed from: o, reason: collision with root package name */
    public long f46o;
    public long p;
    public int q;
    public boolean r;
    public final /* synthetic */ ExecutorC0039Bn s;
    private volatile /* synthetic */ int workerCtl$volatile;

    public C0013An(ExecutorC0039Bn executorC0039Bn, int i) {
        this.s = executorC0039Bn;
        setDaemon(true);
        setContextClassLoader(ExecutorC0039Bn.class.getClassLoader());
        this.l = new Bm0();
        this.m = new B10();
        this.n = 4;
        this.nextParkedWorker = ExecutorC0039Bn.v;
        int iNanoTime = (int) System.nanoTime();
        this.q = iNanoTime == 0 ? 42 : iNanoTime;
        f(i);
    }

    /* JADX WARN: Code restructure failed: missing block: B:20:0x003f, code lost:
    
        r11 = o.Bm0.d.get(r9);
        r0 = o.Bm0.c.get(r9);
     */
    /* JADX WARN: Code restructure failed: missing block: B:21:0x004b, code lost:
    
        if (r11 == r0) goto L68;
     */
    /* JADX WARN: Code restructure failed: missing block: B:23:0x0053, code lost:
    
        if (o.Bm0.e.get(r9) != 0) goto L25;
     */
    /* JADX WARN: Code restructure failed: missing block: B:25:0x0056, code lost:
    
        r0 = r0 - 1;
        r1 = r9.c(r0, true);
     */
    /* JADX WARN: Code restructure failed: missing block: B:26:0x005c, code lost:
    
        if (r1 == null) goto L71;
     */
    /* JADX WARN: Code restructure failed: missing block: B:27:0x005e, code lost:
    
        r7 = r1;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final o.Nc0 a(boolean r11) {
        /*
            r10 = this;
            int r0 = r10.n
            o.Bn r2 = r10.s
            r7 = 0
            r8 = 1
            o.Bm0 r9 = r10.l
            if (r0 != r8) goto Lc
            goto L82
        Lc:
            java.util.concurrent.atomic.AtomicLongFieldUpdater r0 = o.ExecutorC0039Bn.t
        Le:
            long r3 = r0.get(r2)
            r5 = 9223367638808264704(0x7ffffc0000000000, double:NaN)
            long r5 = r5 & r3
            r1 = 42
            long r5 = r5 >> r1
            int r1 = (int) r5
            if (r1 != 0) goto L71
            r9.getClass()
        L21:
            java.util.concurrent.atomic.AtomicReferenceFieldUpdater r11 = o.Bm0.b
            java.lang.Object r0 = r11.get(r9)
            o.Nc0 r0 = (o.Nc0) r0
            if (r0 != 0) goto L2c
            goto L3f
        L2c:
            boolean r1 = r0.m
            if (r1 != r8) goto L3f
        L30:
            boolean r1 = r11.compareAndSet(r9, r0, r7)
            if (r1 == 0) goto L38
            r7 = r0
            goto L5f
        L38:
            java.lang.Object r1 = r11.get(r9)
            if (r1 == r0) goto L30
            goto L21
        L3f:
            java.util.concurrent.atomic.AtomicIntegerFieldUpdater r11 = o.Bm0.d
            int r11 = r11.get(r9)
            java.util.concurrent.atomic.AtomicIntegerFieldUpdater r0 = o.Bm0.c
            int r0 = r0.get(r9)
        L4b:
            if (r11 == r0) goto L5f
            java.util.concurrent.atomic.AtomicIntegerFieldUpdater r1 = o.Bm0.e
            int r1 = r1.get(r9)
            if (r1 != 0) goto L56
            goto L5f
        L56:
            int r0 = r0 + (-1)
            o.Nc0 r1 = r9.c(r0, r8)
            if (r1 == 0) goto L4b
            r7 = r1
        L5f:
            if (r7 != 0) goto L70
            o.TD r11 = r2.q
            java.lang.Object r11 = r11.d()
            o.Nc0 r11 = (o.Nc0) r11
            if (r11 != 0) goto L6f
            o.Nc0 r11 = r10.i(r8)
        L6f:
            return r11
        L70:
            return r7
        L71:
            r5 = 4398046511104(0x40000000000, double:2.1729236899484E-311)
            long r5 = r3 - r5
            java.util.concurrent.atomic.AtomicLongFieldUpdater r1 = o.ExecutorC0039Bn.t
            boolean r1 = r1.compareAndSet(r2, r3, r5)
            if (r1 == 0) goto Le
            r10.n = r8
        L82:
            if (r11 == 0) goto Lb6
            int r11 = r2.l
            int r11 = r11 * 2
            int r11 = r10.d(r11)
            if (r11 != 0) goto L8f
            goto L90
        L8f:
            r8 = 0
        L90:
            if (r8 == 0) goto L99
            o.Nc0 r11 = r10.e()
            if (r11 == 0) goto L99
            return r11
        L99:
            r9.getClass()
            java.util.concurrent.atomic.AtomicReferenceFieldUpdater r11 = o.Bm0.b
            java.lang.Object r11 = r11.getAndSet(r9, r7)
            o.Nc0 r11 = (o.Nc0) r11
            if (r11 != 0) goto Laa
            o.Nc0 r11 = r9.b()
        Laa:
            if (r11 == 0) goto Lad
            return r11
        Lad:
            if (r8 != 0) goto Lbd
            o.Nc0 r11 = r10.e()
            if (r11 == 0) goto Lbd
            return r11
        Lb6:
            o.Nc0 r11 = r10.e()
            if (r11 == 0) goto Lbd
            return r11
        Lbd:
            r11 = 3
            o.Nc0 r11 = r10.i(r11)
            return r11
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C0013An.a(boolean):o.Nc0");
    }

    public final int b() {
        return this.indexInArray;
    }

    public final Object c() {
        return this.nextParkedWorker;
    }

    public final int d(int i) {
        int i2 = this.q;
        int i3 = i2 ^ (i2 << 13);
        int i4 = i3 ^ (i3 >> 17);
        int i5 = i4 ^ (i4 << 5);
        this.q = i5;
        int i6 = i - 1;
        return (i6 & i) == 0 ? i5 & i6 : (i5 & Api.BaseClientBuilder.API_PRIORITY_OTHER) % i;
    }

    public final Nc0 e() {
        int iD = d(2);
        ExecutorC0039Bn executorC0039Bn = this.s;
        if (iD == 0) {
            Nc0 nc0 = (Nc0) executorC0039Bn.p.d();
            return nc0 != null ? nc0 : (Nc0) executorC0039Bn.q.d();
        }
        Nc0 nc02 = (Nc0) executorC0039Bn.q.d();
        return nc02 != null ? nc02 : (Nc0) executorC0039Bn.p.d();
    }

    public final void f(int i) {
        StringBuilder sb = new StringBuilder();
        sb.append(this.s.f58o);
        sb.append("-worker-");
        sb.append(i == 0 ? "TERMINATED" : String.valueOf(i));
        setName(sb.toString());
        this.indexInArray = i;
    }

    public final void g(Object obj) {
        this.nextParkedWorker = obj;
    }

    public final boolean h(int i) {
        int i2 = this.n;
        boolean z = i2 == 1;
        if (z) {
            ExecutorC0039Bn.t.addAndGet(this.s, 4398046511104L);
        }
        if (i2 != i) {
            this.n = i;
        }
        return z;
    }

    /* JADX WARN: Code restructure failed: missing block: B:25:0x006b, code lost:
    
        r7 = r4;
     */
    /* JADX WARN: Code restructure failed: missing block: B:42:0x009f, code lost:
    
        r7 = -2;
        r5 = r4;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final o.Nc0 i(int r26) {
        /*
            Method dump skipped, instructions count: 259
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C0013An.i(int):o.Nc0");
    }

    /* JADX WARN: Code restructure failed: missing block: B:124:0x0004, code lost:
    
        continue;
     */
    @Override // java.lang.Thread, java.lang.Runnable
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void run() {
        /*
            Method dump skipped, instructions count: 401
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C0013An.run():void");
    }
}
