// File: SeTriones[P]Anubis/base_nio_handler.cpp
// Function: base_nio_handler::connectSocket(sockaddr_in*)
int base_nio_handler::connectSocket(sockaddr_in* address) {
    int fd = -1;
    if (address == NULL) {
        _ERROR("null address");
        return -1;
    }
    _INFO("begin to connect to %s:%d", inet_ntoa(address->sin_addr), ntohs(address->sin_port));
    if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
        _ERROR("create socket fd error on %s:%d", inet_ntoa(address->sin_addr), ntohs(address->sin_port));
        return -1;
    }
    if (connect(fd, (struct sockaddr*)address, sizeof(*address)) < 0) {
        _ERROR("connect socket fail on %s:%d", inet_ntoa(address->sin_addr), ntohs(address->sin_port));
        return -1;
    }
    _INFO("connect to %s:%d success", inet_ntoa(address->sin_addr), ntohs(address->sin_port));
    return fd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
cmpq $0x0, -0x18(%rbp)
jne 0x404d
leaq -0x28(%rbp), %rdi
callq 0x21e0
leaq -0x28(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2120
leaq -0x80(%rbp), %rdi
movl $0x12, %esi
leaq 0x5019(%rip), %rdx      # 0x9004
leaq -0x60(%rbp), %rcx
callq 0x2190
movq 0x8fdd(%rip), %rax      # 0xcfd8
movq (%rax), %rax
movq %rax, -0x218(%rbp)
leaq -0x80(%rbp), %rax
movq %rax, -0x210(%rbp)
callq 0x21c0
movq -0x218(%rbp), %rdi
movq -0x210(%rbp), %rdx
movq %rax, %rcx
leaq 0x51dd(%rip), %rsi      # 0x920a
leaq 0x5147(%rip), %r8       # 0x917b
movb $0x0, %al
callq 0x2310
movl %eax, -0x84(%rbp)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x43ea
leaq -0x90(%rbp), %rdi
callq 0x21e0
leaq -0x90(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x2120
leaq -0xe0(%rbp), %rdi
movl $0x12, %esi
leaq 0x4f85(%rip), %rdx      # 0x9004
leaq -0xc8(%rbp), %rcx
callq 0x2190
movq 0x8f46(%rip), %rax      # 0xcfd8
movq (%rax), %rax
movq %rax, -0x238(%rbp)
leaq -0xe0(%rbp), %rax
movq %rax, -0x230(%rbp)
callq 0x21c0
movq %rax, -0x228(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0xe8(%rbp)
movl -0xe8(%rbp), %edi
callq 0x2100
movq %rax, -0x220(%rbp)
movq -0x18(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x2400
movq -0x238(%rbp), %rdi
movq -0x230(%rbp), %rdx
movq -0x228(%rbp), %rcx
movq -0x220(%rbp), %r9
movzwl %ax, %eax
leaq 0x5127(%rip), %rsi      # 0x922f
leaq 0x506c(%rip), %r8       # 0x917b
movl %eax, (%rsp)
movb $0x0, %al
callq 0x2310
movl %eax, -0xe4(%rbp)
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x20a0
movl %eax, -0x1c(%rbp)
cmpl $0x0, %eax
jge 0x421a
leaq -0xf0(%rbp), %rdi
callq 0x21e0
leaq -0xf0(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x2120
leaq -0x140(%rbp), %rdi
movl $0x12, %esi
leaq 0x4e96(%rip), %rdx      # 0x9004
leaq -0x128(%rbp), %rcx
callq 0x2190
movq 0x8e57(%rip), %rax      # 0xcfd8
movq (%rax), %rax
movq %rax, -0x258(%rbp)
leaq -0x140(%rbp), %rax
movq %rax, -0x250(%rbp)
callq 0x21c0
movq %rax, -0x248(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x148(%rbp)
movl -0x148(%rbp), %edi
callq 0x2100
movq %rax, -0x240(%rbp)
movq -0x18(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x2400
movq -0x258(%rbp), %rdi
movq -0x250(%rbp), %rdx
movq -0x248(%rbp), %rcx
movq -0x240(%rbp), %r9
movzwl %ax, %eax
leaq 0x506a(%rip), %rsi      # 0x9261
leaq 0x4f7d(%rip), %r8       # 0x917b
movl %eax, (%rsp)
movb $0x0, %al
callq 0x2310
movl %eax, -0x144(%rbp)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x43ea
movl -0x1c(%rbp), %edi
movq -0x18(%rbp), %rsi
movl $0x10, %edx
callq 0x21b0
cmpl $0x0, %eax
jge 0x4312
leaq -0x150(%rbp), %rdi
callq 0x21e0
leaq -0x150(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x2120
leaq -0x1a0(%rbp), %rdi
movl $0x12, %esi
leaq 0x4d9e(%rip), %rdx      # 0x9004
leaq -0x188(%rbp), %rcx
callq 0x2190
movq 0x8d5f(%rip), %rax      # 0xcfd8
movq (%rax), %rax
movq %rax, -0x278(%rbp)
leaq -0x1a0(%rbp), %rax
movq %rax, -0x270(%rbp)
callq 0x21c0
movq %rax, -0x268(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x1a8(%rbp)
movl -0x1a8(%rbp), %edi
callq 0x2100
movq %rax, -0x260(%rbp)
movq -0x18(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x2400
movq -0x278(%rbp), %rdi
movq -0x270(%rbp), %rdx
movq -0x268(%rbp), %rcx
movq -0x260(%rbp), %r9
movzwl %ax, %eax
leaq 0x4faa(%rip), %rsi      # 0x9299
leaq 0x4e85(%rip), %r8       # 0x917b
movl %eax, (%rsp)
movb $0x0, %al
callq 0x2310
movl %eax, -0x1a4(%rbp)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x43ea
leaq -0x1b0(%rbp), %rdi
callq 0x21e0
leaq -0x1b0(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x2120
leaq -0x200(%rbp), %rdi
movl $0x12, %esi
leaq 0x4cc0(%rip), %rdx      # 0x9004
leaq -0x1e8(%rbp), %rcx
callq 0x2190
movq 0x8c81(%rip), %rax      # 0xcfd8
movq (%rax), %rax
movq %rax, -0x298(%rbp)
leaq -0x200(%rbp), %rax
movq %rax, -0x290(%rbp)
callq 0x21c0
movq %rax, -0x288(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x208(%rbp)
movl -0x208(%rbp), %edi
callq 0x2100
movq %rax, -0x280(%rbp)
movq -0x18(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x2400
movq -0x298(%rbp), %rdi
movq -0x290(%rbp), %rdx
movq -0x288(%rbp), %rcx
movq -0x280(%rbp), %r9
movzwl %ax, %eax
leaq 0x4f01(%rip), %rsi      # 0x92ce
leaq 0x4da7(%rip), %r8       # 0x917b
movl %eax, (%rsp)
movb $0x0, %al
callq 0x2310
movl %eax, -0x204(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
nopw %cs:(%rax,%rax)