package c1;

import java.util.NoSuchElementException;
import kotlin.jvm.internal.t;

/* loaded from: classes.dex */
public final class k extends a {

    /* renamed from: r, reason: collision with root package name */
    private int f7371r;

    /* renamed from: s, reason: collision with root package name */
    private Object[] f7372s;

    /* renamed from: t, reason: collision with root package name */
    private boolean f7373t;

    /* JADX WARN: Type inference failed for: r5v1 */
    /* JADX WARN: Type inference failed for: r5v2, types: [boolean, int] */
    /* JADX WARN: Type inference failed for: r5v3 */
    public k(Object[] objArr, int i10, int i11, int i12) {
        super(i10, i11);
        this.f7371r = i12;
        Object[] objArr2 = new Object[i12];
        this.f7372s = objArr2;
        ?? r52 = i10 == i11 ? 1 : 0;
        this.f7373t = r52;
        objArr2[0] = objArr;
        h(i10 - r52, 1);
    }

    private final Object g() {
        int c10 = c() & 31;
        Object obj = this.f7372s[this.f7371r - 1];
        t.e(obj, "null cannot be cast to non-null type kotlin.Array<E of androidx.compose.runtime.external.kotlinx.collections.immutable.implementations.immutableList.TrieIterator>");
        return ((Object[]) obj)[c10];
    }

    private final void h(int i10, int i11) {
        int i12 = (this.f7371r - i11) * 5;
        while (i11 < this.f7371r) {
            Object[] objArr = this.f7372s;
            Object obj = objArr[i11 - 1];
            t.e(obj, "null cannot be cast to non-null type kotlin.Array<kotlin.Any?>");
            objArr[i11] = ((Object[]) obj)[l.a(i10, i12)];
            i12 -= 5;
            i11++;
        }
    }

    private final void i(int i10) {
        int i11 = 0;
        while (l.a(c(), i11) == i10) {
            i11 += 5;
        }
        if (i11 > 0) {
            h(c(), ((this.f7371r - 1) - (i11 / 5)) + 1);
        }
    }

    /* JADX WARN: Type inference failed for: r0v2 */
    /* JADX WARN: Type inference failed for: r0v3, types: [boolean, int] */
    /* JADX WARN: Type inference failed for: r0v4 */
    public final void m(Object[] objArr, int i10, int i11, int i12) {
        e(i10);
        f(i11);
        this.f7371r = i12;
        if (this.f7372s.length < i12) {
            this.f7372s = new Object[i12];
        }
        this.f7372s[0] = objArr;
        ?? r02 = i10 == i11 ? 1 : 0;
        this.f7373t = r02;
        h(i10 - r02, 1);
    }

    @Override // java.util.ListIterator, java.util.Iterator
    public Object next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        Object g10 = g();
        e(c() + 1);
        if (c() == d()) {
            this.f7373t = true;
            return g10;
        }
        i(0);
        return g10;
    }

    @Override // java.util.ListIterator
    public Object previous() {
        if (!hasPrevious()) {
            throw new NoSuchElementException();
        }
        e(c() - 1);
        if (this.f7373t) {
            this.f7373t = false;
            return g();
        }
        i(31);
        return g();
    }
}
