// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/Proxy.cpp
// Function: Proxy::getResponse(int, int, int, Request const&)
void getResponse(int client_id, int client_fd, int server_fd, const Request & request)
	{
	    // get header first, decide whether content-based or chunk-based
	    std::vector<char> buffer(BUFFER_SIZE, '\0');
	    int len = 0; // len is the length of received header length
	    try
	    {
	    	len = getResponseHeader(server_fd, buffer);
	    }
	    catch(std::exception & e)
	    {
	    	throw e;
	    }

	    // send header to the client
	    if(!respondClient(client_fd, buffer, len))
	    {
	    	throw ProxyException("Proxy send to client error");
	    }

	    // get url of the request, and pass it as the argument of getResponse() body part
	    const std::string url = request.url;
	    const std::string header(buffer.begin(), buffer.begin() + len + 1);
	    std::vector<std::vector<char>> segment; // store every segment of the response from the server
	    segment.push_back(std::vector<char>(buffer.begin(), buffer.begin() + len)); // push header into the segment vector
	    try
	    {
	    	getResponse(client_id, client_fd, server_fd, url, header, segment, len, request.httpAction);
	    }
	    catch(std::exception & e)
	    {
	    	throw e;
	    }
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %r8, %rbx
movl %ecx, %r15d
movl %edx, %r14d
movl %esi, %ebp
movq %rdi, %r12
leaq 0x60(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0x8(%rsp), %rdi
leaq 0x40(%rsp), %rcx
movl $0x10000, %esi          # imm = 0x10000
callq 0x563e
leaq 0x8(%rsp), %rdx
movq %r12, %rdi
movl %r15d, %esi
callq 0x9dba
movl %eax, %r13d
leaq 0x8(%rsp), %rdx
movq %r12, %rdi
movl %r14d, %esi
movl %eax, %ecx
callq 0x7668
testb %al, %al
je 0x9c4c
movl %r15d, 0x4(%rsp)
leaq 0x60(%rbx), %rsi
leaq 0x60(%rsp), %rdi
callq 0x33d0
movq 0x8(%rsp), %rsi
movslq %r13d, %r15
leaq (%rsi,%r15), %rdx
incq %rdx
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x40(%rsp), %rdi
callq 0x805e
andq $0x0, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x8(%rsp), %rsi
addq %rsi, %r15
leaq 0x80(%rsp), %rdi
leaq 0x3(%rsp), %rcx
movq %r15, %rdx
callq 0x598e
leaq 0x20(%rsp), %r15
leaq 0x80(%rsp), %rsi
movq %r15, %rdi
callq 0x80cc
leaq 0x80(%rsp), %rdi
callq 0x3dda
addq $0x40, %rbx
subq $0x8, %rsp
leaq 0x68(%rsp), %r8
leaq 0x48(%rsp), %r9
movq %r12, %rdi
movl %ebp, %esi
movl %r14d, %edx
movl 0xc(%rsp), %ecx
pushq %rbx
pushq %r13
pushq %r15
callq 0x76ae
addq $0x20, %rsp
leaq 0x20(%rsp), %rdi
callq 0x3c98
leaq 0x40(%rsp), %rdi
callq 0x3150
leaq 0x60(%rsp), %rdi
callq 0x3150
leaq 0x8(%rsp), %rdi
callq 0x3dda
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x3190
movq %rax, %r14
leaq 0x934(%rip), %rsi       # 0xa592
leaq 0x98(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x386c
movb $0x1, %bpl
leaq 0x98(%rsp), %rsi
movq %r14, %rdi
callq 0x55e8
xorl %ebp, %ebp
leaq 0x607c(%rip), %rsi      # 0xfd08
leaq -0x4675(%rip), %rdx     # 0x561e
movq %r14, %rdi
callq 0x3490
jmp 0x9d92
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x3150
testb %bpl, %bpl
jne 0x9cbd
jmp 0x9d9a
movq %rax, %rbx
movq %r14, %rdi
callq 0x3240
jmp 0x9d9a
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x9d2a
movq %rbx, %rdi
callq 0x3100
pushq $0x8
popq %rdi
callq 0x3190
movq 0x62c7(%rip), %rcx      # 0xffb0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x62d9(%rip), %rsi      # 0xffd0
movq 0x62f2(%rip), %rdx      # 0xfff0
movq %rax, %rdi
callq 0x3490
jmp 0x9d92
movq %rax, %rbx
callq 0x3470
jmp 0x9d2a
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x3dda
jmp 0x9d2a
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3c98
leaq 0x40(%rsp), %rdi
callq 0x3150
jmp 0x9d43
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3150
jmp 0x9d9a
jmp 0x9d51
movq %rax, %rbx
jmp 0x9d9a
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x9d9a
movq %rbx, %rdi
callq 0x3100
pushq $0x8
popq %rdi
callq 0x3190
movq 0x623b(%rip), %rcx      # 0xffb0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x624d(%rip), %rsi      # 0xffd0
movq 0x6266(%rip), %rdx      # 0xfff0
movq %rax, %rdi
callq 0x3490
movq %rax, %rbx
callq 0x3470
leaq 0x8(%rsp), %rdi
callq 0x3dda
movq %rbx, %rdi
callq 0x34b0
movq %rax, %rdi
callq 0x3b8d
movq %rax, %rbx
jmp 0x9da4
nop