// File: theuni[P]libbtcnet/src/handler.cpp
// Function: CConnectionHandlerInt::StartConnection(CConnection&&)
void CConnectionHandlerInt::StartConnection(CConnection&& conn)
{
    assert(IsEventThread());
    ConnID id = GetNextConnectionIndex();
    if (conn.IsDNS() && conn.GetOptions().doResolve == CConnectionOptions::RESOLVE_ONLY) {
        if (conn.GetProxy().IsSet()) {
            /* TODO */
        } else {
            std::unique_ptr<CResolveOnly> ptr(new CResolveOnly(*this, std::move(conn), id));
            auto it = m_dns_resolves.emplace_hint(m_dns_resolves.end(), id, std::move(ptr));
            it->second->Resolve();
        }
    } else {
        ConnectionBase* ptr;
        if (conn.GetProxy().IsSet())
            ptr = new CProxyConn(*this, std::move(conn), id);
        else if (conn.IsDNS())
            ptr = new CDNSConnection(*this, std::move(conn), id);
        else
            ptr = new CDirectConnection(*this, std::move(conn), id);
        auto it = m_connecting.emplace_hint(m_connecting.end(), id, std::unique_ptr<ConnectionBase>(ptr));
        it->second->Connect();
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x78(%rbp)
callq 0xe790
testb $0x1, %al
jne 0xfe66
jmp 0xfe68
jmp 0xfe87
leaq 0x15a2e(%rip), %rdi     # 0x2589d
leaq 0x15919(%rip), %rsi     # 0x2578f
movl $0x173, %edx            # imm = 0x173
leaq 0x15fb1(%rip), %rcx     # 0x25e33
callq 0x52e0
movq -0x78(%rbp), %rdi
callq 0xee20
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x9c70
testb $0x1, %al
jne 0xfea6
jmp 0xffca
movq -0x10(%rbp), %rdi
callq 0xa9c0
cmpl $0x2, 0x4(%rax)
jne 0xffca
movq -0x10(%rbp), %rdi
callq 0xa9a0
movq %rax, %rdi
callq 0xa100
testb $0x1, %al
jne 0xfed0
jmp 0xfed5
jmp 0xffc5
movl $0x1d8, %edi            # imm = 0x1D8
callq 0x5400
movq -0x78(%rbp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x22400
jmp 0xfefc
movq -0x80(%rbp), %rsi
leaq -0x20(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0x11c70
movq -0x78(%rbp), %rdi
addq $0x90, %rdi
movq %rdi, -0x98(%rbp)
callq 0x11720
movq %rax, -0x48(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x11cf0
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rcx
movq -0x40(%rbp), %rsi
leaq -0x18(%rbp), %rdx
callq 0x11ca0
movq %rax, -0x88(%rbp)
jmp 0xff5c
movq -0x88(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x11750
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11770
movq %rax, %rdi
callq 0x22620
jmp 0xff86
leaq -0x20(%rbp), %rdi
callq 0x11d10
jmp 0xffc5
movq -0x80(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x53e0
jmp 0x101a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x11d10
jmp 0x101a2
jmp 0x10199
movq -0x10(%rbp), %rdi
callq 0xa9a0
movq %rax, %rdi
callq 0xa100
testb $0x1, %al
jne 0xffe1
jmp 0x10038
movl $0x2e0, %edi            # imm = 0x2E0
callq 0x5400
movq -0x78(%rbp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x1e6c0
jmp 0x1000b
movq -0xa0(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x100f1
movq -0xa0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x53e0
jmp 0x101a2
movq -0x10(%rbp), %rdi
callq 0x9c70
testb $0x1, %al
jne 0x10047
jmp 0x1009b
movl $0x2f0, %edi            # imm = 0x2F0
callq 0x5400
movq -0x78(%rbp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x18a60
jmp 0x10071
movq -0xa8(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x100ef
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x53e0
jmp 0x101a2
movl $0x2c8, %edi            # imm = 0x2C8
callq 0x5400
movq -0x78(%rbp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x18480
jmp 0x100c5
movq -0xb0(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x100ef
movq -0xb0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x53e0
jmp 0x101a2
jmp 0x100f1
movq -0x78(%rbp), %rdi
addq $0x30, %rdi
movq %rdi, -0xc8(%rbp)
callq 0x113e0
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x118b0
movq -0x50(%rbp), %rsi
leaq -0x70(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x11930
movq -0xc8(%rbp), %rdi
movq -0xc0(%rbp), %rcx
movq -0x60(%rbp), %rsi
leaq -0x18(%rbp), %rdx
callq 0x11860
movq %rax, -0xb8(%rbp)
jmp 0x1014e
movq -0xb8(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x118d0
leaq -0x58(%rbp), %rdi
callq 0x11410
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11430
movq %rax, %rdi
movq (%rdi), %rax
callq *0x10(%rax)
jmp 0x10199
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x118d0
jmp 0x101a2
addq $0xd0, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x5710
nopl (%rax,%rax)