package o;

import java.io.IOException;
import java.io.InputStream;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class M9 implements T90 {
    public final /* synthetic */ int l;
    public final Object m;
    public final Object n;

    public /* synthetic */ M9(int i, Object obj, Object obj2) {
        this.l = i;
        this.m = obj;
        this.n = obj2;
    }

    /* JADX WARN: Removed duplicated region for block: B:27:0x006e  */
    @Override // o.T90
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final long C(long r6, o.C0732af r8) {
        /*
            r5 = this;
            int r0 = r5.l
            java.lang.Object r1 = r5.m
            java.lang.Object r2 = r5.n
            switch(r0) {
                case 0: goto L88;
                default: goto L9;
            }
        L9:
            r3 = 0
            int r0 = (r6 > r3 ? 1 : (r6 == r3 ? 0 : -1))
            if (r0 != 0) goto L10
            goto L53
        L10:
            if (r0 < 0) goto L78
            r0 = 1
            o.Cf0 r2 = (o.Cf0) r2     // Catch: java.lang.AssertionError -> L43
            r2.f()     // Catch: java.lang.AssertionError -> L43
            o.t50 r2 = r8.y(r0)     // Catch: java.lang.AssertionError -> L43
            int r3 = r2.c     // Catch: java.lang.AssertionError -> L43
            int r3 = 8192 - r3
            long r3 = (long) r3     // Catch: java.lang.AssertionError -> L43
            long r6 = java.lang.Math.min(r6, r3)     // Catch: java.lang.AssertionError -> L43
            int r6 = (int) r6     // Catch: java.lang.AssertionError -> L43
            java.io.InputStream r1 = (java.io.InputStream) r1     // Catch: java.lang.AssertionError -> L43
            byte[] r7 = r2.a     // Catch: java.lang.AssertionError -> L43
            int r3 = r2.c     // Catch: java.lang.AssertionError -> L43
            int r6 = r1.read(r7, r3, r6)     // Catch: java.lang.AssertionError -> L43
            r7 = -1
            if (r6 != r7) goto L48
            int r6 = r2.b     // Catch: java.lang.AssertionError -> L43
            int r7 = r2.c     // Catch: java.lang.AssertionError -> L43
            if (r6 != r7) goto L45
            o.t50 r6 = r2.a()     // Catch: java.lang.AssertionError -> L43
            r8.l = r6     // Catch: java.lang.AssertionError -> L43
            o.AbstractC2781w50.a(r2)     // Catch: java.lang.AssertionError -> L43
            goto L45
        L43:
            r6 = move-exception
            goto L54
        L45:
            r3 = -1
            goto L53
        L48:
            int r7 = r2.c     // Catch: java.lang.AssertionError -> L43
            int r7 = r7 + r6
            r2.c = r7     // Catch: java.lang.AssertionError -> L43
            long r1 = r8.m     // Catch: java.lang.AssertionError -> L43
            long r3 = (long) r6     // Catch: java.lang.AssertionError -> L43
            long r1 = r1 + r3
            r8.m = r1     // Catch: java.lang.AssertionError -> L43
        L53:
            return r3
        L54:
            java.util.logging.Logger r7 = o.AbstractC2714vT.a
            java.lang.Throwable r7 = r6.getCause()
            r8 = 0
            if (r7 == 0) goto L6e
            java.lang.String r7 = r6.getMessage()
            if (r7 == 0) goto L6a
            java.lang.String r1 = "getsockname failed"
            boolean r7 = o.Za0.P(r7, r1, r8)
            goto L6b
        L6a:
            r7 = r8
        L6b:
            if (r7 == 0) goto L6e
            goto L6f
        L6e:
            r0 = r8
        L6f:
            if (r0 == 0) goto L77
            java.io.IOException r7 = new java.io.IOException
            r7.<init>(r6)
            throw r7
        L77:
            throw r6
        L78:
            java.lang.String r8 = "byteCount < 0: "
            java.lang.String r6 = o.AbstractC0126Ew.l(r8, r6)
            java.lang.IllegalArgumentException r7 = new java.lang.IllegalArgumentException
            java.lang.String r6 = r6.toString()
            r7.<init>(r6)
            throw r7
        L88:
            o.L90 r1 = (o.L90) r1
            o.M9 r2 = (o.M9) r2
            r1.h()
            long r6 = r2.C(r6, r8)     // Catch: java.lang.Throwable -> La0 java.io.IOException -> La2
            boolean r8 = r1.i()
            if (r8 != 0) goto L9a
            return r6
        L9a:
            r6 = 0
            java.io.IOException r6 = r1.k(r6)
            throw r6
        La0:
            r6 = move-exception
            goto Laf
        La2:
            r6 = move-exception
            boolean r7 = r1.i()     // Catch: java.lang.Throwable -> La0
            if (r7 != 0) goto Laa
            goto Lae
        Laa:
            java.io.IOException r6 = r1.k(r6)     // Catch: java.lang.Throwable -> La0
        Lae:
            throw r6     // Catch: java.lang.Throwable -> La0
        Laf:
            r1.i()
            throw r6
        */
        throw new UnsupportedOperationException("Method not decompiled: o.M9.C(long, o.af):long");
    }

    @Override // o.T90
    public final Cf0 a() {
        switch (this.l) {
            case 0:
                return (L90) this.m;
            default:
                return (Cf0) this.n;
        }
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() throws IOException {
        switch (this.l) {
            case 0:
                L90 l90 = (L90) this.m;
                M9 m9 = (M9) this.n;
                l90.h();
                try {
                    m9.close();
                    if (l90.i()) {
                        throw l90.k(null);
                    }
                    return;
                } catch (IOException e) {
                    if (!l90.i()) {
                        throw e;
                    }
                    throw l90.k(e);
                } finally {
                    l90.i();
                }
            default:
                ((InputStream) this.m).close();
                return;
        }
    }

    public final String toString() {
        switch (this.l) {
            case 0:
                return "AsyncTimeout.source(" + ((M9) this.n) + ')';
            default:
                return "source(" + ((InputStream) this.m) + ')';
        }
    }
}
