// File: /workspace/github_cpp_makefile_star2_O3/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 0x3b5b
callq 0x2d02
jmp 0x3ce5
movq %rsi, %r14
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x21e0
leaq 0x30(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2100
leaq 0x2482(%rip), %rdx      # 0x6004
leaq 0x10(%rsp), %r15
movl $0x12, %esi
movq %r15, %rdi
movq %r12, %rcx
callq 0x2190
movq 0x543a(%rip), %r13      # 0x8fd8
movq (%r13), %r12
callq 0x21c0
movq %rax, %rbx
movl 0x4(%r14), %edi
callq 0x20e0
movzwl 0x2(%r14), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movl %ecx, (%rsp)
leaq 0x2666(%rip), %rsi      # 0x622f
leaq 0x25ab(%rip), %r8       # 0x617b
movq %r12, %rdi
movq %r15, %rdx
movq %rbx, %rcx
movq %rax, %r9
xorl %eax, %eax
callq 0x22f0
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2080
testl %eax, %eax
jns 0x3c56
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x21e0
leaq 0x30(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2100
leaq 0x23e8(%rip), %rdx      # 0x6004
leaq 0x10(%rsp), %r15
movl $0x12, %esi
movq %r15, %rdi
movq %r12, %rcx
callq 0x2190
movq (%r13), %r12
movl 0x4(%r14), %edi
callq 0x20e0
movzwl 0x2(%r14), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movl %ecx, (%rsp)
leaq 0x260d(%rip), %rsi      # 0x6261
jmp 0x3ccb
movl %eax, %ebp
movl %eax, %edi
movq %r14, %rsi
movl $0x10, %edx
callq 0x21b0
leaq 0x8(%rsp), %r15
movq %r15, %rdi
testl %eax, %eax
jns 0x3cfb
callq 0x21e0
leaq 0x30(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2100
leaq 0x2371(%rip), %rdx      # 0x6004
leaq 0x10(%rsp), %r15
movl $0x12, %esi
movq %r15, %rdi
movq %r12, %rcx
callq 0x2190
movq (%r13), %r12
movl 0x4(%r14), %edi
callq 0x20e0
movzwl 0x2(%r14), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movl %ecx, (%rsp)
leaq 0x25ce(%rip), %rsi      # 0x6299
leaq 0x24a9(%rip), %r8       # 0x617b
movq %r12, %rdi
movq %r15, %rdx
movq %rbx, %rcx
movq %rax, %r9
xorl %eax, %eax
callq 0x22f0
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 0x21e0
leaq 0x30(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2100
leaq 0x22ed(%rip), %rdx      # 0x6004
leaq 0x10(%rsp), %r15
movl $0x12, %esi
movq %r15, %rdi
movq %r12, %rcx
callq 0x2190
movq (%r13), %r12
movl 0x4(%r14), %edi
callq 0x20e0
movzwl 0x2(%r14), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movl %ecx, (%rsp)
leaq 0x257f(%rip), %rsi      # 0x62ce
leaq 0x2425(%rip), %r8       # 0x617b
movq %r12, %rdi
movq %r15, %rdx
movq %rbx, %rcx
movq %rax, %r9
xorl %eax, %eax
callq 0x22f0
jmp 0x3cea
nop