package defpackage;

import androidx.media3.container.NalUnitUtil;
import defpackage.dw7;
import java.io.IOException;
import kotlin.Metadata;
import kotlin.coroutines.jvm.internal.Boxing;
import kotlin.coroutines.jvm.internal.ContinuationImpl;
import kotlin.coroutines.jvm.internal.DebugMetadata;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@DebugMetadata(c = "io.ktor.utils.io.ByteReadChannelOperationsKt", f = "ByteReadChannelOperations.kt", i = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4}, l = {513, 516, 526, 536, 537}, m = "readUntil", n = {"$this$readUntil", "matchString", "writeChannel", "partialMatchTable", "matchIndex", "matchBuffer", "rc", "limit", "ignoreMissing", "$this$readUntil", "matchString", "writeChannel", "partialMatchTable", "matchIndex", "matchBuffer", "rc", "limit", "ignoreMissing", "byte", "$this$readUntil", "matchString", "writeChannel", "partialMatchTable", "matchIndex", "matchBuffer", "rc", "limit", "ignoreMissing", "writeChannel", "rc", "rc"}, s = {"L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "J$0", "Z$0", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "J$0", "Z$0", "B$0", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "J$0", "Z$0", "L$0", "L$1", "L$0"})
final class ao0 extends ContinuationImpl {
    public Object a;
    public Object b;
    public gp0 c;
    public int[] d;
    public dw7.f e;
    public byte[] f;
    public dw7.g i;
    public long j;
    public boolean k;
    public byte l;
    public /* synthetic */ Object m;
    public int n;

    /* JADX WARN: Code restructure failed: missing block: B:22:0x00d8, code lost:
    
        if (defpackage.go0.q(r14, r11, r12, r10, r22) == r3) goto L51;
     */
    /* JADX WARN: Code restructure failed: missing block: B:50:0x018d, code lost:
    
        if (r6.b(r22) != r3) goto L52;
     */
    /* JADX WARN: Path cross not found for [B:19:0x00b8, B:30:0x00f0], limit reached: 60 */
    /* JADX WARN: Removed duplicated region for block: B:32:0x0102  */
    /* JADX WARN: Removed duplicated region for block: B:38:0x013c  */
    /* JADX WARN: Removed duplicated region for block: B:56:0x01c6  */
    /* JADX WARN: Removed duplicated region for block: B:58:0x01e8  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:35:0x011f -> B:36:0x0129). Please report as a decompilation issue!!! */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws IOException {
        int i;
        yo0 yo0Var;
        int[] iArr;
        byte[] bArr;
        bn0 bn0Var;
        gp0 gp0Var;
        dw7.f fVar;
        dw7.g gVar;
        long j;
        boolean z;
        byte bByteValue;
        dw7.f fVar2;
        yo0 yo0Var2;
        int i2;
        Object obj2;
        dw7.g gVar2;
        gp0 gp0Var2;
        Object objG = obj;
        this.m = objG;
        int i3 = (this.n | Integer.MIN_VALUE) - Integer.MIN_VALUE;
        this.n = i3;
        ck1 ck1Var = ck1.a;
        if (i3 == 0) {
            s38.b(objG);
            throw null;
        }
        int i4 = 3;
        int i5 = 2;
        if (i3 == 1) {
            i = 1;
            boolean z2 = this.k;
            long j2 = this.j;
            dw7.g gVar3 = this.i;
            byte[] bArr2 = this.f;
            dw7.f fVar3 = this.e;
            int[] iArr2 = this.d;
            gp0 gp0Var3 = this.c;
            yo0 yo0Var3 = (yo0) this.b;
            bn0 bn0Var2 = (bn0) this.a;
            s38.b(objG);
            yo0Var = yo0Var3;
            iArr = iArr2;
            bArr = bArr2;
            bn0Var = bn0Var2;
            gp0Var = gp0Var3;
            fVar = fVar3;
            gVar = gVar3;
            j = j2;
            z = z2;
            bByteValue = ((Number) objG).byteValue();
            i2 = fVar.a;
            if (i2 > 0) {
            }
            gp0 gp0Var4 = gp0Var;
            fVar2 = fVar;
            dw7.g gVar4 = gVar;
            int[] iArr3 = iArr;
            byte[] bArr3 = bArr;
            long j3 = j;
            yo0Var2 = yo0Var;
            if (bByteValue == yo0Var2.a(fVar2.a)) {
            }
        } else if (i3 == 2) {
            bByteValue = this.l;
            z = this.k;
            j = this.j;
            gVar = this.i;
            bArr = this.f;
            fVar = this.e;
            iArr = this.d;
            gp0Var = this.c;
            yo0Var = (yo0) this.b;
            i = 1;
            bn0Var = (bn0) this.a;
            s38.b(objG);
            byte b = bByteValue;
            while (true) {
                int i6 = fVar.a;
                if (i6 <= 0 || b == yo0Var.a(i6)) {
                    break;
                }
                fVar.a = iArr[fVar.a - 1];
            }
            gp0 gp0Var42 = gp0Var;
            fVar2 = fVar;
            dw7.g gVar42 = gVar;
            int[] iArr32 = iArr;
            byte[] bArr32 = bArr;
            long j32 = j;
            yo0Var2 = yo0Var;
            if (bByteValue == yo0Var2.a(fVar2.a)) {
            }
        } else {
            if (i3 == 3) {
                boolean z3 = this.k;
                long j4 = this.j;
                dw7.g gVar5 = this.i;
                byte[] bArr4 = this.f;
                dw7.f fVar4 = this.e;
                int[] iArr4 = this.d;
                gp0 gp0Var5 = this.c;
                yo0 yo0Var4 = (yo0) this.b;
                bn0 bn0Var3 = (bn0) this.a;
                s38.b(objG);
                i = 1;
                bn0Var = bn0Var3;
                z = z3;
                gp0Var = gp0Var5;
                yo0Var = yo0Var4;
                j = j4;
                gVar = gVar5;
                bArr = bArr4;
                fVar = fVar4;
                iArr = iArr4;
                long j5 = gVar.a;
                gVar.a = j5 + 1;
                Boxing.boxLong(j5);
                if (gVar.a > j) {
                    StringBuilder sbP = vw2.p(j, "Limit of ", " bytes exceeded while scanning for \"");
                    cr4.g(yo0Var, "<this>");
                    yo0Var.getClass();
                    throw new IOException(vw2.o(sbP, new String((byte[]) null, bz0.a), '\"'));
                }
                if (!bn0Var.i()) {
                    this.a = bn0Var;
                    this.b = yo0Var;
                    this.c = gp0Var;
                    this.d = iArr;
                    this.e = fVar;
                    this.f = bArr;
                    this.i = gVar;
                    this.j = j;
                    this.k = z;
                    this.n = i;
                    objG = go0.g(bn0Var, this);
                    if (objG != ck1Var) {
                        i4 = 3;
                        i5 = 2;
                        i = 1;
                        bByteValue = ((Number) objG).byteValue();
                        i2 = fVar.a;
                        if (i2 > 0 || bByteValue == yo0Var.a(i2)) {
                            gp0 gp0Var422 = gp0Var;
                            fVar2 = fVar;
                            dw7.g gVar422 = gVar;
                            int[] iArr322 = iArr;
                            byte[] bArr322 = bArr;
                            long j322 = j;
                            yo0Var2 = yo0Var;
                            if (bByteValue == yo0Var2.a(fVar2.a)) {
                                int i7 = fVar2.a;
                                bArr322[i7] = bByteValue;
                                fVar2.a = i7 + 1;
                                throw null;
                            }
                            this.a = bn0Var;
                            this.b = yo0Var2;
                            this.c = gp0Var422;
                            this.d = iArr322;
                            this.e = fVar2;
                            this.f = bArr322;
                            this.i = gVar422;
                            this.j = j322;
                            this.k = z;
                            this.n = i4;
                            if (kp0.b(gp0Var422, bByteValue, this) != ck1Var) {
                                yo0Var = yo0Var2;
                                j = j322;
                                bArr = bArr322;
                                iArr = iArr322;
                                gVar = gVar422;
                                fVar = fVar2;
                                gp0Var = gp0Var422;
                                long j52 = gVar.a;
                                gVar.a = j52 + 1;
                                Boxing.boxLong(j52);
                                if (gVar.a > j) {
                                }
                            }
                        } else {
                            this.a = bn0Var;
                            this.b = yo0Var;
                            this.c = gp0Var;
                            this.d = iArr;
                            this.e = fVar;
                            this.f = bArr;
                            this.i = gVar;
                            this.j = j;
                            this.k = z;
                            this.l = bByteValue;
                            this.n = i5;
                        }
                    }
                } else {
                    if (!z) {
                        StringBuilder sb = new StringBuilder("Expected \"");
                        cr4.g(yo0Var, "<this>");
                        yo0Var.getClass();
                        sb.append(n89.an(new String((byte[]) null, bz0.a), "\n", "\\n"));
                        sb.append("\" but encountered end of input");
                        throw new IOException(sb.toString());
                    }
                    this.a = gp0Var;
                    this.b = gVar;
                    obj2 = null;
                    this.c = null;
                    this.d = null;
                    this.e = null;
                    this.f = null;
                    this.i = null;
                    this.n = 4;
                    if (go0.q(gp0Var, bArr, fVar, gVar, this) != ck1Var) {
                        gVar2 = gVar;
                        gp0Var2 = gp0Var;
                        this.a = gVar2;
                        this.b = obj2;
                        this.n = 5;
                    }
                }
                return ck1Var;
            }
            if (i3 != 4) {
                if (i3 != 5) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                gVar2 = (dw7.g) this.a;
                s38.b(objG);
                return Boxing.boxLong(gVar2.a);
            }
            gVar2 = (dw7.g) this.b;
            gp0Var2 = (gp0) this.a;
            s38.b(objG);
            obj2 = null;
            this.a = gVar2;
            this.b = obj2;
            this.n = 5;
        }
    }
}
