package defpackage;

import androidx.media3.container.NalUnitUtil;
import defpackage.dw7;
import kotlin.Metadata;
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.ByteReadChannelOperations_jvmKt", f = "ByteReadChannelOperations.jvm.kt", i = {0, 0, 0, 0, 0, 0}, l = {198}, m = "copyTo", n = {"$this$copyTo", "copied", "copy", "$this$read$iv", "limit", "min$iv"}, s = {"L$0", "L$1", "L$2", "L$3", "J$0", "I$0"})
final class ho0 extends ContinuationImpl {
    public bn0 a;
    public dw7.g b;
    public sq3 c;
    public bn0 d;
    public long e;
    public /* synthetic */ Object f;
    public int i;

    /* JADX WARN: Code restructure failed: missing block: B:28:0x0075, code lost:
    
        r12 = r8.a();
     */
    /* JADX WARN: Code restructure failed: missing block: B:29:0x0079, code lost:
    
        if (r12 != null) goto L32;
     */
    /* JADX WARN: Code restructure failed: missing block: B:31:0x0081, code lost:
    
        return kotlin.coroutines.jvm.internal.Boxing.boxLong(r7.a);
     */
    /* JADX WARN: Code restructure failed: missing block: B:32:0x0082, code lost:
    
        throw r12;
     */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws Throwable {
        ho0 ho0Var;
        this.f = obj;
        int i = this.i | Integer.MIN_VALUE;
        this.i = i;
        if ((i & Integer.MIN_VALUE) != 0) {
            this.i = i - Integer.MIN_VALUE;
            ho0Var = this;
        } else {
            ho0Var = new ho0(this);
        }
        Object obj2 = ho0Var.f;
        ck1 ck1Var = ck1.a;
        int i2 = ho0Var.i;
        if (i2 == 0) {
            s38.b(obj2);
            throw null;
        }
        if (i2 != 1) {
            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
        long j = ho0Var.e;
        bn0 bn0Var = ho0Var.d;
        sq3 sq3Var = ho0Var.c;
        dw7.g gVar = ho0Var.b;
        bn0 bn0Var2 = ho0Var.a;
        s38.b(obj2);
        loop0: while (true) {
            bn0Var.i();
            if (go0.d(bn0Var) > 0) {
                no0.a(bn0Var.g(), sq3Var);
            }
            while (!bn0Var2.i() && gVar.a < j) {
                if (go0.d(bn0Var2) <= 0 || go0.d(bn0Var2) < 0) {
                    ho0Var.a = bn0Var2;
                    ho0Var.b = gVar;
                    ho0Var.c = sq3Var;
                    ho0Var.d = bn0Var2;
                    ho0Var.e = j;
                    ho0Var.i = 1;
                    if (bn0Var2.h(1, ho0Var) == ck1Var) {
                        return ck1Var;
                    }
                    bn0Var = bn0Var2;
                } else {
                    no0.a(bn0Var2.g(), sq3Var);
                }
            }
            break loop0;
        }
    }
}
