package j$.util.concurrent;

/* JADX INFO: compiled from: r8-map-id-da1bda724d8b26dc30f90d2ccf434f42461d6c82e7dbdeb074f412e5504de99c */
/* JADX INFO: loaded from: classes2.dex */
public class o {
    public k[] a;
    public k b = null;
    public n c;
    public n d;
    public int e;
    public int f;
    public int g;
    public final int h;

    public o(k[] kVarArr, int i, int i2, int i3) {
        this.a = kVarArr;
        this.h = i;
        this.e = i2;
        this.f = i2;
        this.g = i3;
    }

    /* JADX WARN: Removed duplicated region for block: B:57:0x0097 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:60:0x005f A[SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final k a() {
        k[] kVarArr;
        int length;
        int i;
        n nVar;
        k kVar = this.b;
        if (kVar != null) {
            kVar = kVar.d;
        }
        while (kVar == null) {
            if (this.f >= this.g || (kVarArr = this.a) == null || (length = kVarArr.length) <= (i = this.e) || i < 0) {
                this.b = null;
                return null;
            }
            k kVarK = ConcurrentHashMap.k(kVarArr, i);
            if (kVarK == null || kVarK.a >= 0) {
                kVar = kVarK;
                if (this.c == null) {
                    while (true) {
                        nVar = this.c;
                        if (nVar == null) {
                            break;
                        }
                        int i2 = this.e;
                        int i3 = nVar.a;
                        int i4 = i2 + i3;
                        this.e = i4;
                        if (i4 < length) {
                            break;
                        }
                        this.e = nVar.b;
                        this.a = nVar.c;
                        nVar.c = null;
                        n nVar2 = nVar.d;
                        nVar.d = this.d;
                        this.c = nVar2;
                        this.d = nVar;
                        length = i3;
                    }
                    if (nVar == null) {
                        int i5 = this.e + this.h;
                        this.e = i5;
                        if (i5 >= length) {
                            int i6 = this.f + 1;
                            this.f = i6;
                            this.e = i6;
                        }
                    }
                } else {
                    int i7 = i + this.h;
                    this.e = i7;
                    if (i7 >= length) {
                        int i8 = this.f + 1;
                        this.f = i8;
                        this.e = i8;
                    }
                }
            } else if (kVarK instanceof g) {
                this.a = ((g) kVarK).e;
                n nVar3 = this.d;
                if (nVar3 != null) {
                    this.d = nVar3.d;
                } else {
                    nVar3 = new n();
                }
                nVar3.c = kVarArr;
                nVar3.a = length;
                nVar3.b = i;
                nVar3.d = this.c;
                this.c = nVar3;
                kVar = null;
            } else {
                kVar = kVarK instanceof p ? ((p) kVarK).f : null;
                if (this.c == null) {
                }
            }
        }
        this.b = kVar;
        return kVar;
    }
}
