// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
testq %rsi, %rsi
jne 0x3a6f
callq 0x2ce5
jmp 0x3bf9
movq %rsi, %r14
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x21d0
leaq 0x30(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2100
leaq 0x256e(%rip), %rdx      # 0x6004
leaq 0x10(%rsp), %r15
movl $0x12, %esi
movq %r15, %rdi
movq %r12, %rcx
callq 0x2180
movq 0x5526(%rip), %r13      # 0x8fd8
movq (%r13), %r12
callq 0x21b0
movq %rax, %rbx
movl 0x4(%r14), %edi
callq 0x20e0
movzwl 0x2(%r14), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movl %ecx, (%rsp)
leaq 0x2752(%rip), %rsi      # 0x622f
leaq 0x2697(%rip), %r8       # 0x617b
movq %r12, %rdi
movq %r15, %rdx
movq %rbx, %rcx
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2080
testl %eax, %eax
jns 0x3b6a
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x21d0
leaq 0x30(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2100
leaq 0x24d4(%rip), %rdx      # 0x6004
leaq 0x10(%rsp), %r15
movl $0x12, %esi
movq %r15, %rdi
movq %r12, %rcx
callq 0x2180
movq (%r13), %r12
movl 0x4(%r14), %edi
callq 0x20e0
movzwl 0x2(%r14), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movl %ecx, (%rsp)
leaq 0x26f9(%rip), %rsi      # 0x6261
jmp 0x3bdf
movl %eax, %ebp
movl %eax, %edi
movq %r14, %rsi
movl $0x10, %edx
callq 0x21a0
leaq 0x8(%rsp), %r15
movq %r15, %rdi
testl %eax, %eax
jns 0x3c0f
callq 0x21d0
leaq 0x30(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2100
leaq 0x245d(%rip), %rdx      # 0x6004
leaq 0x10(%rsp), %r15
movl $0x12, %esi
movq %r15, %rdi
movq %r12, %rcx
callq 0x2180
movq (%r13), %r12
movl 0x4(%r14), %edi
callq 0x20e0
movzwl 0x2(%r14), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movl %ecx, (%rsp)
leaq 0x26ba(%rip), %rsi      # 0x6299
leaq 0x2595(%rip), %r8       # 0x617b
movq %r12, %rdi
movq %r15, %rdx
movq %rbx, %rcx
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x21d0
leaq 0x30(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2100
leaq 0x23d9(%rip), %rdx      # 0x6004
leaq 0x10(%rsp), %r15
movl $0x12, %esi
movq %r15, %rdi
movq %r12, %rcx
callq 0x2180
movq (%r13), %r12
movl 0x4(%r14), %edi
callq 0x20e0
movzwl 0x2(%r14), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movl %ecx, (%rsp)
leaq 0x266b(%rip), %rsi      # 0x62ce
leaq 0x2511(%rip), %r8       # 0x617b
movq %r12, %rdi
movq %r15, %rdx
movq %rbx, %rcx
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
jmp 0x3bfe
nop