// File: theuni[P]libbtcnet/src/connectionbase.cpp
// Function: ConnectionBase::DisconnectWhenFinishedInt()
void ConnectionBase::DisconnectWhenFinishedInt()
{
    assert(m_bev);
    bool now;
    {
        BufferEventLocker lock(m_bev);
        evbuffer* output = bufferevent_get_output(m_bev);
        if (evbuffer_get_length(output) != 0u) {
            DEBUG_PRINT(LOGINFO, "id:", m_id, "disconnecting when finished");
            bufferevent_disable(m_bev, EV_READ);
            bufferevent_setwatermark(m_bev, EV_WRITE, 0, 0);
            bufferevent_setcb(m_bev, nullptr, close_on_finished_writecb, event_cb, this);
            now = false;
        } else {
            bufferevent_disable(m_bev, EV_READ | EV_WRITE);
            bufferevent_setcb(m_bev, nullptr, nullptr, nullptr, nullptr);
            now = true;
        }
    }
    if (now)
        DisconnectInt(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x38(%rbp)
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x19d80
testb $0x1, %al
jne 0x1a919
jmp 0x1a91b
jmp 0x1a93a
leaq 0xbf01(%rip), %rdi      # 0x26823
leaq 0xc04f(%rip), %rsi      # 0x26978
movl $0x87, %edx
leaq 0xc147(%rip), %rcx      # 0x26a7c
callq 0x52e0
movq -0x38(%rbp), %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
movq %rdi, -0x48(%rbp)
callq 0x1a1a0
movq %rax, %rsi
leaq -0x18(%rbp), %rdi
callq 0x1c730
movq -0x48(%rbp), %rdi
callq 0x1a1a0
movq %rax, -0x40(%rbp)
jmp 0x1a969
movq -0x40(%rbp), %rdi
callq 0x5140
movq %rax, -0x50(%rbp)
jmp 0x1a978
movq -0x50(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5440
movq %rax, -0x58(%rbp)
jmp 0x1a98f
movq -0x58(%rbp), %rax
cmpq $0x0, %rax
je 0x1aa6b
movq -0x38(%rbp), %rdx
addq $0x190, %rdx            # imm = 0x190
leaq 0xc0fe(%rip), %rdi      # 0x26aad
leaq 0xb2e0(%rip), %rsi      # 0x25c96
leaq 0xc10a(%rip), %rcx      # 0x26ac7
callq 0x1c810
jmp 0x1a9c4
movq -0x38(%rbp), %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x1a1a0
movq %rax, -0x60(%rbp)
jmp 0x1a9da
movq -0x60(%rbp), %rdi
movl $0x2, %esi
callq 0x55e0
jmp 0x1a9ea
movq -0x38(%rbp), %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x1a1a0
movq %rax, -0x68(%rbp)
jmp 0x1aa00
movq -0x68(%rbp), %rdi
xorl %eax, %eax
movl %eax, %ecx
movl $0x4, %esi
movq %rcx, %rdx
callq 0x50f0
jmp 0x1aa17
movq -0x38(%rbp), %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x1a1a0
movq %rax, -0x70(%rbp)
jmp 0x1aa2d
movq -0x38(%rbp), %r8
movq -0x70(%rbp), %rdi
leaq 0x8f4(%rip), %rdx       # 0x1b330
leaq 0x94d(%rip), %rcx       # 0x1b390
xorl %eax, %eax
movl %eax, %esi
callq 0x5410
jmp 0x1aa4e
movb $0x0, -0x9(%rbp)
jmp 0x1aac4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x1c760
jmp 0x1aae7
movq -0x38(%rbp), %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x1a1a0
movq %rax, -0x78(%rbp)
jmp 0x1aa81
movq -0x78(%rbp), %rdi
movl $0x6, %esi
callq 0x55e0
jmp 0x1aa91
movq -0x38(%rbp), %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x1a1a0
movq %rax, -0x80(%rbp)
jmp 0x1aaa7
movq -0x80(%rbp), %rdi
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rsi
movq %r8, %rdx
movq %r8, %rcx
callq 0x5410
jmp 0x1aac0
movb $0x1, -0x9(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x1c760
testb $0x1, -0x9(%rbp)
je 0x1aade
movq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x1a770
addq $0x80, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x5710