// File: tenup-coin[P]seeder/netbase.cpp
// Function: ConnectSocketByName(CService&, unsigned int&, char const*, int, int)
bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault, int nTimeout)
{
    string strDest;
    int port = portDefault;
    SplitHostPort(string(pszDest), port, strDest);

    SOCKET hSocket = INVALID_SOCKET;
    CService addrResolved(CNetAddr(strDest, fNameLookup && !nameproxyInfo.second), port);
    if (addrResolved.IsValid()) {
        addr = addrResolved;
        return ConnectSocket(addr, hSocketRet, nTimeout);
    }
    addr = CService("0.0.0.0:0");
    if (!nameproxyInfo.second)
        return false;
    if (!ConnectSocketDirectly(nameproxyInfo.first, hSocket, nTimeout))
        return false;

    switch(nameproxyInfo.second)
    {
        default:
        case 4: return false;
        case 5:
            if (!Socks5(strDest, port, hSocket))
                return false;
            break;
    }

    hSocketRet = hSocket;
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x46b0
movl -0x24(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0x71(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x4800
movq -0xf8(%rbp), %rsi
movq -0xf0(%rbp), %rdx
leaq -0x70(%rbp), %rdi
callq 0x4690
jmp 0x12b51
leaq -0x70(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0xf680
jmp 0x12b64
leaq -0x70(%rbp), %rdi
callq 0x42f0
leaq -0x71(%rbp), %rdi
callq 0x4520
movl $0xffffffff, -0x88(%rbp) # imm = 0xFFFFFFFF
xorl %eax, %eax
testb $0x1, 0x37a07(%rip)     # 0x4a590
movb %al, -0xf9(%rbp)
je 0x12ba3
cmpl $0x0, 0x379f4(%rip)     # 0x4a58c
setne %al
xorb $-0x1, %al
movb %al, -0xf9(%rbp)
movb -0xf9(%rbp), %al
movzbl %al, %edx
andl $0x1, %edx
leaq -0xaa(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x13410
jmp 0x12bc1
movzwl -0x4c(%rbp), %edx
leaq -0x9a(%rbp), %rdi
leaq -0xaa(%rbp), %rsi
callq 0x14640
jmp 0x12bda
leaq -0x9a(%rbp), %rdi
callq 0x10150
movb %al, -0xfa(%rbp)
jmp 0x12bee
movb -0xfa(%rbp), %al
testb $0x1, %al
jne 0x12bfd
jmp 0x12c93
movq -0x10(%rbp), %rax
movw -0x8a(%rbp), %cx
movw %cx, 0x10(%rax)
movups -0x9a(%rbp), %xmm0
movups %xmm0, (%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x28(%rbp), %edx
callq 0x10470
movb %al, -0xfb(%rbp)
jmp 0x12c2e
movb -0xfb(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movl $0x1, -0xb0(%rbp)
jmp 0x12dfb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x12c71
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x42f0
leaq -0x71(%rbp), %rdi
callq 0x4520
jmp 0x12e12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x12e12
leaq 0x20723(%rip), %rsi     # 0x333bd
leaq -0xc2(%rbp), %rdi
xorl %edx, %edx
callq 0x14880
jmp 0x12caa
movq -0x10(%rbp), %rax
movq -0xc2(%rbp), %rcx
movq %rcx, (%rax)
movq -0xba(%rbp), %rcx
movq %rcx, 0x8(%rax)
movw -0xb2(%rbp), %cx
movw %cx, 0x10(%rax)
cmpl $0x0, 0x378b7(%rip)     # 0x4a58c
jne 0x12cea
movb $0x0, -0x1(%rbp)
movl $0x1, -0xb0(%rbp)
jmp 0x12dfb
movl -0x28(%rbp), %edx
leaq 0x37884(%rip), %rdi     # 0x4a578
leaq -0x88(%rbp), %rsi
callq 0x10640
movb %al, -0xfc(%rbp)
jmp 0x12d08
movb -0xfc(%rbp), %al
testb $0x1, %al
jne 0x12d27
jmp 0x12d14
movb $0x0, -0x1(%rbp)
movl $0x1, -0xb0(%rbp)
jmp 0x12dfb
movl 0x3785f(%rip), %eax     # 0x4a58c
movl %eax, -0x100(%rbp)
subl $0x4, %eax
je 0x12d49
jmp 0x12d3a
movl -0x100(%rbp), %eax
subl $0x5, %eax
je 0x12d5c
jmp 0x12d47
jmp 0x12d49
movb $0x0, -0x1(%rbp)
movl $0x1, -0xb0(%rbp)
jmp 0x12dfb
leaq -0xe8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x4200
jmp 0x12d6e
movl -0x4c(%rbp), %esi
leaq -0xe8(%rbp), %rdi
leaq -0x88(%rbp), %rdx
callq 0x113b0
movb %al, -0x101(%rbp)
jmp 0x12d8c
movb -0x101(%rbp), %al
xorb $-0x1, %al
movb %al, -0x102(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x42f0
movb -0x102(%rbp), %al
testb $0x1, %al
jne 0x12db2
jmp 0x12ddf
movb $0x0, -0x1(%rbp)
movl $0x1, -0xb0(%rbp)
jmp 0x12dfb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x42f0
jmp 0x12e12
jmp 0x12de1
movl -0x88(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movb $0x1, -0x1(%rbp)
movl $0x1, -0xb0(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x42f0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x42f0
movq -0x80(%rbp), %rdi
callq 0x47f0
nopw %cs:(%rax,%rax)