// File: /workspace/github_cpp_makefile_star2_O1/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 0x829f
callq 0x4310
movq %rax, 0x168(%rbx)
cmpl $0x0, 0xe0(%rbx)
jne 0x86b8
cmpl $0x0, 0xe4(%rbx)
jne 0x86d7
cmpq $0x0, 0x190(%rbx)
jne 0x86f6
cmpq $0x0, 0x198(%rbx)
jne 0x8715
leaq 0x1a0(%rbx), %r14
movq %r14, %rdi
callq 0x11d00
testb %al, %al
jne 0x8734
leaq 0x1c8(%rbx), %r15
movq %r15, %rdi
callq 0x11d00
testb %al, %al
jne 0x8753
movl %ebp, 0xe8(%rbx)
callq 0x45d0
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x8772
movq %rax, %rdi
movl $0x10, %esi
callq 0x4630
testl %eax, %eax
jne 0x8791
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x87b0
callq 0x44a0
movq %rax, %r13
testq %rax, %rax
je 0x87cf
leaq 0x190(%rbx), %r12
movq (%r12), %rdi
testq %rdi, %rdi
je 0x8365
callq 0x10ee0
movq %r13, 0x190(%rbx)
cmpb $0x1, 0xec(%rbx)
jne 0x8385
movq %r13, %rdi
callq 0x4690
testl %eax, %eax
jne 0x8824
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x8394
callq 0x10ec8
movq $0x0, 0x8(%rsp)
movq (%r12), %rdi
testq %rdi, %rdi
je 0x8650
movl $0x1, %esi
callq 0x4700
movq %rax, %r13
testq %rax, %rax
je 0x87e6
movq 0x198(%rbx), %rdi
testq %rdi, %rdi
je 0x83d1
callq 0x10ee6
movq %r13, 0x198(%rbx)
leaq 0xa52b(%rip), %rsi      # 0x1290a
leaq 0xb4f2(%rip), %rdx      # 0x138d8
movq %r13, %rdi
callq 0x4250
testl %eax, %eax
jne 0x8805
movq (%r12), %rdi
testq %rdi, %rdi
je 0x8650
movl $0x3, %esi
callq 0x45a0
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movl $0x18, %edi
callq 0x4350
leaq 0x47d(%rip), %rcx       # 0x88a8
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movq %rbx, 0x10(%rax)
leaq 0x10(%rsp), %r8
movq %rax, (%r8)
leaq 0x2889(%rip), %r13      # 0xacd2
movq %r13, 0x18(%r8)
leaq 0x289a(%rip), %rbp      # 0xacee
movq %rbp, 0x10(%r8)
movq %r14, %rdi
movq %r12, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x10, %ecx
callq 0x11b9c
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x8486
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movl $0x18, %edi
callq 0x4350
leaq 0x510(%rip), %rcx       # 0x89b4
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 0x11b9c
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x84ee
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq %r15, %rdi
xorl %esi, %esi
callq 0x11d74
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 0x866a
movq 0x178(%rbx), %rdi
testq %rdi, %rdi
je 0x8530
callq 0x10ed4
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 0x866a
movq 0x170(%rbx), %rdi
testq %rdi, %rdi
je 0x856f
callq 0x10ed4
movq %r15, 0x170(%rbx)
movq 0x190(%rbx), %rdi
testq %rdi, %rdi
je 0x8650
movq 0x178(%rbx), %rsi
testq %rsi, %rsi
je 0x8684
callq 0x4200
movq %rax, %r15
testq %rax, %rax
je 0x869e
movq 0x188(%rbx), %rdi
testq %rdi, %rdi
je 0x85b8
callq 0x10eda
movq %r15, 0x188(%rbx)
movq 0x190(%rbx), %rdi
testq %rdi, %rdi
je 0x8650
movq 0x170(%rbx), %rsi
testq %rsi, %rsi
je 0x8684
callq 0x4200
movq %rax, %r15
testq %rax, %rax
je 0x869e
movq 0x180(%rbx), %rdi
testq %rdi, %rdi
je 0x8601
callq 0x10eda
movq %r15, 0x180(%rbx)
movups 0xacc9(%rip), %xmm0     # 0x132d8
leaq 0x10(%rsp), %rsi
movaps %xmm0, (%rsi)
movq %r14, %rdi
callq 0x11d66
movq 0xc0(%rbx), %rdi
movq (%rdi), %rax
callq *0xa0(%rax)
movq %r14, %rdi
callq 0x11d50
leaq 0x8(%rsp), %rdi
callq 0xa816
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa8fc(%rip), %rdi      # 0x12f53
leaq 0xa906(%rip), %rsi      # 0x12f64
leaq 0xa910(%rip), %rcx      # 0x12f75
jmp 0x87c5
leaq 0xa9db(%rip), %rdi      # 0x1304c
leaq 0xa8ec(%rip), %rsi      # 0x12f64
leaq 0xaa5f(%rip), %rcx      # 0x130de
jmp 0x87fb
leaq 0xa8c8(%rip), %rdi      # 0x12f53
leaq 0xa8d2(%rip), %rsi      # 0x12f64
leaq 0xaa9e(%rip), %rcx      # 0x13137
jmp 0x87c5
leaq 0xa9a7(%rip), %rdi      # 0x1304c
leaq 0xa8b8(%rip), %rsi      # 0x12f64
leaq 0xaae9(%rip), %rcx      # 0x1319c
jmp 0x87fb
leaq 0xa1a5(%rip), %rdi      # 0x12864
leaq 0xa145(%rip), %rsi      # 0x1280b
leaq 0xa1b2(%rip), %rcx      # 0x1287f
movl $0x35, %edx
callq 0x4260
leaq 0xa1c8(%rip), %rdi      # 0x128a6
leaq 0xa126(%rip), %rsi      # 0x1280b
leaq 0xa193(%rip), %rcx      # 0x1287f
movl $0x36, %edx
callq 0x4260
leaq 0xa1c4(%rip), %rdi      # 0x128c1
leaq 0xa107(%rip), %rsi      # 0x1280b
leaq 0xa174(%rip), %rcx      # 0x1287f
movl $0x37, %edx
callq 0x4260
leaq 0xa1b3(%rip), %rdi      # 0x128cf
leaq 0xa0e8(%rip), %rsi      # 0x1280b
leaq 0xa155(%rip), %rcx      # 0x1287f
movl $0x38, %edx
callq 0x4260
leaq 0xa1a0(%rip), %rdi      # 0x128db
leaq 0xa0c9(%rip), %rsi      # 0x1280b
leaq 0xa136(%rip), %rcx      # 0x1287f
movl $0x39, %edx
callq 0x4260
leaq 0xa192(%rip), %rdi      # 0x128ec
leaq 0xa0aa(%rip), %rsi      # 0x1280b
leaq 0xa117(%rip), %rcx      # 0x1287f
movl $0x3a, %edx
callq 0x4260
leaq 0xa7da(%rip), %rdi      # 0x12f53
leaq 0xa7e4(%rip), %rsi      # 0x12f64
leaq 0xa838(%rip), %rcx      # 0x12fbf
movl $0x21, %edx
callq 0x4260
leaq 0xa166(%rip), %rdi      # 0x128fe
leaq 0xa06c(%rip), %rsi      # 0x1280b
leaq 0xa0d9(%rip), %rcx      # 0x1287f
movl $0x40, %edx
callq 0x4260
leaq 0xa79c(%rip), %rdi      # 0x12f53
leaq 0xa7a6(%rip), %rsi      # 0x12f64
leaq 0xa837(%rip), %rcx      # 0x12ffc
movl $0x4b, %edx
callq 0x4260
leaq 0xa876(%rip), %rdi      # 0x1304c
leaq 0xa787(%rip), %rsi      # 0x12f64
leaq 0xa86c(%rip), %rcx      # 0x13050
jmp 0x87fb
leaq 0xa85f(%rip), %rdi      # 0x1304c
leaq 0xa770(%rip), %rsi      # 0x12f64
leaq 0xa89c(%rip), %rcx      # 0x13097
movl $0x67, %edx
callq 0x4260
leaq 0xa0f2(%rip), %rdi      # 0x128fe
leaq 0x9ff8(%rip), %rsi      # 0x1280b
leaq 0xa065(%rip), %rcx      # 0x1287f
movl $0x4e, %edx
callq 0x4260
leaq 0xa0d3(%rip), %rdi      # 0x128fe
leaq 0x9fd9(%rip), %rsi      # 0x1280b
leaq 0xa046(%rip), %rcx      # 0x1287f
movl $0x47, %edx
callq 0x4260
jmp 0x8887
jmp 0x8887
movq %rax, %rbx
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x8896
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x8896
jmp 0x8887
jmp 0x8893
movq %rax, %rbx
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x8896
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x8896
movq %rax, %rdi
callq 0xab84
jmp 0x8893
jmp 0x8893
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xa816
movq %rbx, %rdi
callq 0x4640