package o;

import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.k90, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1650k90 extends AbstractMap {
    public static final /* synthetic */ int q = 0;
    public List l;
    public Map m;
    public boolean n;

    /* renamed from: o, reason: collision with root package name */
    public volatile C1364h9 f608o;
    public Map p;

    public static C1650k90 f() {
        C1650k90 c1650k90 = new C1650k90();
        c1650k90.l = Collections.EMPTY_LIST;
        Map map = Collections.EMPTY_MAP;
        c1650k90.m = map;
        c1650k90.p = map;
        return c1650k90;
    }

    /* JADX WARN: Removed duplicated region for block: B:13:0x0024  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final int a(java.lang.Comparable r5) {
        /*
            r4 = this;
            java.util.List r0 = r4.l
            int r0 = r0.size()
            int r1 = r0 + (-1)
            if (r1 < 0) goto L21
            java.util.List r2 = r4.l
            java.lang.Object r2 = r2.get(r1)
            o.l90 r2 = (o.C1745l90) r2
            java.lang.Comparable r2 = r2.l
            int r2 = r5.compareTo(r2)
            if (r2 <= 0) goto L1e
            int r0 = r0 + 1
        L1c:
            int r5 = -r0
            return r5
        L1e:
            if (r2 != 0) goto L21
            return r1
        L21:
            r0 = 0
        L22:
            if (r0 > r1) goto L43
            int r2 = r0 + r1
            int r2 = r2 / 2
            java.util.List r3 = r4.l
            java.lang.Object r3 = r3.get(r2)
            o.l90 r3 = (o.C1745l90) r3
            java.lang.Comparable r3 = r3.l
            int r3 = r5.compareTo(r3)
            if (r3 >= 0) goto L3c
            int r2 = r2 + (-1)
            r1 = r2
            goto L22
        L3c:
            if (r3 <= 0) goto L42
            int r2 = r2 + 1
            r0 = r2
            goto L22
        L42:
            return r2
        L43:
            int r0 = r0 + 1
            goto L1c
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C1650k90.a(java.lang.Comparable):int");
    }

    public final void b() {
        if (this.n) {
            throw new UnsupportedOperationException();
        }
    }

    public final Map.Entry c(int i) {
        return (Map.Entry) this.l.get(i);
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final void clear() {
        b();
        if (!this.l.isEmpty()) {
            this.l.clear();
        }
        if (this.m.isEmpty()) {
            return;
        }
        this.m.clear();
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final boolean containsKey(Object obj) {
        Comparable comparable = (Comparable) obj;
        return a(comparable) >= 0 || this.m.containsKey(comparable);
    }

    public final Set d() {
        return this.m.isEmpty() ? Collections.EMPTY_SET : this.m.entrySet();
    }

    public final SortedMap e() {
        b();
        if (this.m.isEmpty() && !(this.m instanceof TreeMap)) {
            TreeMap treeMap = new TreeMap();
            this.m = treeMap;
            this.p = treeMap.descendingMap();
        }
        return (SortedMap) this.m;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final Set entrySet() {
        if (this.f608o == null) {
            this.f608o = new C1364h9(this, 1);
        }
        return this.f608o;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof C1650k90)) {
            return super.equals(obj);
        }
        C1650k90 c1650k90 = (C1650k90) obj;
        int size = size();
        if (size == c1650k90.size()) {
            int size2 = this.l.size();
            if (size2 != c1650k90.l.size()) {
                return ((AbstractSet) entrySet()).equals(c1650k90.entrySet());
            }
            for (int i = 0; i < size2; i++) {
                if (c(i).equals(c1650k90.c(i))) {
                }
            }
            if (size2 != size) {
                return this.m.equals(c1650k90.m);
            }
            return true;
        }
        return false;
    }

    @Override // java.util.AbstractMap, java.util.Map
    /* renamed from: g, reason: merged with bridge method [inline-methods] */
    public final Object put(Comparable comparable, Object obj) {
        b();
        int iA = a(comparable);
        if (iA >= 0) {
            return ((C1745l90) this.l.get(iA)).setValue(obj);
        }
        b();
        if (this.l.isEmpty() && !(this.l instanceof ArrayList)) {
            this.l = new ArrayList(16);
        }
        int i = -(iA + 1);
        if (i >= 16) {
            return e().put(comparable, obj);
        }
        if (this.l.size() == 16) {
            C1745l90 c1745l90 = (C1745l90) this.l.remove(15);
            e().put(c1745l90.l, c1745l90.m);
        }
        this.l.add(i, new C1745l90(this, comparable, obj));
        return null;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final Object get(Object obj) {
        Comparable comparable = (Comparable) obj;
        int iA = a(comparable);
        return iA >= 0 ? ((C1745l90) this.l.get(iA)).m : this.m.get(comparable);
    }

    public final Object h(int i) {
        b();
        Object obj = ((C1745l90) this.l.remove(i)).m;
        if (!this.m.isEmpty()) {
            Iterator it = e().entrySet().iterator();
            List list = this.l;
            Map.Entry entry = (Map.Entry) it.next();
            list.add(new C1745l90(this, (Comparable) entry.getKey(), entry.getValue()));
            it.remove();
        }
        return obj;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final int hashCode() {
        int size = this.l.size();
        int iHashCode = 0;
        for (int i = 0; i < size; i++) {
            iHashCode += ((C1745l90) this.l.get(i)).hashCode();
        }
        return this.m.size() > 0 ? this.m.hashCode() + iHashCode : iHashCode;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final Object remove(Object obj) {
        b();
        Comparable comparable = (Comparable) obj;
        int iA = a(comparable);
        if (iA >= 0) {
            return h(iA);
        }
        if (this.m.isEmpty()) {
            return null;
        }
        return this.m.remove(comparable);
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final int size() {
        return this.m.size() + this.l.size();
    }
}
