// File: /workspace/github_cpp_makefile_star2_O1/enbock[P]Warp10Server/ulib/src/Socket.cpp
// Function: u::Socket::connect()
bool u::Socket::connect()
{
	if(isConnected()) return false;

	lock();
	switch(_domain)
	{
		case AF_UNIX:
		{
			_con = ::connect(
				_descriptor
				, (const sockaddr*)_addr
				, _addrLen
			);
		} break;
		case AF_INET:
		case AF_INET6:
		default:
		{
			struct addrinfo hints, *servinfo, *p;
			memset(&hints, 0, sizeof hints);
			hints.ai_family = _domain;
			hints.ai_socktype = _type;

			if(::getaddrinfo(_hostname.c_str(), int2string((int)_port).c_str(), &hints, &servinfo) != 0)
			{
				error(className()+"::connect: Can't resolv hostname "+_hostname+":"
					+int2string(_port));
				return false;
			}

			for(p = servinfo; p != NULL; p = p->ai_next)
			{
				((struct sockaddr_in *)_addr)->sin_addr = ((struct sockaddr_in*)p->ai_addr)->sin_addr;
				_con = ::connect(_descriptor, (const struct sockaddr*)_addr, _addrLen);
				if(isConnected())
				{
					break;
				}
			}

			freeaddrinfo(servinfo);
		} break;
	}
	unlock();
	return isConnected();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rdi, %rbx
callq 0x410246
movl 0x54(%rbx), %ebp
movq %rbx, %rdi
callq 0x4101fe
cmpl $-0x1, %ebp
je 0x4122f8
xorl %ebp, %ebp
jmp 0x412747
movq %rbx, %rdi
callq 0x410246
movl 0x38(%rbx), %eax
cmpl $0x1, %eax
jne 0x41231f
movl 0x34(%rbx), %edi
movq 0x48(%rbx), %rsi
movl 0x50(%rbx), %edx
callq 0x5607c0
movl %eax, 0x54(%rbx)
jmp 0x412727
xorps %xmm0, %xmm0
leaq 0x140(%rsp), %r14
movaps %xmm0, (%r14)
movaps %xmm0, 0x10(%r14)
movaps %xmm0, 0x20(%r14)
movl %eax, 0x4(%r14)
movl 0x40(%rbx), %eax
movl %eax, 0x8(%r14)
movq 0x90(%rbx), %r15
movl 0xb0(%rbx), %esi
leaq 0x90(%rsp), %r12
movq %r12, %rdi
callq 0x410522
movq 0x38(%r12), %rsi
leaq 0x48(%rsp), %rcx
movq %r15, %rdi
movq %r14, %rdx
callq 0x55ad00
movl %eax, %ebp
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x412398
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x90(%rsp), %rdi
callq 0x410354
testl %ebp, %ebp
je 0x412413
movq $0x653b20, %rdi         # imm = 0x653B20
leaq 0x1bbd9c(%rip), %rsi    # 0x5ce153
movl $0x7, %edx
callq 0x490a00
movq (%rbx), %rax
leaq 0x90(%rsp), %rdi
movq %rbx, %rsi
callq *0x8(%rax)
leaq 0xc8(%rsp), %rdi
leaq 0x1bc933(%rip), %rsi    # 0x5ced14
callq 0x4a25e0
leaq 0x80(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x412468
movq %rdx, 0x70(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x80(%rsp)
jmp 0x412470
movq 0x48(%rsp), %r14
testq %r14, %r14
je 0x412459
movq 0x18(%r14), %rax
movq 0x48(%rbx), %rsi
movl 0x4(%rax), %eax
movl %eax, 0x4(%rsi)
movl 0x34(%rbx), %edi
movl 0x50(%rbx), %edx
callq 0x5607c0
movl %eax, 0x54(%rbx)
movq %rbx, %rdi
callq 0x410246
movl 0x54(%rbx), %r15d
movq %rbx, %rdi
callq 0x4101fe
cmpl $-0x1, %r15d
jne 0x412459
movq 0x28(%r14), %r14
jmp 0x412418
movq 0x48(%rsp), %rdi
callq 0x55d280
jmp 0x41271f
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
leaq 0x70(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x90(%rbx), %rsi
movq 0x98(%rbx), %rdx
callq 0x4a24a0
leaq 0x60(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4124c6
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x4124cc
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
leaq 0x50(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x1c413e(%rip), %rsi    # 0x5d662d
callq 0x4a25e0
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x41251b
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x412522
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x30(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl 0xb0(%rbx), %esi
leaq 0xe8(%rsp), %rdi
callq 0x410522
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %r8
movq 0x128(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r15, %rcx
je 0x412572
movq 0x38(%rsp), %rsi
leaq 0x130(%rsp), %r12
cmpq %rsi, %rax
jbe 0x41259b
movl $0xf, %esi
cmpq %r12, 0x120(%rsp)
je 0x412596
movq 0x130(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x4125af
movq 0x120(%rsp), %rsi
leaq 0x28(%rsp), %rdi
callq 0x4a24a0
jmp 0x4125c0
leaq 0x120(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4a1e20
leaq 0x18(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x4125e4
movq %rsi, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x4125ea
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq $0x653b20, %rdi         # imm = 0x653B20
callq 0x490a00
movq %rax, %r14
leaq 0x1bba84(%rip), %rsi    # 0x5ce0ab
movl $0x4, %edx
movq %rax, %rdi
callq 0x490a00
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x471b50
movsbl %al, %esi
movq %r14, %rdi
callq 0x490500
movq %rax, %rdi
callq 0x48fad0
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x412676
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x426f20
movq 0x120(%rsp), %rdi
cmpq %r12, %rdi
je 0x412693
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0xe8(%rsp), %rdi
callq 0x410354
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
leaq 0xd8(%rsp), %r14
je 0x4126bf
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x426f20
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x4126db
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x426f20
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0x4126f5
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x426f20
movq 0xc8(%rsp), %rdi
cmpq %r14, %rdi
je 0x412712
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x90(%rsp), %rdi
callq 0x410354
testl %ebp, %ebp
jne 0x4122f1
movq %rbx, %rdi
callq 0x4101fe
movq %rbx, %rdi
callq 0x410246
cmpl $-0x1, 0x54(%rbx)
setne %bpl
movq %rbx, %rdi
callq 0x4101fe
movl %ebp, %eax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x412794
movq %rax, %rbx
jmp 0x4127a1
movq %rax, %rbx
jmp 0x4127b8
movq %rax, %rbx
jmp 0x4127d4
jmp 0x412771
movq %rax, %rbx
jmp 0x4127ee
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x412794
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0xe8(%rsp), %rdi
callq 0x40512a
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x4127b8
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x426f20
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x4127d4
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x426f20
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0x4127ee
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x90(%rsp), %rdi
callq 0x40512a
movq %rbx, %rdi
callq 0x4d11b0
nop