// File: /workspace/github_cpp_makefile_star2_O2/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 0x3618
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x21d0
leaq 0x30(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2100
leaq 0x2a31(%rip), %rdx      # 0x6004
leaq 0x10(%rsp), %rbx
pushq $0x12
popq %rsi
movq %rbx, %rdi
movq %r14, %rcx
callq 0x2180
movq 0x69eb(%rip), %rax      # 0x9fd8
movq (%rax), %r14
callq 0x21b0
leaq 0x2c0e(%rip), %rsi      # 0x620a
leaq 0x2b78(%rip), %r8       # 0x617b
movq %r14, %rdi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x22e0
jmp 0x3796
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 0x29c5(%rip), %rdx      # 0x6004
leaq 0x10(%rsp), %r15
pushq $0x12
popq %rsi
movq %r15, %rdi
movq %r12, %rcx
callq 0x2180
movq 0x697f(%rip), %r13      # 0x9fd8
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 0x2bab(%rip), %rsi      # 0x622f
leaq 0x2af0(%rip), %r8       # 0x617b
movq %r12, %rdi
movq %r15, %rdx
movq %rbx, %rcx
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
pushq $0x2
popq %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x2080
testl %eax, %eax
jns 0x370b
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x21d0
leaq 0x30(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2100
leaq 0x2931(%rip), %rdx      # 0x6004
leaq 0x10(%rsp), %r15
pushq $0x12
popq %rsi
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 0x2b58(%rip), %rsi      # 0x6261
jmp 0x377c
movl %eax, %ebp
pushq $0x10
popq %rdx
movl %eax, %edi
movq %r14, %rsi
callq 0x21a0
leaq 0x8(%rsp), %r15
movq %r15, %rdi
testl %eax, %eax
jns 0x37aa
callq 0x21d0
leaq 0x30(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2100
leaq 0x28be(%rip), %rdx      # 0x6004
leaq 0x10(%rsp), %r15
pushq $0x12
popq %rsi
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 0x2b1d(%rip), %rsi      # 0x6299
leaq 0x29f8(%rip), %r8       # 0x617b
movq %r12, %rdi
movq %r15, %rdx
movq %rbx, %rcx
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
pushq $-0x1
popq %rbp
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 0x283e(%rip), %rdx      # 0x6004
leaq 0x10(%rsp), %r15
pushq $0x12
popq %rsi
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 0x2ad2(%rip), %rsi      # 0x62ce
leaq 0x2978(%rip), %r8       # 0x617b
movq %r12, %rdi
movq %r15, %rdx
movq %rbx, %rcx
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
jmp 0x3799