// File: theuni[P]libbtcnet/src/handler.cpp
// Function: CConnectionHandlerInt::ShutdownInt()
void CConnectionHandlerInt::ShutdownInt()
{
    assert(IsEventThread());
    if (m_shutdown)
        return;

    DEBUG_PRINT(LOGINFO, "shutdown started");

    std::map<ConnID, std::unique_ptr<ConnectionBase> > disconnecting;
    {
        optional_lock(m_conn_mutex, m_enable_threading);
        disconnecting.swap(m_connected);
    }
    std::map<ConnID, std::unique_ptr<CConnListener> > binds;
    {
        optional_lock(m_bind_mutex, m_enable_threading);
        binds.swap(m_binds);
    }

    m_shutdown = true;

    for (auto iter = disconnecting.begin(); iter != disconnecting.end(); disconnecting.erase(iter++)) {
        if (iter->second->IsOutgoing())
            m_outgoing_conn_count--;
        else
            m_incoming_conn_count--;
        m_interface.OnDisconnected(iter->first, false);
    }

    for (auto iter = m_connecting.begin(); iter != m_connecting.end(); m_connecting.erase(iter++)) {
        if (iter->second->IsOutgoing()) {
            const CConnection& conn = iter->second->GetBaseConnection();
            m_interface.OnConnectionFailure(conn, conn, false);
        }
    }

    m_dns_resolves.clear();
    binds.clear();

    m_dns_base.free();
    m_outgoing_rate_limit.free();
    m_incoming_rate_limit.free();
    m_incoming_rate_cfg.free();
    m_outgoing_rate_cfg.free();
    m_request_event.free();
    m_shutdown_event.free();

    assert(m_connecting.empty());
    assert(disconnecting.empty());
    assert(m_connected.empty());
    assert(binds.empty());
    assert(m_dns_resolves.empty());
    assert(!m_outgoing_conn_count);
    assert(!m_incoming_conn_count);

    DEBUG_PRINT(LOGINFO, "shutdown complete");
    event_base_loopbreak(m_event_base);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0xe790
testb $0x1, %al
jne 0xe175
jmp 0xe177
jmp 0xe196
leaq 0x1771f(%rip), %rdi     # 0x2589d
leaq 0x1760a(%rip), %rsi     # 0x2578f
movl $0x67, %edx
leaq 0x1771c(%rip), %rcx     # 0x258ad
callq 0x52e0
movq -0xe8(%rbp), %rax
testb $0x1, 0xed(%rax)
je 0xe1ab
jmp 0xe770
leaq 0x17725(%rip), %rdi     # 0x258d7
leaq 0x1772a(%rip), %rsi     # 0x258e3
callq 0x11280
leaq -0x38(%rbp), %rdi
callq 0x10b50
movq -0xe8(%rbp), %rax
movq %rax, %rsi
addq $0xf0, %rsi
movzbl 0xec(%rax), %edx
andl $0x1, %edx
leaq -0x48(%rbp), %rdi
callq 0x11290
jmp 0xe1ed
movq -0xe8(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x112e0
leaq -0x48(%rbp), %rdi
callq 0x11310
leaq -0x88(%rbp), %rdi
callq 0x10b70
movq -0xe8(%rbp), %rax
movq %rax, %rsi
addq $0x118, %rsi            # imm = 0x118
movzbl 0xec(%rax), %edx
andl $0x1, %edx
leaq -0x98(%rbp), %rdi
callq 0x11290
jmp 0xe23b
movq -0xe8(%rbp), %rsi
addq $0x60, %rsi
leaq -0x88(%rbp), %rdi
callq 0x11350
leaq -0x98(%rbp), %rdi
callq 0x11310
movq -0xe8(%rbp), %rax
movb $0x1, 0xed(%rax)
leaq -0x38(%rbp), %rdi
callq 0x11380
movq %rax, -0xa0(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x113e0
movq %rax, -0xa8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x113b0
testb $0x1, %al
jne 0xe2a8
jmp 0xe3b7
leaq -0xa0(%rbp), %rdi
callq 0x11410
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11430
movq %rax, %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movb %al, -0xe9(%rbp)
jmp 0xe2d4
movb -0xe9(%rbp), %al
testb $0x1, %al
jne 0xe2e0
jmp 0xe326
movq -0xe8(%rbp), %rax
movl 0xe0(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0xe0(%rax)
jmp 0xe33c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xe779
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x10d50
jmp 0xe779
movq -0xe8(%rbp), %rax
movl 0xe4(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0xe4(%rax)
movq -0xe8(%rbp), %rax
movq 0xc0(%rax), %rax
movq %rax, -0xf8(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x11410
movq -0xf8(%rbp), %rdi
movq (%rax), %rsi
movq (%rdi), %rax
movq 0x50(%rax), %rax
xorl %edx, %edx
callq *%rax
jmp 0xe374
jmp 0xe376
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
callq 0x11490
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x11450
movq %rax, -0x100(%rbp)
jmp 0xe3a4
movq -0x100(%rbp), %rax
movq %rax, -0xb8(%rbp)
jmp 0xe27c
movq -0xe8(%rbp), %rdi
addq $0x30, %rdi
callq 0x11380
movq %rax, -0xc0(%rbp)
movq -0xe8(%rbp), %rdi
addq $0x30, %rdi
callq 0x113e0
movq %rax, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x113b0
testb $0x1, %al
jne 0xe401
jmp 0xe4ef
leaq -0xc0(%rbp), %rdi
callq 0x11410
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11430
movq %rax, %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movb %al, -0x101(%rbp)
jmp 0xe42d
movb -0x101(%rbp), %al
testb $0x1, %al
jne 0xe439
jmp 0xe497
leaq -0xc0(%rbp), %rdi
callq 0x11410
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11430
movq %rax, %rdi
callq 0x1b310
movq %rax, -0x110(%rbp)
jmp 0xe462
movq -0xe8(%rbp), %rax
movq -0x110(%rbp), %rcx
movq %rcx, -0xd0(%rbp)
movq 0xc0(%rax), %rdi
movq -0xd0(%rbp), %rdx
movq (%rdi), %rax
movq 0x30(%rax), %rax
xorl %ecx, %ecx
movq %rdx, %rsi
callq *%rax
jmp 0xe495
jmp 0xe497
jmp 0xe499
movq -0xe8(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x120(%rbp)
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
callq 0x11490
movq -0x120(%rbp), %rdi
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rsi
callq 0x11450
movq %rax, -0x118(%rbp)
jmp 0xe4dc
movq -0x118(%rbp), %rax
movq %rax, -0xe0(%rbp)
jmp 0xe3ce
movq -0xe8(%rbp), %rdi
addq $0x90, %rdi
callq 0x114d0
leaq -0x88(%rbp), %rdi
callq 0x114f0
movq -0xe8(%rbp), %rdi
addq $0x198, %rdi            # imm = 0x198
callq 0x11510
jmp 0xe523
movq -0xe8(%rbp), %rdi
addq $0x188, %rdi            # imm = 0x188
callq 0x11550
jmp 0xe538
movq -0xe8(%rbp), %rdi
addq $0x180, %rdi            # imm = 0x180
callq 0x11550
jmp 0xe54d
movq -0xe8(%rbp), %rdi
addq $0x170, %rdi            # imm = 0x170
callq 0x11590
jmp 0xe562
movq -0xe8(%rbp), %rdi
addq $0x178, %rdi            # imm = 0x178
callq 0x11590
jmp 0xe577
movq -0xe8(%rbp), %rdi
addq $0x1a0, %rdi            # imm = 0x1A0
callq 0x239d0
jmp 0xe58c
movq -0xe8(%rbp), %rdi
addq $0x1c8, %rdi            # imm = 0x1C8
callq 0x239d0
jmp 0xe5a1
movq -0xe8(%rbp), %rdi
addq $0x30, %rdi
callq 0x115d0
testb $0x1, %al
jne 0xe5b7
jmp 0xe5b9
jmp 0xe5d8
leaq 0x17334(%rip), %rdi     # 0x258f4
leaq 0x171c8(%rip), %rsi     # 0x2578f
movl $0x94, %edx
leaq 0x172da(%rip), %rcx     # 0x258ad
callq 0x52e0
leaq -0x38(%rbp), %rdi
callq 0x115d0
testb $0x1, %al
jne 0xe5e7
jmp 0xe5e9
jmp 0xe608
leaq 0x17319(%rip), %rdi     # 0x25909
leaq 0x17198(%rip), %rsi     # 0x2578f
movl $0x95, %edx
leaq 0x172aa(%rip), %rcx     # 0x258ad
callq 0x52e0
movq -0xe8(%rbp), %rdi
callq 0x115d0
testb $0x1, %al
jne 0xe61a
jmp 0xe61c
jmp 0xe63b
leaq 0x172fc(%rip), %rdi     # 0x2591f
leaq 0x17165(%rip), %rsi     # 0x2578f
movl $0x96, %edx
leaq 0x17277(%rip), %rcx     # 0x258ad
callq 0x52e0
leaq -0x88(%rbp), %rdi
callq 0x115f0
testb $0x1, %al
jne 0xe64d
jmp 0xe64f
jmp 0xe66e
leaq 0x172dd(%rip), %rdi     # 0x25933
leaq 0x17132(%rip), %rsi     # 0x2578f
movl $0x97, %edx
leaq 0x17244(%rip), %rcx     # 0x258ad
callq 0x52e0
movq -0xe8(%rbp), %rdi
addq $0x90, %rdi
callq 0x11610
testb $0x1, %al
jne 0xe687
jmp 0xe689
jmp 0xe6a8
leaq 0x172b1(%rip), %rdi     # 0x25941
leaq 0x170f8(%rip), %rsi     # 0x2578f
movl $0x98, %edx
leaq 0x1720a(%rip), %rcx     # 0x258ad
callq 0x52e0
movq -0xe8(%rbp), %rax
cmpl $0x0, 0xe0(%rax)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xe6c1
jmp 0xe6c3
jmp 0xe6e2
leaq 0x1728e(%rip), %rdi     # 0x25958
leaq 0x170be(%rip), %rsi     # 0x2578f
movl $0x99, %edx
leaq 0x171d0(%rip), %rcx     # 0x258ad
callq 0x52e0
movq -0xe8(%rbp), %rax
cmpl $0x0, 0xe4(%rax)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xe6fb
jmp 0xe6fd
jmp 0xe71c
leaq 0x1726b(%rip), %rdi     # 0x2596f
leaq 0x17084(%rip), %rsi     # 0x2578f
movl $0x9a, %edx
leaq 0x17196(%rip), %rcx     # 0x258ad
callq 0x52e0
leaq 0x171b4(%rip), %rdi     # 0x258d7
leaq 0x1725c(%rip), %rsi     # 0x25986
callq 0x11630
jmp 0xe731
movq -0xe8(%rbp), %rdi
addq $0x190, %rdi            # imm = 0x190
callq 0x10f40
movq %rax, -0x128(%rbp)
jmp 0xe74d
movq -0x128(%rbp), %rdi
callq 0x5530
jmp 0xe75b
leaq -0x88(%rbp), %rdi
callq 0x10d50
leaq -0x38(%rbp), %rdi
callq 0x10d70
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x10d70
movq -0x50(%rbp), %rdi
callq 0x5710
nopl (%rax,%rax)