// File: /workspace/github_cpp_makefile_star2_O3/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 0x410226
movl 0x54(%rbx), %ebp
movq %rbx, %rdi
callq 0x4101de
cmpl $-0x1, %ebp
je 0x4122e4
xorl %ebp, %ebp
jmp 0x412724
movq %rbx, %rdi
callq 0x410226
movl 0x38(%rbx), %eax
cmpl $0x1, %eax
jne 0x41230b
movl 0x34(%rbx), %edi
movq 0x48(%rbx), %rsi
movl 0x50(%rbx), %edx
callq 0x560700
movl %eax, 0x54(%rbx)
jmp 0x412704
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 0x410514
movq 0x38(%r12), %rsi
leaq 0x48(%rsp), %rcx
movq %r15, %rdi
movq %r14, %rdx
callq 0x55ac40
movl %eax, %ebp
leaq 0xd8(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x412384
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x90(%rsp), %rdi
callq 0x410332
testl %ebp, %ebp
je 0x4123f9
movq $0x653b20, %rdi         # imm = 0x653B20
leaq 0x1bbdb0(%rip), %rsi    # 0x5ce153
movl $0x7, %edx
callq 0x490910
movq (%rbx), %rax
leaq 0x90(%rsp), %rdi
movq %rbx, %rsi
callq *0x8(%rax)
leaq 0xc8(%rsp), %rdi
leaq 0x1bc947(%rip), %rsi    # 0x5ced14
callq 0x4a24f0
leaq 0x60(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x41244e
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x412455
movq 0x48(%rsp), %r14
testq %r14, %r14
je 0x4126fd
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 0x560700
movl %eax, 0x54(%rbx)
movq %rbx, %rdi
callq 0x410226
movl 0x54(%rbx), %ebp
movq %rbx, %rdi
callq 0x4101de
cmpl $-0x1, %ebp
jne 0x412444
movq 0x28(%r14), %r14
testq %r14, %r14
jne 0x412407
movq 0x48(%rsp), %rdi
jmp 0x4126ff
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq 0x50(%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 0x4a23b0
leaq 0x80(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4124b2
movq %rdx, 0x70(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x80(%rsp)
jmp 0x4124ba
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq 0x70(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x1c4150(%rip), %rsi    # 0x5d662d
callq 0x4a24f0
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x412509
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x412511
movups (%rcx), %xmm0
movups %xmm0, (%r13)
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 0x410514
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %r8
movq 0x128(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r13, %rcx
je 0x412561
movq 0x38(%rsp), %rdi
leaq 0x130(%rsp), %rbp
movq -0x10(%rbp), %rsi
cmpq %rdi, %rax
jbe 0x412589
movl $0xf, %edi
cmpq %rbp, %rsi
je 0x412584
movq 0x130(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x412595
leaq 0x28(%rsp), %rdi
callq 0x4a23b0
jmp 0x4125a6
leaq 0x120(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4a1d30
leaq 0x18(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x4125ca
movq %rsi, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x4125d0
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 0x490910
movq %rax, %rbx
leaq 0x1bba9e(%rip), %rsi    # 0x5ce0ab
movl $0x4, %edx
movq %rax, %rdi
callq 0x490910
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x471a60
movsbl %al, %esi
movq %rbx, %rdi
callq 0x490410
movq %rax, %rdi
callq 0x48f9e0
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x41265c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x426e30
movq 0x120(%rsp), %rdi
cmpq %rbp, %rdi
je 0x412679
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0xe8(%rsp), %rdi
callq 0x410332
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x41269d
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x426e30
movq 0x70(%rsp), %rdi
cmpq %r12, %rdi
je 0x4126b7
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x426e30
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x4126ce
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x426e30
movq 0xc8(%rsp), %rdi
cmpq %r15, %rdi
je 0x4126eb
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x90(%rsp), %rdi
callq 0x410332
jmp 0x4122dd
xorl %edi, %edi
callq 0x55d1c0
movq %rbx, %rdi
callq 0x4101de
movq %rbx, %rdi
callq 0x410226
cmpl $-0x1, 0x54(%rbx)
setne %bpl
movq %rbx, %rdi
callq 0x4101de
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 0x412771
movq %rax, %rbx
jmp 0x41277e
movq %rax, %rbx
jmp 0x412795
movq %rax, %rbx
jmp 0x4127af
jmp 0x41274e
movq %rax, %rbx
jmp 0x4127c6
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x412771
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0xe8(%rsp), %rdi
callq 0x40512c
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x412795
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x426e30
movq 0x70(%rsp), %rdi
cmpq %r12, %rdi
je 0x4127af
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x426e30
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x4127c6
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x90(%rsp), %rdi
callq 0x40512c
movq %rbx, %rdi
callq 0x4d10c0
nop