// File: theuni[P]libbtcnet/src/connection.cpp
// Function: CConnectionBase::ToString[abi:cxx11]() const
std::string CConnectionBase::ToString() const
{
    if (isDns || isOnion)
        return host + ":" + std::to_string(port);
    std::string ret;
    if (!addr.empty()) {
        std::array<char, NI_MAXHOST> hostbuf{};
        std::array<char, NI_MAXSERV> servbuf{};
        sockaddr_storage addr_stor;
        memset(&addr_stor, 0, sizeof(addr_stor));
        memcpy(&addr_stor, addr.data(), addr.size());
        if (getnameinfo(reinterpret_cast<sockaddr*>(&addr_stor), addr.size(), hostbuf.data(), hostbuf.size(), servbuf.data(), servbuf.size(), NI_NUMERICHOST | NI_NUMERICSERV) == 0) {
            if (addr_stor.ss_family == AF_INET6) {
                size_t len = strlen(hostbuf.data()) + strlen(servbuf.data()) + 3;
                ret.reserve(len);
                ret.push_back('[');
                ret.append(hostbuf.data());
                ret.append("]:");
                ret.append(servbuf.data());
            } else if (addr_stor.ss_family == AF_INET) {
                size_t len = strlen(hostbuf.data()) + strlen(servbuf.data()) + 1;
                ret.reserve(len);
                ret.assign(hostbuf.data());
                ret.push_back(':');
                ret.append(servbuf.data());
            } else
                ret.assign(hostbuf.data());
        }
    }
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5b0, %rsp            # imm = 0x5B0
movq %rdi, -0x528(%rbp)
movq %rdi, %rax
movq %rax, -0x520(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x518(%rbp)
testb $0x1, 0x22(%rax)
jne 0xa166
movq -0x518(%rbp), %rax
testb $0x1, 0x23(%rax)
je 0xa1f1
movq -0x518(%rbp), %rsi
leaq 0x1afb2(%rip), %rdx     # 0x25126
leaq -0x30(%rbp), %rdi
callq 0xb0e0
movq -0x518(%rbp), %rax
movzwl 0x20(%rax), %esi
leaq -0x50(%rbp), %rdi
callq 0xb160
jmp 0xa193
movq -0x528(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0xb010
jmp 0xa1a9
leaq -0x50(%rbp), %rdi
callq 0x52a0
leaq -0x30(%rbp), %rdi
callq 0x52a0
jmp 0xa554
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xa1e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x52a0
leaq -0x30(%rbp), %rdi
callq 0x52a0
jmp 0xa564
movq -0x528(%rbp), %rdi
movb $0x0, -0x5d(%rbp)
callq 0x5560
movq -0x518(%rbp), %rdi
addq $0x28, %rdi
callq 0xaf30
testb $0x1, %al
jne 0xa53c
leaq -0x45e(%rbp), %rdi
movq %rdi, -0x568(%rbp)
xorl %esi, %esi
movl $0x401, %edx            # imm = 0x401
callq 0x5220
movq -0x518(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, -0x590(%rbp)
movaps %xmm0, -0x470(%rbp)
movaps %xmm0, -0x480(%rbp)
movaps %xmm0, -0x490(%rbp)
movaps %xmm0, -0x4a0(%rbp)
movaps %xmm0, -0x4b0(%rbp)
movaps %xmm0, -0x4c0(%rbp)
movaps %xmm0, -0x4d0(%rbp)
movaps %xmm0, -0x4e0(%rbp)
movaps %xmm0, -0x4f0(%rbp)
movaps %xmm0, -0x500(%rbp)
addq $0x28, %rdi
movq %rdi, -0x570(%rbp)
callq 0xaf90
movq -0x570(%rbp), %rdi
movq %rax, -0x578(%rbp)
callq 0x6b00
movq -0x578(%rbp), %rsi
movq %rax, %rdx
leaq -0x500(%rbp), %rdi
movq %rdi, -0x558(%rbp)
callq 0x5370
movq -0x570(%rbp), %rdi
callq 0x6b00
movq -0x568(%rbp), %rdi
movl %eax, -0x54c(%rbp)
callq 0xafb0
movq -0x568(%rbp), %rdi
movq %rax, -0x548(%rbp)
callq 0xafd0
movl %eax, -0x53c(%rbp)
leaq -0x480(%rbp), %rdi
movq %rdi, -0x560(%rbp)
callq 0xafe0
movq -0x560(%rbp), %rdi
movq %rax, -0x538(%rbp)
callq 0xb000
movq -0x558(%rbp), %rdi
movl -0x54c(%rbp), %esi
movq -0x548(%rbp), %rdx
movl -0x53c(%rbp), %ecx
movq -0x538(%rbp), %r8
movl %eax, %r9d
movq %rsp, %rax
movl $0x3, (%rax)
callq 0x52b0
movl %eax, -0x52c(%rbp)
jmp 0xa361
movl -0x52c(%rbp), %eax
cmpl $0x0, %eax
jne 0xa53a
movzwl -0x500(%rbp), %eax
cmpl $0xa, %eax
jne 0xa45e
leaq -0x45e(%rbp), %rdi
callq 0xafb0
movq %rax, %rdi
callq 0x51c0
movq %rax, -0x598(%rbp)
leaq -0x480(%rbp), %rdi
callq 0xafe0
movq %rax, %rdi
callq 0x51c0
movq -0x528(%rbp), %rdi
movq %rax, %rcx
movq -0x598(%rbp), %rax
leaq 0x3(%rax,%rcx), %rax
movq %rax, -0x508(%rbp)
movq -0x508(%rbp), %rsi
callq 0x5630
jmp 0xa3da
movq -0x528(%rbp), %rdi
movl $0x5b, %esi
callq 0x5380
jmp 0xa3ed
leaq -0x45e(%rbp), %rdi
callq 0xafb0
movq -0x528(%rbp), %rdi
movq %rax, %rsi
callq 0x57b0
jmp 0xa40a
movq -0x528(%rbp), %rdi
leaq 0x1ad0d(%rip), %rsi     # 0x25125
callq 0x57b0
jmp 0xa41f
leaq -0x480(%rbp), %rdi
callq 0xafe0
movq -0x528(%rbp), %rdi
movq %rax, %rsi
callq 0x57b0
jmp 0xa43c
jmp 0xa538
movq -0x528(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
callq 0x52a0
jmp 0xa564
movzwl -0x500(%rbp), %eax
cmpl $0x2, %eax
jne 0xa517
leaq -0x45e(%rbp), %rdi
callq 0xafb0
movq %rax, %rdi
callq 0x51c0
movq %rax, -0x5a0(%rbp)
leaq -0x480(%rbp), %rdi
callq 0xafe0
movq %rax, %rdi
callq 0x51c0
movq -0x528(%rbp), %rdi
movq %rax, %rcx
movq -0x5a0(%rbp), %rax
leaq 0x1(%rax,%rcx), %rax
movq %rax, -0x510(%rbp)
movq -0x510(%rbp), %rsi
callq 0x5630
jmp 0xa4c8
leaq -0x45e(%rbp), %rdi
callq 0xafb0
movq -0x528(%rbp), %rdi
movq %rax, %rsi
callq 0x57d0
jmp 0xa4e5
movq -0x528(%rbp), %rdi
movl $0x3a, %esi
callq 0x5380
jmp 0xa4f8
leaq -0x480(%rbp), %rdi
callq 0xafe0
movq -0x528(%rbp), %rdi
movq %rax, %rsi
callq 0x57b0
jmp 0xa515
jmp 0xa536
leaq -0x45e(%rbp), %rdi
callq 0xafb0
movq -0x528(%rbp), %rdi
movq %rax, %rsi
callq 0x57d0
jmp 0xa534
jmp 0xa536
jmp 0xa538
jmp 0xa53a
jmp 0xa53c
movb $0x1, -0x5d(%rbp)
testb $0x1, -0x5d(%rbp)
jne 0xa552
movq -0x528(%rbp), %rdi
callq 0x52a0
jmp 0xa554
movq -0x520(%rbp), %rax
addq $0x5b0, %rsp            # imm = 0x5B0
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x5710
nopl (%rax)