// File: /workspace/github_cpp_makefile_star2_O1/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 0x5872
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 0x58cd
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 0x592a
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 0x795f(%rip), %rsi      # 0xd1ee
leaq 0x7978(%rip), %rdx      # 0xd20e
leaq 0x50(%rsp), %rdi
callq 0x3c86
movb $0x1, %bpl
leaq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0x6aa8
xorl %ebp, %ebp
leaq 0xc44f(%rip), %rsi      # 0x11d08
leaq 0x1232(%rip), %rdx      # 0x6af2
movq %rbx, %rdi
callq 0x34e0
jmp 0x5980
callq 0x33d0
movl $0x28, %edi
callq 0x31a0
movq %rax, %rbx
leaq 0x40(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x7920(%rip), %rsi      # 0xd20f
leaq 0x793b(%rip), %rdx      # 0xd231
leaq 0x30(%rsp), %rdi
callq 0x3c86
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x6aa8
xorl %ebp, %ebp
leaq 0xc3ef(%rip), %rsi      # 0x11d08
leaq 0x11d2(%rip), %rdx      # 0x6af2
movq %rbx, %rdi
callq 0x34e0
jmp 0x5980
movl $0x28, %edi
callq 0x31a0
movq %rax, %rbx
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x78eb(%rip), %rsi      # 0xd232
leaq 0x7902(%rip), %rdx      # 0xd250
leaq 0x10(%rsp), %rdi
callq 0x3c86
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x6aa8
xorl %ebp, %ebp
leaq 0xc397(%rip), %rsi      # 0x11d08
leaq 0x117a(%rip), %rdx      # 0x6af2
movq %rbx, %rdi
callq 0x34e0
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x59ce
movq 0x20(%rsp), %rsi
jmp 0x59be
jmp 0x59c8
movq %rax, %r14
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x59ce
movq 0x40(%rsp), %rsi
jmp 0x59be
jmp 0x59c8
movq %rax, %r14
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x59ce
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x3340
jmp 0x59ce
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0x59db
movq %rbx, %rdi
callq 0x3250
movq %r14, %rdi
callq 0x3510
nop