package k1;

import com.mstar.android.samba.OnRecvMsg;
import com.mstar.android.tv.TvLanguage;
import e1.C0454b;
import i1.C0548b;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ConnectException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.NoRouteToHostException;
import java.net.Socket;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.ListIterator;
import l1.AbstractC0619b;
import l1.AbstractC0621d;
import l1.C0622e;
import m1.AbstractC0630b;
import m1.AbstractRunnableC0631c;
import m1.C0632d;
import m1.InterfaceC0629a;
import okhttp3.HttpUrl;

/* JADX INFO: loaded from: classes.dex */
public class e0 extends AbstractRunnableC0631c implements U {

    /* JADX INFO: renamed from: t0, reason: collision with root package name */
    static final byte[] f4817t0 = new byte[65535];

    /* JADX INFO: renamed from: u0, reason: collision with root package name */
    static final C0564A f4818u0 = new C0564A();

    /* JADX INFO: renamed from: v0, reason: collision with root package name */
    static C0622e f4819v0 = C0622e.a();

    /* JADX INFO: renamed from: w0, reason: collision with root package name */
    static HashMap f4820w0 = null;

    /* JADX INFO: renamed from: L, reason: collision with root package name */
    InetAddress f4821L;

    /* JADX INFO: renamed from: M, reason: collision with root package name */
    int f4822M;

    /* JADX INFO: renamed from: Q, reason: collision with root package name */
    C0454b f4823Q;

    /* JADX INFO: renamed from: Z, reason: collision with root package name */
    Socket f4824Z;

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    int f4825a0;

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    int f4826b0;

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    OutputStream f4827c0;

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    InputStream f4828d0;

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    byte[] f4829e0 = new byte[512];

    /* JADX INFO: renamed from: f0, reason: collision with root package name */
    C0603u f4830f0 = new C0603u();

    /* JADX INFO: renamed from: g0, reason: collision with root package name */
    long f4831g0 = System.currentTimeMillis() + ((long) U.f4700P);

    /* JADX INFO: renamed from: h0, reason: collision with root package name */
    LinkedList f4832h0 = new LinkedList();

    /* JADX INFO: renamed from: i0, reason: collision with root package name */
    C0601s f4833i0 = null;

    /* JADX INFO: renamed from: j0, reason: collision with root package name */
    LinkedList f4834j0 = new LinkedList();

    /* JADX INFO: renamed from: k0, reason: collision with root package name */
    a f4835k0 = new a();

    /* JADX INFO: renamed from: l0, reason: collision with root package name */
    int f4836l0 = U.f4694F;

    /* JADX INFO: renamed from: m0, reason: collision with root package name */
    int f4837m0 = U.f4707l;

    /* JADX INFO: renamed from: n0, reason: collision with root package name */
    int f4838n0 = U.f4708m;

    /* JADX INFO: renamed from: o0, reason: collision with root package name */
    int f4839o0 = U.f4709n;

    /* JADX INFO: renamed from: p0, reason: collision with root package name */
    int f4840p0 = U.f4695G;

    /* JADX INFO: renamed from: q0, reason: collision with root package name */
    int f4841q0 = 0;

    /* JADX INFO: renamed from: r0, reason: collision with root package name */
    boolean f4842r0 = U.f4710o;

    /* JADX INFO: renamed from: s0, reason: collision with root package name */
    String f4843s0 = null;

    class a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        int f4844a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        int f4845b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        int f4846c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        int f4847d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        String f4848e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        int f4849f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        int f4850g;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        boolean f4851h;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        boolean f4852i;

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        boolean f4853j;

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        int f4854k;

        /* JADX INFO: renamed from: l, reason: collision with root package name */
        int f4855l;

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        long f4856m;

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        int f4857n;

        /* JADX INFO: renamed from: o, reason: collision with root package name */
        int f4858o;

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        byte[] f4859p;

        /* JADX INFO: renamed from: q, reason: collision with root package name */
        byte[] f4860q;

