// File: /workspace/github_cpp_makefile_star2_O1/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 $0xc8, %rsp
movq %r8, 0x30(%rsp)
movl %ecx, %r13d
movl %edx, %r14d
movl %esi, 0xc(%rsp)
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x10000, %edi          # imm = 0x10000
callq 0x3330
leaq 0x10(%rsp), %r15
movq %rax, (%r15)
movq %rax, 0x8(%r15)
movq %rax, %r12
addq $0x10000, %r12          # imm = 0x10000
movq %r12, 0x10(%r15)
xorl %ebp, %ebp
movl $0x10000, %edx          # imm = 0x10000
movq %rax, %rdi
xorl %esi, %esi
callq 0x31f0
movq %r12, 0x8(%r15)
movq %rbx, 0x28(%rsp)
movq %rbx, %rdi
movl %r13d, 0x8(%rsp)
movl %r13d, %esi
movq %r15, %rdx
callq 0xcaec
movl %eax, %r13d
movslq %eax, %r15
xorl %ecx, %ecx
movq 0x30(%rsp), %rbx
cmpl %r13d, %ecx
jge 0xc7ea
movl %ecx, %r12d
movslq %ecx, %rsi
addq 0x10(%rsp), %rsi
movl %r14d, %edi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x31b0
cmpl $-0x1, %eax
movl %eax, %ecx
cmovel %ebp, %ecx
addl %r12d, %ecx
cmpl $-0x1, %eax
jne 0xc7b4
cmpl %r13d, %r12d
jl 0xc91f
leaq 0x80(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x60(%rbx), %rsi
movq 0x68(%rbx), %rdx
addq %rsi, %rdx
leaq 0x70(%rsp), %rdi
callq 0x3d22
movq 0x10(%rsp), %rsi
leaq (%rsi,%r15), %rdx
incq %rdx
leaq 0x60(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x50(%rsp), %rdi
callq 0xa5fc
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movq $0x0, 0xa0(%rsp)
movq 0x10(%rsp), %rsi
addq %rsi, %r15
leaq 0x38(%rsp), %rdi
leaq 0x7(%rsp), %rcx
movq %r15, %rdx
callq 0x6e9e
leaq 0x90(%rsp), %r15
leaq 0x38(%rsp), %rsi
movq %r15, %rdi
callq 0xa66c
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0xc888
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x3340
addq $0x40, %rbx
subq $0x8, %rsp
leaq 0x78(%rsp), %r8
leaq 0x58(%rsp), %r9
movq 0x30(%rsp), %rdi
movl 0x14(%rsp), %esi
movl %r14d, %edx
movl 0x10(%rsp), %ecx
pushq %rbx
pushq %r13
pushq %r15
callq 0x9258
addq $0x20, %rsp
leaq 0x90(%rsp), %rdi
callq 0x3f6a
movq 0x50(%rsp), %rdi
cmpq %rbp, %rdi
je 0xc8dc
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x3340
movq 0x70(%rsp), %rdi
cmpq %r12, %rdi
je 0xc8f6
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x3340
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xc90d
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3340
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x31a0
movq %rax, %r14
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xc53(%rip), %rsi       # 0xd592
leaq 0xc66(%rip), %rdx       # 0xd5ac
leaq 0xa8(%rsp), %rdi
callq 0x3c86
movb $0x1, %bpl
leaq 0xa8(%rsp), %rsi
movq %r14, %rdi
callq 0x6aa8
xorl %ebp, %ebp
leaq 0x5399(%rip), %rsi      # 0x11d08
leaq -0x5e84(%rip), %rdx     # 0x6af2
movq %r14, %rdi
callq 0x34e0
jmp 0xcab2
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0xc9ab
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3340
jmp 0xc9ab
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0xcacc
movq %r14, %rdi
callq 0x3250
jmp 0xcacc
movq %rax, %rbx
cmpl $0x1, %edx
jne 0xca2d
movq %rbx, %rdi
callq 0x3130
movl $0x8, %edi
callq 0x31a0
movq 0x55d6(%rip), %rcx      # 0x11fb8
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x55e0(%rip), %rsi      # 0x11fd0
movq 0x55f9(%rip), %rdx      # 0x11ff0
movq %rax, %rdi
callq 0x34e0
jmp 0xcab2
movq %rax, %rbx
callq 0x34c0
jmp 0xca2d
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0xca2d
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x3340
jmp 0xca2d
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x3f6a
movq 0x50(%rsp), %rdi
cmpq %rbp, %rdi
je 0xca56
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x3340
jmp 0xca56
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r12, %rdi
je 0xcacc
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x3340
jmp 0xcacc
jmp 0xcac9
movq %rax, %rbx
cmpl $0x1, %edx
jne 0xcacc
movq %rbx, %rdi
callq 0x3130
movl $0x8, %edi
callq 0x31a0
movq 0x5523(%rip), %rcx      # 0x11fb8
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x552d(%rip), %rsi      # 0x11fd0
movq 0x5546(%rip), %rdx      # 0x11ff0
movq %rax, %rdi
callq 0x34e0
movq %rax, %rbx
callq 0x34c0
jmp 0xcacc
movq %rax, %rdi
callq 0x3d16
movq %rax, %rbx
jmp 0xcae3
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xcae3
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3340
movq %rbx, %rdi
callq 0x3510
nop