// File: /workspace/github_cpp_makefile_star2_O2/tenup-coin[P]seeder/netbase.cpp
// Function: CNetAddr::GetReachabilityFrom(CNetAddr const*) const
int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const
{
    enum Reachability {
        REACH_UNREACHABLE,
        REACH_DEFAULT,
        REACH_TEREDO,
        REACH_IPV6_WEAK,
        REACH_IPV4,
        REACH_IPV6_STRONG,
        REACH_PRIVATE
    };

    if (!IsRoutable())
        return REACH_UNREACHABLE;

    int ourNet = GetExtNetwork(this);
    int theirNet = GetExtNetwork(paddrPartner);
    bool fTunnel = IsRFC3964() || IsRFC6052() || IsRFC6145();

    switch(theirNet) {
    case NET_IPV4:
        switch(ourNet) {
        default:       return REACH_DEFAULT;
        case NET_IPV4: return REACH_IPV4;
        }
    case NET_IPV6:
        switch(ourNet) {
        default:         return REACH_DEFAULT;
        case NET_TEREDO: return REACH_TEREDO;
        case NET_IPV4:   return REACH_IPV4;
        case NET_IPV6:   return fTunnel ? REACH_IPV6_WEAK : REACH_IPV6_STRONG; // only prefer giving our IPv6 address if it's not tunnelled
        }
    case NET_TOR:
        switch(ourNet) {
        default:         return REACH_DEFAULT;
        case NET_IPV4:   return REACH_IPV4; // Tor users can connect to IPv4 as well
        case NET_TOR:    return REACH_PRIVATE;
        }
    case NET_I2P:
        switch(ourNet) {
        default:         return REACH_DEFAULT;
        case NET_I2P:    return REACH_PRIVATE;
        }
    case NET_TEREDO:
        switch(ourNet) {
        default:          return REACH_DEFAULT;
        case NET_TEREDO:  return REACH_TEREDO;
        case NET_IPV6:    return REACH_IPV6_WEAK;
        case NET_IPV4:    return REACH_IPV4;
        }
    case NET_UNKNOWN:
    case NET_UNROUTABLE:
    default:
        switch(ourNet) {
        default:          return REACH_DEFAULT;
        case NET_TEREDO:  return REACH_TEREDO;
        case NET_IPV6:    return REACH_IPV6_WEAK;
        case NET_IPV4:    return REACH_IPV4;
        case NET_I2P:     return REACH_PRIVATE; // assume connections from unroutable addresses are
        case NET_TOR:     return REACH_PRIVATE; // either from Tor/I2P, or don't care about our address
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
callq 0x857a
xorl %ebp, %ebp
testb %al, %al
je 0x8aa5
movq %r15, %rdi
callq 0x8ab6
movl %eax, %ebx
movq %r14, %rdi
callq 0x8ab6
movl %eax, %r14d
cmpb $0x20, (%r15)
pushq $0x3
popq %rbp
jne 0x89f9
cmpb $0x2, 0x1(%r15)
je 0x8a19
movq %r15, %rdi
callq 0x84a2
testb %al, %al
jne 0x8a19
movq %r15, %rdi
callq 0x84ec
xorb $0x1, %al
movzbl %al, %eax
leal 0x3(,%rax,2), %ebp
decl %r14d
cmpl $0x5, %r14d
ja 0x8a41
leaq 0x9857(%rip), %rax      # 0x12280
movslq (%rax,%r14,4), %rcx
addq %rax, %rcx
jmpq *%rcx
xorl %eax, %eax
cmpl $0x1, %ebx
sete %al
leal (%rax,%rax,2), %ebp
incl %ebp
jmp 0x8aa5
decl %ebx
cmpl $0x6, %ebx
jae 0x8aa2
movl %ebx, %eax
leaq 0x98b7(%rip), %rcx      # 0x12308
jmp 0x8a9d
xorl %eax, %eax
cmpl $0x3, %ebx
sete %al
leal (%rax,%rax,4), %eax
incl %eax
cmpl $0x1, %ebx
pushq $0x4
popq %rbp
cmovnel %eax, %ebp
jmp 0x8aa5
cmpl $0x1, %ebx
je 0x8ab2
cmpl $0x2, %ebx
je 0x8aa5
cmpl $0x6, %ebx
jne 0x8aa2
pushq $0x2
jmp 0x8aa4
xorl %eax, %eax
cmpl $0x4, %ebx
sete %al
leal (%rax,%rax,4), %ebp
incl %ebp
jmp 0x8aa5
decl %ebx
cmpl $0x6, %ebx
jae 0x8aa2
movl %ebx, %eax
leaq 0x9853(%rip), %rcx      # 0x122f0
movl (%rcx,%rax,4), %ebp
jmp 0x8aa5
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x4
jmp 0x8aa4