// File: /workspace/github_cpp_makefile_star2_O3/theuni[P]libbtcnet/src/handler.cpp
// Function: CConnectionHandlerInt::Start(int)
void CConnectionHandlerInt::Start(int outgoing_limit)
{
    int result = 0;
    m_shutdown = false;

#ifndef NO_THREADS
    if (m_enable_threading)
        m_main_thread = std::this_thread::get_id();
#endif

    assert(m_outgoing_conn_count == 0);
    assert(m_incoming_conn_count == 0);
    assert(!m_event_base);
    assert(!m_dns_base);
    assert(!m_request_event);
    assert(!m_shutdown_event);

    m_outgoing_conn_limit = outgoing_limit;

    event_type<event_config> cfg(event_config_new());
    result = event_config_set_flag(cfg, EVENT_BASE_FLAG_EPOLL_USE_CHANGELIST);
    assert(result == 0);
    (void)result;

    m_event_base = event_base_new_with_config(cfg);

    if (m_enable_threading) {
        result = enable_threads_for_handler(m_event_base);
        assert(result == 0);
        (void)result;
    }
    cfg.free();

    m_dns_base = evdns_base_new(m_event_base, 1);
    result = evdns_base_set_option(m_dns_base, "randomize-case", "0");
    assert(result == 0);
    (void)result;

    event_base_priority_init(m_event_base, 3);

    m_request_event.reset(m_event_base, -1, EV_PERSIST, std::bind(&CConnectionHandlerInt::RequestOutgoingInt, this));
    m_shutdown_event.reset(m_event_base, -1, 0, std::bind(&CConnectionHandlerInt::ShutdownInt, this));

    m_shutdown_event.priority_set(0);

    m_outgoing_rate_cfg = ev_token_bucket_cfg_new(EV_RATE_LIMIT_MAX, EV_RATE_LIMIT_MAX, EV_RATE_LIMIT_MAX, EV_RATE_LIMIT_MAX, nullptr);
    m_incoming_rate_cfg = ev_token_bucket_cfg_new(EV_RATE_LIMIT_MAX, EV_RATE_LIMIT_MAX, EV_RATE_LIMIT_MAX, EV_RATE_LIMIT_MAX, nullptr);

    m_outgoing_rate_limit = bufferevent_rate_limit_group_new(m_event_base, m_outgoing_rate_cfg);
    m_incoming_rate_limit = bufferevent_rate_limit_group_new(m_event_base, m_incoming_rate_cfg);

    timeval request_timeout = {0, 500000};
    m_request_event.add(&request_timeout);
    m_interface.OnStartup();

    m_request_event.active();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movb $0x0, 0xed(%rdi)
cmpb $0x1, 0xec(%rdi)
jne 0x823b
callq 0x4310
movq %rax, 0x168(%rbx)
cmpl $0x0, 0xe0(%rbx)
jne 0x864c
cmpl $0x0, 0xe4(%rbx)
jne 0x866b
cmpq $0x0, 0x190(%rbx)
jne 0x868a
cmpq $0x0, 0x198(%rbx)
jne 0x86a9
leaq 0x1a0(%rbx), %r14
movq %r14, %rdi
callq 0x11b3e
testb %al, %al
jne 0x86c8
leaq 0x1c8(%rbx), %r15
movq %r15, %rdi
callq 0x11b3e
testb %al, %al
jne 0x86e7
movl %ebp, 0xe8(%rbx)
callq 0x45d0
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x8706
movq %rax, %rdi
movl $0x10, %esi
callq 0x4630
testl %eax, %eax
jne 0x8725
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x8744
callq 0x44a0
movq %rax, %r13
testq %rax, %rax
je 0x8763
leaq 0x190(%rbx), %r12
movq (%r12), %rdi
testq %rdi, %rdi
je 0x8301
callq 0x10d38
movq %r13, 0x190(%rbx)
cmpb $0x1, 0xec(%rbx)
jne 0x8321
movq %r13, %rdi
callq 0x4690
testl %eax, %eax
jne 0x87b8
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x8330
callq 0x10d20
movq $0x0, 0x8(%rsp)
movq (%r12), %rdi
testq %rdi, %rdi
je 0x85e4
movl $0x1, %esi
callq 0x4700
movq %rax, %r13
testq %rax, %rax
je 0x877a
movq 0x198(%rbx), %rdi
testq %rdi, %rdi
je 0x836d
callq 0x10d3e
movq %r13, 0x198(%rbx)
leaq 0xa58b(%rip), %rsi      # 0x12906
leaq 0xb54e(%rip), %rdx      # 0x138d0
movq %r13, %rdi
callq 0x4250
testl %eax, %eax
jne 0x8799
movq (%r12), %rdi
testq %rdi, %rdi
je 0x85e4
movl $0x3, %esi
callq 0x45a0
movq $0x0, 0x18(%rsp)
movl $0x18, %edi
callq 0x4350
leaq 0x479(%rip), %rcx       # 0x883c
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movq %rbx, 0x10(%rax)
leaq 0x10(%rsp), %r8
movq %rax, (%r8)
leaq 0x278b(%rip), %r13      # 0xab6c
movq %r13, 0x18(%r8)
leaq 0x279c(%rip), %rbp      # 0xab88
movq %rbp, 0x10(%r8)
movq %r14, %rdi
movq %r12, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x10, %ecx
callq 0x119e0
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x841e
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq $0x0, 0x18(%rsp)
movl $0x18, %edi
callq 0x4350
leaq 0x50c(%rip), %rcx       # 0x8944
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movq %rbx, 0x10(%rax)
leaq 0x10(%rsp), %r8
movq %rax, (%r8)
movq %r13, 0x18(%r8)
movq %rbp, 0x10(%r8)
movq %r15, %rdi
movq %r12, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
callq 0x119e0
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x8482
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq %r15, %rdi
xorl %esi, %esi
callq 0x11bb2
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
movq %rcx, %rdi
movq %rcx, %rsi
movq %rcx, %rdx
xorl %r8d, %r8d
callq 0x4590
movq %rax, %r15
testq %rax, %rax
je 0x85fe
movq 0x178(%rbx), %rdi
testq %rdi, %rdi
je 0x84c4
callq 0x10d2c
movq %r15, 0x178(%rbx)
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
movq %rcx, %rdi
movq %rcx, %rsi
movq %rcx, %rdx
xorl %r8d, %r8d
callq 0x4590
movq %rax, %r15
testq %rax, %rax
je 0x85fe
movq 0x170(%rbx), %rdi
testq %rdi, %rdi
je 0x8503
callq 0x10d2c
movq %r15, 0x170(%rbx)
movq 0x190(%rbx), %rdi
testq %rdi, %rdi
je 0x85e4
movq 0x178(%rbx), %rsi
testq %rsi, %rsi
je 0x8618
callq 0x4200
movq %rax, %r15
testq %rax, %rax
je 0x8632
movq 0x188(%rbx), %rdi
testq %rdi, %rdi
je 0x854c
callq 0x10d32
movq %r15, 0x188(%rbx)
movq 0x190(%rbx), %rdi
testq %rdi, %rdi
je 0x85e4
movq 0x170(%rbx), %rsi
testq %rsi, %rsi
je 0x8618
callq 0x4200
movq %rax, %r15
testq %rax, %rax
je 0x8632
movq 0x180(%rbx), %rdi
testq %rdi, %rdi
je 0x8595
callq 0x10d32
movq %r15, 0x180(%rbx)
movups 0xad2d(%rip), %xmm0     # 0x132d0
leaq 0x10(%rsp), %rsi
movaps %xmm0, (%rsi)
movq %r14, %rdi
callq 0x11ba4
movq 0xc0(%rbx), %rdi
movq (%rdi), %rax
callq *0xa0(%rax)
movq %r14, %rdi
callq 0x11b8e
leaq 0x8(%rsp), %rdi
callq 0xa6d4
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa964(%rip), %rdi      # 0x12f4f
leaq 0xa96e(%rip), %rsi      # 0x12f60
leaq 0xa978(%rip), %rcx      # 0x12f71
jmp 0x8759
leaq 0xaa43(%rip), %rdi      # 0x13048
leaq 0xa954(%rip), %rsi      # 0x12f60
leaq 0xaac7(%rip), %rcx      # 0x130da
jmp 0x878f
leaq 0xa930(%rip), %rdi      # 0x12f4f
leaq 0xa93a(%rip), %rsi      # 0x12f60
leaq 0xab06(%rip), %rcx      # 0x13133
jmp 0x8759
leaq 0xaa0f(%rip), %rdi      # 0x13048
leaq 0xa920(%rip), %rsi      # 0x12f60
leaq 0xab51(%rip), %rcx      # 0x13198
jmp 0x878f
leaq 0xa20d(%rip), %rdi      # 0x12860
leaq 0xa1ad(%rip), %rsi      # 0x12807
leaq 0xa21a(%rip), %rcx      # 0x1287b
movl $0x35, %edx
callq 0x4260
leaq 0xa230(%rip), %rdi      # 0x128a2
leaq 0xa18e(%rip), %rsi      # 0x12807
leaq 0xa1fb(%rip), %rcx      # 0x1287b
movl $0x36, %edx
callq 0x4260
leaq 0xa22c(%rip), %rdi      # 0x128bd
leaq 0xa16f(%rip), %rsi      # 0x12807
leaq 0xa1dc(%rip), %rcx      # 0x1287b
movl $0x37, %edx
callq 0x4260
leaq 0xa21b(%rip), %rdi      # 0x128cb
leaq 0xa150(%rip), %rsi      # 0x12807
leaq 0xa1bd(%rip), %rcx      # 0x1287b
movl $0x38, %edx
callq 0x4260
leaq 0xa208(%rip), %rdi      # 0x128d7
leaq 0xa131(%rip), %rsi      # 0x12807
leaq 0xa19e(%rip), %rcx      # 0x1287b
movl $0x39, %edx
callq 0x4260
leaq 0xa1fa(%rip), %rdi      # 0x128e8
leaq 0xa112(%rip), %rsi      # 0x12807
leaq 0xa17f(%rip), %rcx      # 0x1287b
movl $0x3a, %edx
callq 0x4260
leaq 0xa842(%rip), %rdi      # 0x12f4f
leaq 0xa84c(%rip), %rsi      # 0x12f60
leaq 0xa8a0(%rip), %rcx      # 0x12fbb
movl $0x21, %edx
callq 0x4260
leaq 0xa1ce(%rip), %rdi      # 0x128fa
leaq 0xa0d4(%rip), %rsi      # 0x12807
leaq 0xa141(%rip), %rcx      # 0x1287b
movl $0x40, %edx
callq 0x4260
leaq 0xa804(%rip), %rdi      # 0x12f4f
leaq 0xa80e(%rip), %rsi      # 0x12f60
leaq 0xa89f(%rip), %rcx      # 0x12ff8
movl $0x4b, %edx
callq 0x4260
leaq 0xa8de(%rip), %rdi      # 0x13048
leaq 0xa7ef(%rip), %rsi      # 0x12f60
leaq 0xa8d4(%rip), %rcx      # 0x1304c
jmp 0x878f
leaq 0xa8c7(%rip), %rdi      # 0x13048
leaq 0xa7d8(%rip), %rsi      # 0x12f60
leaq 0xa904(%rip), %rcx      # 0x13093
movl $0x67, %edx
callq 0x4260
leaq 0xa15a(%rip), %rdi      # 0x128fa
leaq 0xa060(%rip), %rsi      # 0x12807
leaq 0xa0cd(%rip), %rcx      # 0x1287b
movl $0x4e, %edx
callq 0x4260
leaq 0xa13b(%rip), %rdi      # 0x128fa
leaq 0xa041(%rip), %rsi      # 0x12807
leaq 0xa0ae(%rip), %rcx      # 0x1287b
movl $0x47, %edx
callq 0x4260
jmp 0x881b
jmp 0x881b
movq %rax, %rbx
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x882a
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x882a
jmp 0x881b
jmp 0x8827
movq %rax, %rbx
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x882a
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x882a
movq %rax, %rdi
callq 0xaa1e
jmp 0x8827
jmp 0x8827
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xa6d4
movq %rbx, %rdi
callq 0x4640