        a() {
        }
    }

    e0(C0454b c0454b, int i2, InetAddress inetAddress, int i3) {
        this.f4823Q = c0454b;
        this.f4825a0 = i2;
        this.f4821L = inetAddress;
        this.f4822M = i3;
    }

    static synchronized e0 s(C0454b c0454b, int i2) {
        return t(c0454b, i2, U.f4705j, U.f4706k, null);
    }

    static synchronized e0 t(C0454b c0454b, int i2, InetAddress inetAddress, int i3, String str) {
        int i4;
        LinkedList linkedList = U.f4698N;
        synchronized (linkedList) {
            try {
                if (U.f4699O != 1) {
                    ListIterator listIterator = linkedList.listIterator();
                    while (listIterator.hasNext()) {
                        e0 e0Var = (e0) listIterator.next();
                        if (!e0Var.w(c0454b, i2, inetAddress, i3, str) || ((i4 = U.f4699O) != 0 && e0Var.f4834j0.size() >= i4)) {
                        }
                        return e0Var;
                    }
                }
                e0 e0Var2 = new e0(c0454b, i2, inetAddress, i3);
                U.f4698N.add(0, e0Var2);
                return e0Var2;
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    private void x(int i2, AbstractC0600r abstractC0600r) {
        synchronized (this.f4829e0) {
            try {
                if (i2 == 139) {
                    z();
                } else {
                    if (i2 == 0) {
                        i2 = TvLanguage.TIGRINYA;
                    }
                    Socket socket = new Socket();
                    this.f4824Z = socket;
                    if (this.f4821L != null) {
                        socket.bind(new InetSocketAddress(this.f4821L, this.f4822M));
                    }
                    this.f4824Z.connect(new InetSocketAddress(this.f4823Q.f(), i2), U.f4701R);
                    this.f4824Z.setSoTimeout(U.f4700P);
                    this.f4827c0 = this.f4824Z.getOutputStream();
                    this.f4828d0 = this.f4824Z.getInputStream();
                }
                int i3 = this.f4826b0 + 1;
                this.f4826b0 = i3;
                if (i3 == 32000) {
                    this.f4826b0 = 1;
                }
                C0564A c0564a = f4818u0;
                c0564a.f5008b0 = this.f4826b0;
                int iF = c0564a.f(this.f4829e0, 4);
                AbstractC0619b.e(iF & 65535, this.f4829e0, 0);
                if (C0622e.f5384g >= 4) {
                    f4819v0.println(c0564a);
                    if (C0622e.f5384g >= 6) {
                        AbstractC0621d.a(f4819v0, this.f4829e0, 4, iF);
                    }
                }
                this.f4827c0.write(this.f4829e0, 0, iF + 4);
                this.f4827c0.flush();
                if (j() == null) {
                    throw new IOException("transport closed in negotiate");
                }
                int iA = AbstractC0619b.a(this.f4829e0, 2) & 65535;
                if (iA >= 33) {
                    int i4 = iA + 4;
                    byte[] bArr = this.f4829e0;
                    if (i4 <= bArr.length) {
                        AbstractRunnableC0631c.k(this.f4828d0, bArr, 36, iA - 32);
                        abstractC0600r.e(this.f4829e0, 4);
                        if (C0622e.f5384g >= 4) {
                            f4819v0.println(abstractC0600r);
                            if (C0622e.f5384g >= 6) {
                                AbstractC0621d.a(f4819v0, this.f4829e0, 4, iF);
                            }
                        }
                    }
                }
                throw new IOException("Invalid payload size: " + iA);
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // m1.AbstractRunnableC0631c
    protected void c() throws V {
        C0565B c0565b = new C0565B(this.f4835k0);
        int i2 = TvLanguage.CRIMEANTATAR;
        try {
            x(this.f4825a0, c0565b);
        } catch (ConnectException unused) {
            int i3 = this.f4825a0;
            if (i3 != 0 && i3 != 445) {
                i2 = 445;
            }
            this.f4825a0 = i2;
            x(i2, c0565b);
        } catch (NoRouteToHostException unused2) {
            int i4 = this.f4825a0;
            if (i4 != 0 && i4 != 445) {
                i2 = 445;
            }
            this.f4825a0 = i2;
            x(i2, c0565b);
        }
        if (c0565b.f4559q0 > 10) {
            throw new V("This client does not support the negotiated dialect.");
        }
        a aVar = this.f4835k0;
        if ((aVar.f4847d & Integer.MIN_VALUE) != Integer.MIN_VALUE && aVar.f4858o != 8 && U.f4717w == 0) {
            throw new V("Unexpected encryption key length: " + this.f4835k0.f4858o);
        }
        this.f4843s0 = this.f4823Q.g();
        a aVar2 = this.f4835k0;
        if (aVar2.f4853j || (aVar2.f4852i && U.f4713s)) {
            this.f4836l0 |= 4;
        } else {
            this.f4836l0 &= 65531;
        }
        int iMin = Math.min(this.f4837m0, aVar2.f4844a);
        this.f4837m0 = iMin;
        if (iMin < 1) {
            this.f4837m0 = 1;
        }
        this.f4838n0 = Math.min(this.f4838n0, this.f4835k0.f4845b);
        int i5 = this.f4840p0;
        int i6 = this.f4835k0.f4847d;
        int i7 = i5 & i6;
        this.f4840p0 = i7;
        if ((i6 & Integer.MIN_VALUE) == Integer.MIN_VALUE) {
            this.f4840p0 = i7 | Integer.MIN_VALUE;
        }
        int i8 = this.f4840p0;
        if ((i8 & 4) == 0) {
            if (U.f4711p) {
                this.f4840p0 = i8 | 4;
            } else {
                this.f4842r0 = false;
                this.f4836l0 &= 32767;
            }
        }
    }

    @Override // m1.AbstractRunnableC0631c
    protected void d(boolean z2) {
        ListIterator listIterator = this.f4834j0.listIterator();
        while (listIterator.hasNext()) {
            try {
                ((c0) listIterator.next()).b(z2);
            } catch (Throwable th) {
                this.f4833i0 = null;
                this.f4824Z = null;
                this.f4843s0 = null;
                throw th;
            }
        }
        this.f4824Z.shutdownOutput();
        this.f4827c0.close();
        this.f4828d0.close();
        this.f4824Z.close();
        this.f4833i0 = null;
        this.f4824Z = null;
        this.f4843s0 = null;
    }

    @Override // m1.AbstractRunnableC0631c
    protected void e(AbstractC0630b abstractC0630b) {
        AbstractC0600r abstractC0600r = (AbstractC0600r) abstractC0630b;
        abstractC0600r.f5011e0 = this.f4842r0;
        abstractC0600r.f5013g0 = (this.f4840p0 & Integer.MIN_VALUE) == Integer.MIN_VALUE;
        byte[] bArr = f4817t0;
        synchronized (bArr) {
            try {
                System.arraycopy(this.f4829e0, 0, bArr, 0, 36);
                int iA = AbstractC0619b.a(bArr, 2) & 65535;
                if (iA < 33 || iA + 4 > this.f4839o0) {
                    throw new IOException("Invalid payload size: " + iA);
                }
                int iC = AbstractC0619b.c(bArr, 9);
                if (abstractC0600r.f5021r == 46 && (iC == 0 || iC == -2147483643)) {
                    C0571H c0571h = (C0571H) abstractC0600r;
                    AbstractRunnableC0631c.k(this.f4828d0, bArr, 36, 27);
                    abstractC0600r.e(bArr, 4);
                    int i2 = c0571h.f4592x0 - 59;
                    if (c0571h.f5010d0 > 0 && i2 > 0 && i2 < 4) {
                        AbstractRunnableC0631c.k(this.f4828d0, bArr, 63, i2);
                    }
                    int i3 = c0571h.f4591w0;
                    if (i3 > 0) {
                        AbstractRunnableC0631c.k(this.f4828d0, c0571h.f4588t0, c0571h.f4589u0, i3);
                    }
                } else {
                    AbstractRunnableC0631c.k(this.f4828d0, bArr, 36, iA - 32);
                    abstractC0600r.e(bArr, 4);
                    if (abstractC0600r instanceof AbstractC0575L) {
                        ((AbstractC0575L) abstractC0600r).nextElement();
                    }
                }
                C0601s c0601s = this.f4833i0;
                if (c0601s != null && abstractC0600r.f5003L == 0) {
                    c0601s.d(bArr, 4, abstractC0600r);
                }
                if (C0622e.f5384g >= 4) {
                    f4819v0.println(abstractC0630b);
                    if (C0622e.f5384g >= 6) {
                        AbstractC0621d.a(f4819v0, bArr, 4, iA);
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // m1.AbstractRunnableC0631c
    protected void f(InterfaceC0629a interfaceC0629a) {
        byte[] bArr = f4817t0;
        synchronized (bArr) {
            try {
                AbstractC0600r abstractC0600r = (AbstractC0600r) interfaceC0629a;
                int iF = abstractC0600r.f(bArr, 4);
                AbstractC0619b.e(65535 & iF, bArr, 0);
                if (C0622e.f5384g >= 4) {
                    do {
                        f4819v0.println(abstractC0600r);
                        if (!(abstractC0600r instanceof AbstractC0584b)) {
                            break;
                        } else {
                            abstractC0600r = ((AbstractC0584b) abstractC0600r).f4770s0;
                        }
                    } while (abstractC0600r != null);
                    if (C0622e.f5384g >= 6) {
                        AbstractC0621d.a(f4819v0, f4817t0, 4, iF);
                    }
                }
                this.f4827c0.write(f4817t0, 0, iF + 4);
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // m1.AbstractRunnableC0631c
    protected void g() throws IOException {
        int iA = AbstractC0619b.a(this.f4829e0, 2) & 65535;
        if (iA >= 33 && iA + 4 <= this.f4839o0) {
            this.f4828d0.skip(iA - 32);
        } else {
            this.f4828d0.skip(r0.available());
        }
    }

    @Override // m1.AbstractRunnableC0631c
    protected void i(InterfaceC0629a interfaceC0629a) {
        int i2 = this.f4826b0 + 1;
        this.f4826b0 = i2;
        if (i2 == 32000) {
            this.f4826b0 = 1;
        }
        ((AbstractC0600r) interfaceC0629a).f5008b0 = this.f4826b0;
    }

    @Override // m1.AbstractRunnableC0631c
    protected InterfaceC0629a j() throws IOException {
        while (AbstractRunnableC0631c.k(this.f4828d0, this.f4829e0, 0, 4) >= 4) {
            byte[] bArr = this.f4829e0;
            if (bArr[0] != -123) {
                if (AbstractRunnableC0631c.k(this.f4828d0, bArr, 4, 32) < 32) {
                    return null;
                }
                if (C0622e.f5384g >= 4) {
                    f4819v0.println("New data read: " + this);
                    AbstractC0621d.a(f4819v0, this.f4829e0, 4, 32);
                }
                while (true) {
                    byte[] bArr2 = this.f4829e0;
                    if (bArr2[0] == 0 && bArr2[1] == 0 && bArr2[4] == -1 && bArr2[5] == 83 && bArr2[6] == 77 && bArr2[7] == 66) {
                        this.f4830f0.f5008b0 = AbstractC0619b.b(bArr2, 34) & 65535;
                        return this.f4830f0;
                    }
                    int i2 = 0;
                    while (i2 < 35) {
                        byte[] bArr3 = this.f4829e0;
                        int i3 = i2 + 1;
                        bArr3[i2] = bArr3[i3];
                        i2 = i3;
                    }
                    int i4 = this.f4828d0.read();
                    if (i4 == -1) {
                        return null;
                    }
                    this.f4829e0[35] = (byte) i4;
                }
            }
        }
        return null;
    }

    void m(AbstractC0600r abstractC0600r, AbstractC0600r abstractC0600r2) throws V {
        int iE = V.e(abstractC0600r2.f5003L);
        abstractC0600r2.f5003L = iE;
        if (iE != 0) {
            switch (iE) {
                case -2147483643:
                case OnRecvMsg.NT_STATUS_MORE_PROCESSING_REQUIRED /* -1073741802 */:
                case 0:
                    break;
                case OnRecvMsg.NT_STATUS_ACCESS_DENIED /* -1073741790 */:
                case OnRecvMsg.NT_STATUS_WRONG_PASSWORD /* -1073741718 */:
                case OnRecvMsg.NT_STATUS_TRUSTED_DOMAIN_FAILURE /* -1073741428 */:
                case OnRecvMsg.NT_STATUS_ACCOUNT_LOCKED_OUT /* -1073741260 */:
                    break;
                case OnRecvMsg.NT_STATUS_PATH_NOT_COVERED /* -1073741225 */:
                    C0599q c0599q = abstractC0600r.f5017k0;
                    if (c0599q == null) {
                        throw new V(abstractC0600r2.f5003L, (Throwable) null);
                    }
                    C0587e c0587eQ = q(c0599q, abstractC0600r.f5018l0, 1);
                    if (c0587eQ == null) {
                        throw new V(abstractC0600r2.f5003L, (Throwable) null);
                    }
                    W.f4726p0.d(abstractC0600r.f5018l0, c0587eQ);
                    throw c0587eQ;
                default:
                    switch (iE) {
                        case OnRecvMsg.NT_STATUS_LOGON_FAILURE /* -1073741715 */:
                        case OnRecvMsg.NT_STATUS_ACCOUNT_RESTRICTION /* -1073741714 */:
                        case OnRecvMsg.NT_STATUS_INVALID_LOGON_HOURS /* -1073741713 */:
                        case OnRecvMsg.NT_STATUS_INVALID_WORKSTATION /* -1073741712 */:
                        case OnRecvMsg.NT_STATUS_PASSWORD_EXPIRED /* -1073741711 */:
                        case OnRecvMsg.NT_STATUS_ACCOUNT_DISABLED /* -1073741710 */:
                            break;
                        default:
                            throw new V(abstractC0600r2.f5003L, (Throwable) null);
                    }
                    break;
            }
            throw new C0602t(abstractC0600r2.f5003L);
        }
        if (abstractC0600r2.f5016j0) {
            throw new V("Signature verification failed.");
        }
    }

    public void n() throws V {
        try {
            super.a(U.f4697K);
        } catch (C0632d e2) {
            throw new V("Failed to connect: " + this.f4823Q, e2);
        }
    }

    void o(String str, String[] strArr) {
        int length = strArr.length - 1;
        int length2 = str.length();
        int i2 = 0;
        int i3 = 0;
        int i4 = 0;
        while (i2 != length) {
            if (i3 == length2 || str.charAt(i3) == '\\') {
                strArr[i2] = str.substring(i4, i3);
                i4 = i3 + 1;
                i2++;
            }
            int i5 = i3 + 1;
            if (i3 >= length2) {
                while (i2 < strArr.length) {
                    strArr[i2] = HttpUrl.FRAGMENT_ENCODE_SET;
                    i2++;
                }
                return;
            }
            i3 = i5;
        }
        strArr[length] = str.substring(i4);
    }

    protected void p(InterfaceC0629a interfaceC0629a) throws IOException {
        try {
            f(interfaceC0629a);
        } catch (IOException e2) {
            if (C0622e.f5384g > 2) {
                e2.printStackTrace(f4819v0);
            }
            try {
                b(true);
            } catch (IOException e3) {
                e3.printStackTrace(f4819v0);
            }
            throw e2;
        }
    }

    C0587e q(C0599q c0599q, String str, int i2) {
        f0 f0VarA = r(c0599q).a("IPC$", null);
        k0 k0Var = new k0();
        f0VarA.b(new j0(str), k0Var);
        int i3 = k0Var.f4924N0;
        if (i3 == 0) {
            return null;
        }
        if (i2 == 0 || i3 < i2) {
            i2 = i3;
        }
        C0587e c0587e = new C0587e();
        String[] strArr = new String[4];
        long jCurrentTimeMillis = System.currentTimeMillis() + (C0586d.f4796e * 1000);
        int i4 = 0;
        while (true) {
            c0587e.f4809M = c0599q.f4990H;
            c0587e.f4815x = k0Var.f4926P0[i4].f4936j;
            c0587e.f4810Q = jCurrentTimeMillis;
            if (str.equals(HttpUrl.FRAGMENT_ENCODE_SET)) {
                c0587e.f4816y = k0Var.f4926P0[i4].f4937k.substring(1).toLowerCase();
            } else {
                o(k0Var.f4926P0[i4].f4938l, strArr);
                c0587e.f4816y = strArr[1];
                c0587e.f4806H = strArr[2];
                c0587e.f4808L = strArr[3];
            }
            c0587e.f4814r = k0Var.f4923M0;
            i4++;
            if (i4 == i2) {
                return c0587e.f4811Z;
            }
            c0587e.f(new C0587e());
            c0587e = c0587e.f4811Z;
        }
    }

    synchronized c0 r(C0599q c0599q) {
        ListIterator listIterator = this.f4834j0.listIterator();
        while (listIterator.hasNext()) {
            c0 c0Var = (c0) listIterator.next();
            if (c0Var.c(c0599q)) {
                c0Var.f4791i = c0599q;
                return c0Var;
            }
        }
        int i2 = U.f4700P;
        if (i2 > 0) {
            long j2 = this.f4831g0;
            long jCurrentTimeMillis = System.currentTimeMillis();
            if (j2 < jCurrentTimeMillis) {
                this.f4831g0 = ((long) i2) + jCurrentTimeMillis;
                ListIterator listIterator2 = this.f4834j0.listIterator();
                while (listIterator2.hasNext()) {
                    c0 c0Var2 = (c0) listIterator2.next();
                    if (c0Var2.f4792j < jCurrentTimeMillis) {
                        c0Var2.b(false);
                    }
                }
            }
        }
        c0 c0Var3 = new c0(this.f4823Q, this.f4825a0, this.f4821L, this.f4822M, c0599q);
        c0Var3.f4790h = this;
        this.f4834j0.add(c0Var3);
        return c0Var3;
    }

    @Override // m1.AbstractRunnableC0631c
    public String toString() {
        return super.toString() + "[" + this.f4823Q + ":" + this.f4825a0 + "]";
    }

    boolean u(int i2) throws V {
        try {
            a(U.f4697K);
            return (this.f4840p0 & i2) == i2;
        } catch (IOException e2) {
            throw new V(e2.getMessage(), e2);
        }
    }

    boolean v(C0599q c0599q) {
        C0599q c0599q2;
        return ((this.f4836l0 & 4) == 0 || this.f4833i0 != null || c0599q == (c0599q2 = C0599q.f4987f0) || c0599q2.equals(c0599q)) ? false : true;
    }

    boolean w(C0454b c0454b, int i2, InetAddress inetAddress, int i3, String str) {
        InetAddress inetAddress2;
        int i4;
        if (str == null) {
            str = c0454b.g();
        }
        String str2 = this.f4843s0;
        return (str2 == null || str.equalsIgnoreCase(str2)) && c0454b.equals(this.f4823Q) && (i2 == 0 || i2 == (i4 = this.f4825a0) || (i2 == 445 && i4 == 139)) && ((inetAddress == (inetAddress2 = this.f4821L) || (inetAddress != null && inetAddress.equals(inetAddress2))) && i3 == this.f4822M);
    }

    void y(AbstractC0600r abstractC0600r, AbstractC0600r abstractC0600r2) throws V {
        n();
        abstractC0600r.f5004M |= this.f4836l0;
        abstractC0600r.f5011e0 = this.f4842r0;
        abstractC0600r.f5020n0 = abstractC0600r2;
        if (abstractC0600r.f5019m0 == null) {
            abstractC0600r.f5019m0 = this.f4833i0;
        }
        try {
            if (abstractC0600r2 == null) {
                p(abstractC0600r);
                return;
            }
            if (abstractC0600r instanceof AbstractC0574K) {
                abstractC0600r2.f5021r = abstractC0600r.f5021r;
                AbstractC0574K abstractC0574K = (AbstractC0574K) abstractC0600r;
                AbstractC0575L abstractC0575L = (AbstractC0575L) abstractC0600r2;
                abstractC0574K.f4624O0 = this.f4838n0;
                abstractC0575L.t();
                try {
                    AbstractC0585c.b(abstractC0574K, abstractC0575L);
                    abstractC0574K.nextElement();
                    if (abstractC0574K.hasMoreElements()) {
                        AbstractC0600r c0603u = new C0603u();
                        super.l(abstractC0574K, c0603u, U.f4697K);
                        if (c0603u.f5003L != 0) {
                            m(abstractC0574K, c0603u);
                        }
                        abstractC0574K.nextElement();
                    } else {
                        i(abstractC0574K);
                    }
                    synchronized (this) {
                        try {
                            abstractC0600r2.f5012f0 = false;
                            abstractC0575L.f5399g = false;
                            try {
                                this.f5406y.put(abstractC0574K, abstractC0575L);
                                do {
                                    p(abstractC0574K);
                                    if (!abstractC0574K.hasMoreElements()) {
                                        break;
                                    }
                                } while (abstractC0574K.nextElement() != null);
                                long jCurrentTimeMillis = U.f4697K;
                                abstractC0575L.f5398b = System.currentTimeMillis() + jCurrentTimeMillis;
                                while (abstractC0575L.hasMoreElements()) {
                                    wait(jCurrentTimeMillis);
                                    jCurrentTimeMillis = abstractC0575L.f5398b - System.currentTimeMillis();
                                    if (jCurrentTimeMillis <= 0) {
                                        throw new C0632d(this + " timedout waiting for response to " + abstractC0574K);
                                    }
                                }
                                if (abstractC0600r2.f5003L != 0) {
                                    m(abstractC0574K, abstractC0575L);
                                }
                                this.f5406y.remove(abstractC0574K);
                            } catch (InterruptedException e2) {
                                throw new C0632d(e2);
                            }
                        } catch (Throwable th) {
                            this.f5406y.remove(abstractC0574K);
                            throw th;
                        }
                    }
                    AbstractC0585c.c(abstractC0574K.f4625P0);
                    AbstractC0585c.c(abstractC0575L.f4644I0);
                } catch (Throwable th2) {
                    AbstractC0585c.c(abstractC0574K.f4625P0);
                    AbstractC0585c.c(abstractC0575L.f4644I0);
                    throw th2;
                }
            } else {
                abstractC0600r2.f5021r = abstractC0600r.f5021r;
                super.l(abstractC0600r, abstractC0600r2, U.f4697K);
            }
            m(abstractC0600r, abstractC0600r2);
        } catch (V e3) {
            throw e3;
        } catch (IOException e4) {
            throw new V(e4.getMessage(), e4);
        }
    }

    void z() throws IOException {
        String strK;
        C0548b c0548b = new C0548b(this.f4823Q.a(), 32, null);
        do {
            Socket socket = new Socket();
            this.f4824Z = socket;
            if (this.f4821L != null) {
                socket.bind(new InetSocketAddress(this.f4821L, this.f4822M));
            }
            this.f4824Z.connect(new InetSocketAddress(this.f4823Q.f(), TvLanguage.CRIMEANTATAR), U.f4701R);
            this.f4824Z.setSoTimeout(U.f4700P);
            this.f4827c0 = this.f4824Z.getOutputStream();
            this.f4828d0 = this.f4824Z.getInputStream();
            i1.k kVar = new i1.k(c0548b, i1.g.r());
            OutputStream outputStream = this.f4827c0;
            byte[] bArr = this.f4829e0;
            outputStream.write(bArr, 0, kVar.d(bArr, 0));
            if (AbstractRunnableC0631c.k(this.f4828d0, this.f4829e0, 0, 4) < 4) {
                try {
                    this.f4824Z.close();
                } catch (IOException unused) {
                }
                throw new V("EOF during NetBIOS session request");
            }
            int i2 = this.f4829e0[0] & 255;
            if (i2 == -1) {
                b(true);
                throw new i1.h(2, -1);
            }
            if (i2 == 130) {
                if (C0622e.f5384g >= 4) {
                    f4819v0.println("session established ok with " + this.f4823Q);
                    return;
                }
                return;
            }
            if (i2 != 131) {
                b(true);
                throw new i1.h(2, 0);
            }
            int i3 = this.f4828d0.read() & 255;
            if (i3 != 128 && i3 != 130) {
                b(true);
                throw new i1.h(2, i3);
            }
            this.f4824Z.close();
            strK = this.f4823Q.k();
            c0548b.f4406a = strK;
        } while (strK != null);
        throw new IOException("Failed to establish session with " + this.f4823Q);
    }
}
