// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
subq $0xa8, %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 0x33c0
movl %eax, 0x2b0(%rbx)
testl %eax, %eax
jne 0x5856
movq 0x8(%rsp), %rax
movl 0x4(%rax), %edi
movl 0x8(%rax), %esi
movl 0xc(%rax), %edx
callq 0x30b0
movl %eax, (%r14)
movq 0x8(%rsp), %rdi
cmpl $-0x1, %eax
je 0x58b1
movq 0x18(%rdi), %rsi
movl 0x10(%rdi), %edx
movl %eax, %edi
callq 0x32a0
movl %eax, %ebp
movl %eax, 0x2b0(%rbx)
movq 0x8(%rsp), %rdi
callq 0x33d0
cmpl $-0x1, %ebp
je 0x590e
addq $0xa8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x31a0
movq %rax, %rbx
leaq 0x60(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x797b(%rip), %rsi      # 0xd1ee
leaq 0x7994(%rip), %rdx      # 0xd20e
leaq 0x50(%rsp), %rdi
callq 0x3c80
movb $0x1, %bpl
leaq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0x6a7c
xorl %ebp, %ebp
leaq 0xc46b(%rip), %rsi      # 0x11d08
leaq 0x1222(%rip), %rdx      # 0x6ac6
movq %rbx, %rdi
callq 0x34e0
jmp 0x5964
callq 0x33d0
movl $0x28, %edi
callq 0x31a0
movq %rax, %rbx
leaq 0x40(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x793c(%rip), %rsi      # 0xd20f
leaq 0x7957(%rip), %rdx      # 0xd231
leaq 0x30(%rsp), %rdi
callq 0x3c80
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x6a7c
xorl %ebp, %ebp
leaq 0xc40b(%rip), %rsi      # 0x11d08
leaq 0x11c2(%rip), %rdx      # 0x6ac6
movq %rbx, %rdi
callq 0x34e0
jmp 0x5964
movl $0x28, %edi
callq 0x31a0
movq %rax, %rbx
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x7907(%rip), %rsi      # 0xd232
leaq 0x791e(%rip), %rdx      # 0xd250
leaq 0x10(%rsp), %rdi
callq 0x3c80
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x6a7c
xorl %ebp, %ebp
leaq 0xc3b3(%rip), %rsi      # 0x11d08
leaq 0x116a(%rip), %rdx      # 0x6ac6
movq %rbx, %rdi
callq 0x34e0
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x59aa
movq 0x20(%rsp), %rsi
jmp 0x59a2
jmp 0x59b1
movq %rax, %r14
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x59aa
movq 0x40(%rsp), %rsi
jmp 0x59a2
jmp 0x59b1
movq %rax, %r14
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x59aa
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x3340
testb %bpl, %bpl
jne 0x59b4
jmp 0x59bc
movq %rax, %r14
movq %rbx, %rdi
callq 0x3250
movq %r14, %rdi
callq 0x3510