package okio;

import java.util.List;
import java.util.RandomAccess;
import o1.AbstractC0666b;

/* JADX INFO: loaded from: classes2.dex */
public final class t extends AbstractC0666b implements RandomAccess {

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public static final a f6052x = new a(null);

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private final i[] f6053g;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    private final int[] f6054r;

    public static final class a {
        private a() {
        }

        private final void a(long j2, C0688f c0688f, int i2, List list, int i3, int i4, List list2) {
            int i5;
            int i6;
            int i7;
            int i8;
            C0688f c0688f2;
            int i9 = i2;
            if (!(i3 < i4)) {
                throw new IllegalArgumentException("Failed requirement.");
            }
            for (int i10 = i3; i10 < i4; i10++) {
                if (!(((i) list.get(i10)).s() >= i9)) {
                    throw new IllegalArgumentException("Failed requirement.");
                }
            }
            i iVar = (i) list.get(i3);
            i iVar2 = (i) list.get(i4 - 1);
            int i11 = -1;
            if (i9 == iVar.s()) {
                int iIntValue = ((Number) list2.get(i3)).intValue();
                int i12 = i3 + 1;
                i iVar3 = (i) list.get(i12);
                i5 = i12;
                i6 = iIntValue;
                iVar = iVar3;
            } else {
                i5 = i3;
                i6 = -1;
            }
            if (iVar.d(i9) == iVar2.d(i9)) {
                int iMin = Math.min(iVar.s(), iVar2.s());
                int i13 = 0;
                for (int i14 = i9; i14 < iMin && iVar.d(i14) == iVar2.d(i14); i14++) {
                    i13++;
                }
                long jC = j2 + c(c0688f) + ((long) 2) + ((long) i13) + 1;
                c0688f.writeInt(-i13);
                c0688f.writeInt(i6);
                int i15 = i9 + i13;
                while (i9 < i15) {
                    c0688f.writeInt(iVar.d(i9) & 255);
                    i9++;
                }
                if (i5 + 1 == i4) {
                    if (!(i15 == ((i) list.get(i5)).s())) {
                        throw new IllegalStateException("Check failed.");
                    }
                    c0688f.writeInt(((Number) list2.get(i5)).intValue());
                    return;
                } else {
                    C0688f c0688f3 = new C0688f();
                    c0688f.writeInt(((int) (c(c0688f3) + jC)) * (-1));
                    a(jC, c0688f3, i15, list, i5, i4, list2);
                    c0688f.writeAll(c0688f3);
                    return;
                }
            }
            int i16 = 1;
            for (int i17 = i5 + 1; i17 < i4; i17++) {
                if (((i) list.get(i17 - 1)).d(i9) != ((i) list.get(i17)).d(i9)) {
                    i16++;
                }
            }
            long jC2 = j2 + c(c0688f) + ((long) 2) + ((long) (i16 * 2));
            c0688f.writeInt(i16);
            c0688f.writeInt(i6);
            for (int i18 = i5; i18 < i4; i18++) {
                byte bD = ((i) list.get(i18)).d(i9);
                if (i18 == i5 || bD != ((i) list.get(i18 - 1)).d(i9)) {
                    c0688f.writeInt(bD & 255);
                }
            }
            C0688f c0688f4 = new C0688f();
            while (i5 < i4) {
                byte bD2 = ((i) list.get(i5)).d(i9);
                int i19 = i5 + 1;
                int i20 = i19;
                while (true) {
                    if (i20 >= i4) {
                        i7 = i4;
                        break;
                    } else {
                        if (bD2 != ((i) list.get(i20)).d(i9)) {
                            i7 = i20;
                            break;
                        }
                        i20++;
                    }
                }
                if (i19 == i7 && i9 + 1 == ((i) list.get(i5)).s()) {
                    c0688f.writeInt(((Number) list2.get(i5)).intValue());
                    i8 = i7;
                    c0688f2 = c0688f4;
                } else {
                    c0688f.writeInt(((int) (jC2 + c(c0688f4))) * i11);
                    i8 = i7;
                    c0688f2 = c0688f4;
                    a(jC2, c0688f4, i9 + 1, list, i5, i7, list2);
                }
                c0688f4 = c0688f2;
                i5 = i8;
                i11 = -1;
            }
            c0688f.writeAll(c0688f4);
        }

        static /* synthetic */ void b(a aVar, long j2, C0688f c0688f, int i2, List list, int i3, int i4, List list2, int i5, Object obj) {
            aVar.a((i5 & 1) != 0 ? 0L : j2, c0688f, (i5 & 4) != 0 ? 0 : i2, list, (i5 & 16) != 0 ? 0 : i3, (i5 & 32) != 0 ? list.size() : i4, list2);
        }

        private final long c(C0688f c0688f) {
            return c0688f.G() / ((long) 4);
        }

        /* JADX WARN: Code restructure failed: missing block: B:55:0x00e7, code lost:
        
            continue;
         */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        public final okio.t d(okio.i... r17) {
            /*
                Method dump skipped, instruction units count: 316
                To view this dump add '--comments-level debug' option
            */
            throw new UnsupportedOperationException("Method not decompiled: okio.t.a.d(okio.i[]):okio.t");
        }

        public /* synthetic */ a(kotlin.jvm.internal.g gVar) {
            this();
        }
    }

    public /* synthetic */ t(i[] iVarArr, int[] iArr, kotlin.jvm.internal.g gVar) {
        this(iVarArr, iArr);
    }

    @Override // o1.AbstractC0665a
    public int a() {
        return this.f6053g.length;
    }

    public /* bridge */ boolean b(i iVar) {
        return super.contains(iVar);
    }

    @Override // o1.AbstractC0666b, java.util.List
    /* JADX INFO: renamed from: c, reason: merged with bridge method [inline-methods] */
    public i get(int i2) {
        return this.f6053g[i2];
    }

    @Override // o1.AbstractC0665a, java.util.Collection
    public final /* bridge */ boolean contains(Object obj) {
        if (obj instanceof i) {
            return b((i) obj);
        }
        return false;
    }

    public final i[] d() {
        return this.f6053g;
    }

    public final int[] e() {
        return this.f6054r;
    }

    public /* bridge */ int f(i iVar) {
        return super.indexOf(iVar);
    }

    public /* bridge */ int g(i iVar) {
        return super.lastIndexOf(iVar);
    }

    @Override // o1.AbstractC0666b, java.util.List
    public final /* bridge */ int indexOf(Object obj) {
        if (obj instanceof i) {
            return f((i) obj);
        }
        return -1;
    }

    @Override // o1.AbstractC0666b, java.util.List
    public final /* bridge */ int lastIndexOf(Object obj) {
        if (obj instanceof i) {
            return g((i) obj);
        }
        return -1;
    }

    private t(i[] iVarArr, int[] iArr) {
        this.f6053g = iVarArr;
        this.f6054r = iArr;
    }
}
