// File: theuni[P]libbtcnet/src/handler.cpp
// Function: CConnectionHandlerInt::OnConnectionFailure(long, ConnectionFailureType, int, CConnection, bool)
void CConnectionHandlerInt::OnConnectionFailure(ConnID id, ConnectionFailureType type, int /*error*/, CConnection failed, bool retry)
{
    assert(IsEventThread());
    auto it = m_connecting.find(id);
    assert(it != m_connecting.end());
    auto ptr = std::move(it->second);
    m_connecting.erase(it);
    retry = retry && !m_shutdown;
    bool ret = false;

    if ((type & ConnectionFailureType::PROXY) != 0)
        ret = m_interface.OnProxyFailure(failed, retry);
    else if ((type & ConnectionFailureType::RESOLVE) != 0)
        ret = m_interface.OnDnsFailure(std::move(failed), retry);
    else
        ret = m_interface.OnConnectionFailure(failed, failed, retry);
    if (retry && ret) {
        ConnID newId = GetNextConnectionIndex();
        auto newit = m_connecting.emplace_hint(m_connecting.end(), newId, std::move(ptr));
        newit->second->Retry(newId);
    } else if (m_request_event)
        m_request_event.active();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %r8, -0x98(%rbp)
movb %r9b, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0xe790
testb $0x1, %al
jne 0xf1d2
jmp 0xf1d4
jmp 0xf1f3
leaq 0x166c2(%rip), %rdi     # 0x2589d
leaq 0x165ad(%rip), %rsi     # 0x2578f
movl $0x103, %edx            # imm = 0x103
leaq 0x169b2(%rip), %rcx     # 0x25ba0
callq 0x52e0
movq -0x90(%rbp), %rdi
addq $0x30, %rdi
leaq -0x10(%rbp), %rsi
callq 0x11800
movq -0x90(%rbp), %rdi
movq %rax, -0x30(%rbp)
addq $0x30, %rdi
callq 0x113e0
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x113b0
testb $0x1, %al
jne 0xf232
jmp 0xf234
jmp 0xf253
leaq 0x169cc(%rip), %rdi     # 0x25c07
leaq 0x1654d(%rip), %rsi     # 0x2578f
movl $0x105, %edx            # imm = 0x105
leaq 0x16952(%rip), %rcx     # 0x25ba0
callq 0x52e0
leaq -0x30(%rbp), %rdi
callq 0x11410
movq %rax, %rsi
addq $0x8, %rsi
leaq -0x40(%rbp), %rdi
callq 0x11990
movq -0x90(%rbp), %rdi
addq $0x30, %rdi
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rsi
callq 0x11450
movq %rax, -0xa0(%rbp)
jmp 0xf291
movq -0xa0(%rbp), %rax
movq %rax, -0x60(%rbp)
xorl %eax, %eax
testb $0x1, -0x21(%rbp)
movb %al, -0xa1(%rbp)
je 0xf2bf
movq -0x90(%rbp), %rax
movb 0xed(%rax), %al
xorb $-0x1, %al
movb %al, -0xa1(%rbp)
movb -0xa1(%rbp), %al
andb $0x1, %al
movb %al, -0x21(%rbp)
movb $0x0, -0x61(%rbp)
movl -0x14(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0xf330
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rax
movq 0xc0(%rax), %rdi
movq (%rdi), %rax
movq 0x38(%rax), %rax
movzbl -0x21(%rbp), %edx
andl $0x1, %edx
callq *%rax
movb %al, -0xa2(%rbp)
jmp 0xf306
movb -0xa2(%rbp), %al
andb $0x1, %al
movb %al, -0x61(%rbp)
jmp 0xf3b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x118d0
jmp 0xf4b7
movl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xf375
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rax
movq 0xc0(%rax), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
movzbl -0x21(%rbp), %edx
andl $0x1, %edx
callq *%rax
movb %al, -0xa3(%rbp)
jmp 0xf368
movb -0xa3(%rbp), %al
andb $0x1, %al
movb %al, -0x61(%rbp)
jmp 0xf3b0
movq -0x98(%rbp), %rdx
movq -0x90(%rbp), %rax
movq 0xc0(%rax), %rdi
movq (%rdi), %rax
movq 0x30(%rax), %rax
movzbl -0x21(%rbp), %ecx
andl $0x1, %ecx
movq %rdx, %rsi
callq *%rax
movb %al, -0xa4(%rbp)
jmp 0xf3a5
movb -0xa4(%rbp), %al
andb $0x1, %al
movb %al, -0x61(%rbp)
jmp 0xf3b2
testb $0x1, -0x21(%rbp)
je 0xf465
testb $0x1, -0x61(%rbp)
je 0xf465
movq -0x90(%rbp), %rdi
callq 0xee20
movq %rax, -0xb0(%rbp)
jmp 0xf3db
movq -0x90(%rbp), %rdi
movq -0xb0(%rbp), %rax
movq %rax, -0x70(%rbp)
addq $0x30, %rdi
movq %rdi, -0xc0(%rbp)
callq 0x113e0
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x118b0
movq -0xc0(%rbp), %rdi
movq -0x80(%rbp), %rsi
leaq -0x70(%rbp), %rdx
leaq -0x40(%rbp), %rcx
callq 0x11860
movq %rax, -0xb8(%rbp)
jmp 0xf435
movq -0xb8(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x11410
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11430
movq %rax, %rdi
movq -0x70(%rbp), %rsi
callq 0x1b000
jmp 0xf463
jmp 0xf4a5
movq -0x90(%rbp), %rdi
addq $0x1a0, %rdi            # imm = 0x1A0
callq 0x239f0
movb %al, -0xc1(%rbp)
jmp 0xf480
movb -0xc1(%rbp), %al
testb $0x1, %al
jne 0xf48c
jmp 0xf4a3
movq -0x90(%rbp), %rdi
addq $0x1a0, %rdi            # imm = 0x1A0
callq 0x23ac0
jmp 0xf4a1
jmp 0xf4a3
jmp 0xf4a5
leaq -0x40(%rbp), %rdi
callq 0x118d0
addq $0xd0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x5710