// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/Proxy.cpp
// Function: Proxy::connectServer(Request const&, int&)
void connectServer(const Request & request, int & server_fd)
	{
		// initialize host info
		struct addrinfo host_info;
	    struct addrinfo * host_info_list;
	    memset(&host_info, 0, sizeof(host_info));
	    host_info.ai_family = AF_UNSPEC;
	    host_info.ai_socktype = SOCK_STREAM;

	    // get host information
	    const std::string & hostname = request.hostname;
	    const std::string & port = request.port;
	    status = getaddrinfo(hostname.c_str(), port.c_str(), &host_info, &host_info_list);
	    if(status != 0) 
	    {
	      	throw ProxyException("Connect server getaddrinfo error");
	    } 

	    // create socket
	    server_fd = socket(host_info_list->ai_family, 
	    					host_info_list->ai_socktype,
	                       	host_info_list->ai_protocol);
	    if(server_fd == -1) 
	    {
	    	freeaddrinfo(host_info_list);
	      	throw ProxyException("Connect server create socket error");
	    }

	    // connect a socket to a server
	    status = connect(server_fd, host_info_list->ai_addr, host_info_list->ai_addrlen);
	    if(status == -1) 
	    {
	    	freeaddrinfo(host_info_list);
	      	throw ProxyException("Connect socket to server error");
	    } 

	    // free address infor list
	    freeaddrinfo(host_info_list);
	}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0xa0, %rsp
movq %rdx, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, 0x20(%rdx)
movl $0x1, 0x8(%rdx)
movq 0x80(%rsi), %rdi
movq 0xa0(%rsi), %rsi
leaq 0x8(%rsp), %rcx
callq 0x3380
movl %eax, 0x2b0(%rbx)
testl %eax, %eax
jne 0x4bce
movq 0x8(%rsp), %rax
movl 0x4(%rax), %edi
movl 0x8(%rax), %esi
movl 0xc(%rax), %edx
callq 0x30a0
movl %eax, (%r14)
movq 0x8(%rsp), %rdi
cmpl $-0x1, %eax
je 0x4c1c
movq 0x18(%rdi), %rsi
movl 0x10(%rdi), %edx
movl %eax, %edi
callq 0x3290
movl %eax, %ebp
movl %eax, 0x2b0(%rbx)
movq 0x8(%rsp), %rdi
callq 0x33a0
cmpl $-0x1, %ebp
je 0x4c6c
addq $0xa0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x3190
movq %rax, %rbx
leaq 0x560e(%rip), %rsi      # 0xa1ee
leaq 0x50(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x386c
movb $0x1, %bpl
leaq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0x55e8
xorl %ebp, %ebp
leaq 0xb100(%rip), %rsi      # 0xfd08
leaq 0xa0f(%rip), %rdx       # 0x561e
movq %rbx, %rdi
callq 0x3490
jmp 0x4cb5
callq 0x33a0
pushq $0x28
popq %rdi
callq 0x3190
movq %rax, %rbx
leaq 0x55dc(%rip), %rsi      # 0xa20f
leaq 0x30(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x386c
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x55e8
xorl %ebp, %ebp
leaq 0xb0ad(%rip), %rsi      # 0xfd08
leaq 0x9bc(%rip), %rdx       # 0x561e
movq %rbx, %rdi
callq 0x3490
jmp 0x4cb5
pushq $0x28
popq %rdi
callq 0x3190
movq %rax, %rbx
leaq 0x55b4(%rip), %rsi      # 0xa232
leaq 0x10(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x386c
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x55e8
xorl %ebp, %ebp
leaq 0xb062(%rip), %rsi      # 0xfd08
leaq 0x971(%rip), %rdx       # 0x561e
movq %rbx, %rdi
callq 0x3490
movq %rax, %r14
leaq 0x10(%rsp), %rdi
jmp 0x4cd5
jmp 0x4ce1
movq %rax, %r14
leaq 0x30(%rsp), %rdi
jmp 0x4cd5
jmp 0x4ce1
movq %rax, %r14
leaq 0x50(%rsp), %rdi
callq 0x3150
testb %bpl, %bpl
jne 0x4ce4
jmp 0x4cec
movq %rax, %r14
movq %rbx, %rdi
callq 0x3240
movq %r14, %rdi
callq 0x34b0