package F3;

import java.io.Serializable;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

/* JADX INFO: renamed from: F3.z, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes3.dex */
public final class C0225z extends AbstractMap implements Serializable {

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public static final Object f1633m = new Object();

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public transient Object f1634a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public transient int[] f1635b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public transient Object[] f1636c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public transient Object[] f1637d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public transient int f1638e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public transient int f1639f;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public transient C0222w f1640j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public transient C0222w f1641k;
    public transient C0224y l;

    public static C0225z a(int i6) {
        C0225z c0225z = new C0225z();
        A4.g.l(i6 >= 0, "Expected size must be >= 0");
        c0225z.f1638e = Math.min(Math.max(i6, 1), 1073741823);
        return c0225z;
    }

    public final Map b() {
        Object obj = this.f1634a;
        if (obj instanceof Map) {
            return (Map) obj;
        }
        return null;
    }

    public final int c() {
        return (1 << (this.f1638e & 31)) - 1;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final void clear() {
        if (g()) {
            return;
        }
        this.f1638e += 32;
        Map mapB = b();
        if (mapB != null) {
            this.f1638e = Math.min(Math.max(size(), 3), 1073741823);
            mapB.clear();
            this.f1634a = null;
            this.f1639f = 0;
            return;
        }
        Arrays.fill(j(), 0, this.f1639f, (Object) null);
        Arrays.fill(k(), 0, this.f1639f, (Object) null);
        Object obj = this.f1634a;
        Objects.requireNonNull(obj);
        if (obj instanceof byte[]) {
            Arrays.fill((byte[]) obj, (byte) 0);
        } else if (obj instanceof short[]) {
            Arrays.fill((short[]) obj, (short) 0);
        } else {
            Arrays.fill((int[]) obj, 0);
        }
        Arrays.fill(i(), 0, this.f1639f, 0);
        this.f1639f = 0;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final boolean containsKey(Object obj) {
        Map mapB = b();
        return mapB != null ? mapB.containsKey(obj) : d(obj) != -1;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final boolean containsValue(Object obj) {
        Map mapB = b();
        if (mapB != null) {
            return mapB.containsValue(obj);
        }
        for (int i6 = 0; i6 < this.f1639f; i6++) {
            if (android.support.v4.media.session.b.n(obj, k()[i6])) {
                return true;
            }
        }
        return false;
    }

    public final int d(Object obj) {
        if (g()) {
            return -1;
        }
        int iT = AbstractC0220u.t(obj);
        int iC = c();
        Object obj2 = this.f1634a;
        Objects.requireNonNull(obj2);
        int iU = AbstractC0220u.u(iT & iC, obj2);
        if (iU == 0) {
            return -1;
        }
        int i6 = ~iC;
        int i7 = iT & i6;
        do {
            int i8 = iU - 1;
            int i9 = i()[i8];
            if ((i9 & i6) == i7 && android.support.v4.media.session.b.n(obj, j()[i8])) {
                return i8;
            }
            iU = i9 & iC;
        } while (iU != 0);
        return -1;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final Set entrySet() {
        C0222w c0222w = this.f1641k;
        if (c0222w != null) {
            return c0222w;
        }
        C0222w c0222w2 = new C0222w(this, 0);
        this.f1641k = c0222w2;
        return c0222w2;
    }

    public final void f(int i6, int i7) {
        Object obj = this.f1634a;
        Objects.requireNonNull(obj);
        int[] iArrI = i();
        Object[] objArrJ = j();
        Object[] objArrK = k();
        int size = size();
        int i8 = size - 1;
        if (i6 >= i8) {
            objArrJ[i6] = null;
            objArrK[i6] = null;
            iArrI[i6] = 0;
            return;
        }
        Object obj2 = objArrJ[i8];
        objArrJ[i6] = obj2;
        objArrK[i6] = objArrK[i8];
        objArrJ[i8] = null;
        objArrK[i8] = null;
        iArrI[i6] = iArrI[i8];
        iArrI[i8] = 0;
        int iT = AbstractC0220u.t(obj2) & i7;
        int iU = AbstractC0220u.u(iT, obj);
        if (iU == size) {
            AbstractC0220u.v(iT, i6 + 1, obj);
            return;
        }
        while (true) {
            int i9 = iU - 1;
            int i10 = iArrI[i9];
            int i11 = i10 & i7;
            if (i11 == size) {
                iArrI[i9] = AbstractC0220u.o(i10, i6 + 1, i7);
                return;
            }
            iU = i11;
        }
    }

    public final boolean g() {
        return this.f1634a == null;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final Object get(Object obj) {
        Map mapB = b();
        if (mapB != null) {
            return mapB.get(obj);
        }
        int iD = d(obj);
        if (iD == -1) {
            return null;
        }
        return k()[iD];
    }

    public final Object h(Object obj) {
        boolean zG = g();
        Object obj2 = f1633m;
        if (!zG) {
            int iC = c();
            Object obj3 = this.f1634a;
            Objects.requireNonNull(obj3);
            int iQ = AbstractC0220u.q(obj, null, iC, obj3, i(), j(), null);
            if (iQ != -1) {
                Object obj4 = k()[iQ];
                f(iQ, iC);
                this.f1639f--;
                this.f1638e += 32;
                return obj4;
            }
        }
        return obj2;
    }

    public final int[] i() {
        int[] iArr = this.f1635b;
        Objects.requireNonNull(iArr);
        return iArr;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final boolean isEmpty() {
        return size() == 0;
    }

    public final Object[] j() {
        Object[] objArr = this.f1636c;
        Objects.requireNonNull(objArr);
        return objArr;
    }

    public final Object[] k() {
        Object[] objArr = this.f1637d;
        Objects.requireNonNull(objArr);
        return objArr;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final Set keySet() {
        C0222w c0222w = this.f1640j;
        if (c0222w != null) {
            return c0222w;
        }
        C0222w c0222w2 = new C0222w(this, 1);
        this.f1640j = c0222w2;
        return c0222w2;
    }

    public final int l(int i6, int i7, int i8, int i9) {
        Object objF = AbstractC0220u.f(i7);
        int i10 = i7 - 1;
        if (i9 != 0) {
            AbstractC0220u.v(i8 & i10, i9 + 1, objF);
        }
        Object obj = this.f1634a;
        Objects.requireNonNull(obj);
        int[] iArrI = i();
        for (int i11 = 0; i11 <= i6; i11++) {
            int iU = AbstractC0220u.u(i11, obj);
            while (iU != 0) {
                int i12 = iU - 1;
                int i13 = iArrI[i12];
                int i14 = ((~i6) & i13) | i11;
                int i15 = i14 & i10;
                int iU2 = AbstractC0220u.u(i15, objF);
                AbstractC0220u.v(i15, iU, objF);
                iArrI[i12] = AbstractC0220u.o(i14, iU2, i10);
                iU = i13 & i6;
            }
        }
        this.f1634a = objF;
        this.f1638e = AbstractC0220u.o(this.f1638e, 32 - Integer.numberOfLeadingZeros(i10), 31);
        return i10;
    }

    /* JADX WARN: Removed duplicated region for block: B:40:0x00eb  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:41:0x00fe -> B:37:0x00e4). Please report as a decompilation issue!!! */
    @Override // java.util.AbstractMap, java.util.Map
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object put(Object obj, Object obj2) {
        int i6;
        int i7 = 32;
        int i8 = 1;
        if (g()) {
            A4.g.t(g(), "Arrays already allocated");
            int i9 = this.f1638e;
            int iMax = Math.max(i9 + 1, 2);
            int iHighestOneBit = Integer.highestOneBit(iMax);
            if (iMax > ((int) (1.0d * ((double) iHighestOneBit))) && (iHighestOneBit = iHighestOneBit << 1) <= 0) {
                iHighestOneBit = 1073741824;
            }
            int iMax2 = Math.max(4, iHighestOneBit);
            this.f1634a = AbstractC0220u.f(iMax2);
            this.f1638e = AbstractC0220u.o(this.f1638e, 32 - Integer.numberOfLeadingZeros(iMax2 - 1), 31);
            this.f1635b = new int[i9];
            this.f1636c = new Object[i9];
            this.f1637d = new Object[i9];
        }
        Map mapB = b();
        if (mapB != null) {
            return mapB.put(obj, obj2);
        }
        int[] iArrI = i();
        Object[] objArrJ = j();
        Object[] objArrK = k();
        int i10 = this.f1639f;
        int i11 = i10 + 1;
        int iT = AbstractC0220u.t(obj);
        int iC = c();
        int i12 = iT & iC;
        Object obj3 = this.f1634a;
        Objects.requireNonNull(obj3);
        int iU = AbstractC0220u.u(i12, obj3);
        if (iU == 0) {
            if (i11 > iC) {
                iC = l(iC, (iC + 1) * (iC < 32 ? 4 : 2), iT, i10);
            } else {
                Object obj4 = this.f1634a;
                Objects.requireNonNull(obj4);
                AbstractC0220u.v(i12, i11, obj4);
            }
            i6 = 1;
        } else {
            int i13 = ~iC;
            int i14 = iT & i13;
            int i15 = 0;
            while (true) {
                int i16 = iU - i8;
                i6 = i8;
                int i17 = iArrI[i16];
                int i18 = i7;
                if ((i17 & i13) == i14 && android.support.v4.media.session.b.n(obj, objArrJ[i16])) {
                    Object obj5 = objArrK[i16];
                    objArrK[i16] = obj2;
                    return obj5;
                }
                int i19 = i17 & iC;
                int i20 = i15 + 1;
                if (i19 != 0) {
                    i15 = i20;
                    iU = i19;
                    i8 = i6;
                    i7 = i18;
                } else {
                    if (i20 >= 9) {
                        LinkedHashMap linkedHashMap = new LinkedHashMap(c() + 1, 1.0f);
                        int i21 = isEmpty() ? -1 : 0;
                        while (i21 >= 0) {
                            linkedHashMap.put(j()[i21], k()[i21]);
                            int i22 = i21 + 1;
                            if (i22 < this.f1639f) {
                                i21 = i22;
                            } else {
                                while (i21 >= 0) {
                                }
                            }
                        }
                        this.f1634a = linkedHashMap;
                        this.f1635b = null;
                        this.f1636c = null;
                        this.f1637d = null;
                        this.f1638e += 32;
                        return linkedHashMap.put(obj, obj2);
                    }
                    if (i11 > iC) {
                        iC = l(iC, (iC + 1) * (iC < i18 ? 4 : 2), iT, i10);
                    } else {
                        iArrI[i16] = AbstractC0220u.o(i17, i11, iC);
                    }
                }
            }
        }
        int length = i().length;
        if (i11 > length) {
            int i23 = i6;
            int iMin = Math.min(1073741823, (Math.max(i23, length >>> 1) + length) | i23);
            if (iMin != length) {
                this.f1635b = Arrays.copyOf(i(), iMin);
                this.f1636c = Arrays.copyOf(j(), iMin);
                this.f1637d = Arrays.copyOf(k(), iMin);
            }
        }
        i()[i10] = AbstractC0220u.o(iT, 0, iC);
        j()[i10] = obj;
        k()[i10] = obj2;
        this.f1639f = i11;
        this.f1638e += 32;
        return null;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final Object remove(Object obj) {
        Map mapB = b();
        if (mapB != null) {
            return mapB.remove(obj);
        }
        Object objH = h(obj);
        if (objH == f1633m) {
            return null;
        }
        return objH;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final int size() {
        Map mapB = b();
        return mapB != null ? mapB.size() : this.f1639f;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final Collection values() {
        C0224y c0224y = this.l;
        if (c0224y != null) {
            return c0224y;
        }
        C0224y c0224y2 = new C0224y(this);
        this.l = c0224y2;
        return c0224y2;
    }
}
