// File: tenup-coin[P]seeder/netbase.cpp
// Function: SplitHostPort(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
void SplitHostPort(std::string in, int &portOut, std::string &hostOut) {
    size_t colon = in.find_last_of(':');
    // if a : is found, and it either follows a [...], or no other : is in the string, treat it as port separator
    bool fHaveColon = colon != in.npos;
    bool fBracketed = fHaveColon && (in[0]=='[' && in[colon-1]==']'); // if there is a colon, and in[0]=='[', colon is not 0, so in[colon-1] is safe
    bool fMultiColon = fHaveColon && (in.find_last_of(':',colon-1) != in.npos);
    if (fHaveColon && (colon==0 || fBracketed || !fMultiColon)) {
        char *endp = NULL;
        int n = strtol(in.c_str() + colon + 1, &endp, 10);
        if (endp && *endp == 0 && n >= 0) {
            in = in.substr(0, colon);
            if (n > 0 && n < 0x10000)
                portOut = n;
        }
    }
    if (in.size()>0 && in[0] == '[' && in[in.size()-1] == ']')
        hostOut = in.substr(1, in.size()-2);
    else
        hostOut = in;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x88(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x3a, %esi
movq $-0x1, %rdx
callq 0x4890
movq %rax, -0x20(%rbp)
cmpq $-0x1, -0x20(%rbp)
setne %al
andb $0x1, %al
movb %al, -0x21(%rbp)
xorl %eax, %eax
testb $0x1, -0x21(%rbp)
movb %al, -0x79(%rbp)
je 0xf717
movq -0x88(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x48e0
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x5b, %ecx
movb %al, -0x89(%rbp)
jne 0xf70e
movq -0x88(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq $0x1, %rsi
callq 0x48e0
movsbl (%rax), %eax
cmpl $0x5d, %eax
sete %al
movb %al, -0x89(%rbp)
movb -0x89(%rbp), %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
andb $0x1, %al
movb %al, -0x22(%rbp)
xorl %eax, %eax
testb $0x1, -0x21(%rbp)
movb %al, -0x8a(%rbp)
je 0xf753
movq -0x88(%rbp), %rdi
movq -0x20(%rbp), %rdx
subq $0x1, %rdx
movl $0x3a, %esi
callq 0x4890
cmpq $-0x1, %rax
setne %al
movb %al, -0x8a(%rbp)
movb -0x8a(%rbp), %al
andb $0x1, %al
movb %al, -0x23(%rbp)
testb $0x1, -0x21(%rbp)
je 0xf815
cmpq $0x0, -0x20(%rbp)
je 0xf77f
testb $0x1, -0x22(%rbp)
jne 0xf77f
testb $0x1, -0x23(%rbp)
jne 0xf815
movq -0x88(%rbp), %rdi
movq $0x0, -0x30(%rbp)
callq 0x41e0
movq %rax, %rdi
addq -0x20(%rbp), %rdi
addq $0x1, %rdi
leaq -0x30(%rbp), %rsi
movl $0xa, %edx
callq 0x46c0
movl %eax, -0x34(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xf813
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0xf813
cmpl $0x0, -0x34(%rbp)
jl 0xf813
movq -0x88(%rbp), %rsi
movq -0x20(%rbp), %rcx
leaq -0x58(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
callq 0x44f0
movq -0x88(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x45d0
leaq -0x58(%rbp), %rdi
callq 0x42f0
cmpl $0x0, -0x34(%rbp)
jle 0xf811
cmpl $0x10000, -0x34(%rbp)   # imm = 0x10000
jge 0xf811
movl -0x34(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
jmp 0xf813
jmp 0xf815
movq -0x88(%rbp), %rdi
callq 0x4380
cmpq $0x0, %rax
jbe 0xf8a6
movq -0x88(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x48e0
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0xf8a6
movq -0x88(%rbp), %rdi
callq 0x4380
movq -0x88(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x48e0
movsbl (%rax), %eax
cmpl $0x5d, %eax
jne 0xf8a6
movq -0x88(%rbp), %rdi
callq 0x4380
movq -0x88(%rbp), %rsi
movq %rax, %rcx
subq $0x2, %rcx
leaq -0x78(%rbp), %rdi
movl $0x1, %edx
callq 0x44f0
movq -0x18(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x45d0
leaq -0x78(%rbp), %rdi
callq 0x42f0
jmp 0xf8b6
movq -0x88(%rbp), %rsi
movq -0x18(%rbp), %rdi
callq 0x4050
addq $0x90, %rsp
popq %rbp
retq
nop