package defpackage;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;

/* JADX INFO: renamed from: ˏˋˇᵜ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C1849 extends AbstractC2001 implements InterfaceC0321 {

    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    public final /* synthetic */ Iterator f7315;

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public int f7316;

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public /* synthetic */ Object f7317;

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public final /* synthetic */ int f7318;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public Object f7319;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public Iterator f7320;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public int f7321;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public int f7322;

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public final /* synthetic */ int f7323;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C1849(int i, int i2, Iterator it, InterfaceC2643 interfaceC2643) {
        super(2, interfaceC2643);
        this.f7323 = i;
        this.f7318 = i2;
        this.f7315 = it;
    }

    /* JADX WARN: Removed duplicated region for block: B:26:0x0088  */
    /* JADX WARN: Removed duplicated region for block: B:35:0x00b0  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x00d8  */
    /* JADX WARN: Removed duplicated region for block: B:70:0x0138 A[SYNTHETIC] */
    @Override // defpackage.AbstractC1090
    /* JADX INFO: renamed from: ˊᵙᵾᵲ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object mo1078(Object obj) {
        int i;
        int i2;
        int i3;
        Iterator it;
        C1877 c1877;
        ArrayList arrayList;
        int i4;
        Iterator it2;
        int i5;
        int i6;
        C1877 c18772;
        boolean z;
        C1178 c1178 = (C1178) this.f7317;
        int i7 = this.f7316;
        int i8 = this.f7318;
        boolean z2 = true;
        int i9 = this.f7323;
        EnumC0111 enumC0111 = EnumC0111.f1384;
        if (i7 == 0) {
            ᵟˌᵫ.ˊˌˊ(obj);
            int i10 = i9 <= 1024 ? i9 : 1024;
            i = i8 - i9;
            Iterator it3 = this.f7315;
            if (i >= 0) {
                arrayList = new ArrayList(i10);
                i4 = i10;
                it2 = it3;
                i5 = 0;
                while (it2.hasNext()) {
                }
                if (!arrayList.isEmpty()) {
                }
            } else {
                C1877 c18773 = new C1877(0, new Object[i10]);
                i2 = i10;
                i3 = i;
                it = it3;
                c1877 = c18773;
                while (true) {
                    int i11 = c1877.f7435;
                    Object[] objArr = c1877.f7433;
                    if (it.hasNext()) {
                    }
                    z2 = z;
                }
            }
        } else if (i7 != 1) {
            if (i7 == 2) {
            } else if (i7 == 3) {
                i3 = this.f7322;
                i2 = this.f7321;
                it = this.f7320;
                c1877 = (C1877) this.f7319;
                ᵟˌᵫ.ˊˌˊ(obj);
                c1877.m5107(i8);
                while (true) {
                    int i112 = c1877.f7435;
                    Object[] objArr2 = c1877.f7433;
                    if (it.hasNext()) {
                        i6 = i2;
                        c18772 = c1877;
                        break;
                    }
                    Object next = it.next();
                    z = z2;
                    if (c1877.mo2197() == i112) {
                        ᵕᵩʽᵲ.ᵪᵹᵥᵻ("ring buffer is full");
                        return null;
                    }
                    int i12 = c1877.f7434;
                    int i13 = c1877.f7436;
                    objArr2[(i12 + i13) % i112] = next;
                    c1877.f7436 = i13 + 1;
                    if (c1877.mo2197() == i112) {
                        if (c1877.f7436 >= i9) {
                            ArrayList arrayList2 = new ArrayList(c1877);
                            this.f7317 = c1178;
                            this.f7319 = c1877;
                            this.f7320 = it;
                            this.f7321 = i2;
                            this.f7322 = i3;
                            this.f7316 = 3;
                            c1178.m3654(arrayList2, this);
                            return enumC0111;
                        }
                        int i14 = i112 + (i112 >> 1) + 1;
                        if (i14 > i9) {
                            i14 = i9;
                        }
                        c1877 = new C1877(c1877.f7436, c1877.f7434 == 0 ? Arrays.copyOf(objArr2, i14) : c1877.toArray(new Object[i14]));
                    }
                    z2 = z;
                }
            } else if (i7 == 4) {
                i3 = this.f7322;
                i6 = this.f7321;
                c18772 = (C1877) this.f7319;
                ᵟˌᵫ.ˊˌˊ(obj);
                c18772.m5107(i8);
                if (c18772.f7436 > i8) {
                    ArrayList arrayList3 = new ArrayList(c18772);
                    this.f7317 = c1178;
                    this.f7319 = c18772;
                    this.f7320 = null;
                    this.f7321 = i6;
                    this.f7322 = i3;
                    this.f7316 = 4;
                    c1178.m3654(arrayList3, this);
                    return enumC0111;
                }
                if (!c18772.isEmpty()) {
                    this.f7317 = null;
                    this.f7319 = null;
                    this.f7320 = null;
                    this.f7321 = i6;
                    this.f7322 = i3;
                    this.f7316 = 5;
                    c1178.m3654(c18772, this);
                    return enumC0111;
                }
            } else {
                if (i7 != 5) {
                    ᵕᵩʽᵲ.ᵪᵹᵥᵻ("call to 'resume' before 'invoke' with coroutine");
                    return null;
                }
            }
            ᵟˌᵫ.ˊˌˊ(obj);
        } else {
            i5 = this.f7322;
            i4 = this.f7321;
            it2 = this.f7320;
            ᵟˌᵫ.ˊˌˊ(obj);
            arrayList = new ArrayList(i9);
            i = i5;
            while (it2.hasNext()) {
                Object next2 = it2.next();
                if (i5 > 0) {
                    i5--;
                } else {
                    arrayList.add(next2);
                    if (arrayList.size() == i9) {
                        this.f7317 = c1178;
                        this.f7319 = arrayList;
                        this.f7320 = it2;
                        this.f7321 = i4;
                        this.f7322 = i;
                        this.f7316 = 1;
                        c1178.m3654(arrayList, this);
                        return enumC0111;
                    }
                }
            }
            if (!arrayList.isEmpty()) {
                this.f7317 = null;
                this.f7319 = null;
                this.f7320 = null;
                this.f7321 = i4;
                this.f7322 = i;
                this.f7316 = 2;
                c1178.m3654(arrayList, this);
                return enumC0111;
            }
        }
        return C5063.f19112;
    }

    @Override // defpackage.InterfaceC0321
    /* JADX INFO: renamed from: ᵝᵶ */
    public final Object mo1564(Object obj, Object obj2) {
        return ((C1849) mo1565((InterfaceC2643) obj2, (C1178) obj)).mo1078(C5063.f19112);
    }

    @Override // defpackage.AbstractC1090
    /* JADX INFO: renamed from: ᵟᵹᵙ */
    public final InterfaceC2643 mo1565(InterfaceC2643 interfaceC2643, Object obj) {
        C1849 c1849 = new C1849(this.f7323, this.f7318, this.f7315, interfaceC2643);
        c1849.f7317 = obj;
        return c1849;
    }
}
