// File: /workspace/github_cpp_makefile_star2_O3/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, 0x50(%rsp)
movl %ecx, 0x10(%rsp)
movl %edx, %r14d
movl %esi, 0x14(%rsp)
movq %rdi, %rbx
movl $0x10000, %edi          # imm = 0x10000
callq 0x3330
leaq 0x18(%rsp), %r15
movq %rax, (%r15)
movq %rax, %r13
addq $0x10000, %r13          # imm = 0x10000
movq %r13, 0x10(%r15)
xorl %ebp, %ebp
movl $0x10000, %edx          # imm = 0x10000
movq %rax, %rdi
xorl %esi, %esi
callq 0x31f0
movq %r13, 0x8(%r15)
movq %rbx, %r12
movq %rbx, %rdi
movl 0x10(%rsp), %esi
movq %r15, %rdx
callq 0xc934
movl %eax, %r13d
movslq %eax, %r15
movq 0x50(%rsp), %rbx
cmpl %r13d, %ebp
jge 0xc68b
movslq %ebp, %rsi
addq 0x18(%rsp), %rsi
movl %r14d, %edi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x31b0
addl %eax, %ebp
cmpl $-0x1, %eax
jne 0xc602
movl $0x28, %edi
callq 0x31a0
movq %rax, %r14
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xf4b(%rip), %rsi       # 0xd592
leaq 0xf5e(%rip), %rdx       # 0xd5ac
leaq 0xa8(%rsp), %rdi
callq 0x3c80
movb $0x1, %bpl
leaq 0xa8(%rsp), %rsi
movq %r14, %rdi
callq 0x6a7c
xorl %ebp, %ebp
leaq 0x5691(%rip), %rsi      # 0x11d08
leaq -0x5bb8(%rip), %rdx     # 0x6ac6
movq %r14, %rdi
callq 0x34e0
jmp 0xc8c6
leaq 0x80(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq 0x60(%rbx), %rsi
movq 0x68(%rbx), %rdx
addq %rsi, %rdx
leaq 0x70(%rsp), %rdi
callq 0x3d20
movq 0x18(%rsp), %rsi
leaq (%rsi,%r15), %rdx
incq %rdx
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x30(%rsp), %rdi
callq 0xa4ae
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movq $0x0, 0xa0(%rsp)
movq 0x18(%rsp), %rsi
addq %rsi, %r15
leaq 0x58(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movq %r15, %rdx
callq 0x6e64
leaq 0x90(%rsp), %r15
leaq 0x58(%rsp), %rsi
movq %r15, %rdi
callq 0xa520
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0xc728
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x3340
addq $0x40, %rbx
subq $0x8, %rsp
leaq 0x78(%rsp), %r8
leaq 0x38(%rsp), %r9
movq %r12, %rdi
movl 0x1c(%rsp), %esi
movl %r14d, %edx
movl 0x18(%rsp), %ecx
pushq %rbx
pushq %r13
pushq %r15
callq 0x9186
addq $0x20, %rsp
leaq 0x90(%rsp), %rdi
callq 0x3f6e
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xc77f
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3340
movq 0x70(%rsp), %rdi
cmpq %rbp, %rdi
je 0xc799
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x3340
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0xc7b0
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x3340
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
cmpl $0x1, %edx
jne 0xc82e
movq %rbx, %rdi
callq 0x3130
movl $0x8, %edi
callq 0x31a0
movq 0x57d5(%rip), %rcx      # 0x11fb8
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x57df(%rip), %rsi      # 0x11fd0
movq 0x57f8(%rip), %rdx      # 0x11ff0
movq %rax, %rdi
callq 0x34e0
jmp 0xc8c6
movq %rax, %rbx
callq 0x34c0
jmp 0xc82e
movq %rax, %rbx
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0xc82e
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x3340
jmp 0xc82e
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x3f6e
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xc85c
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3340
jmp 0xc85c
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %rbp, %rdi
je 0xc914
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x3340
jmp 0xc914
jmp 0xc911
movq %rax, %rbx
cmpl $0x1, %edx
jne 0xc914
movq %rbx, %rdi
callq 0x3130
movl $0x8, %edi
callq 0x31a0
movq 0x570f(%rip), %rcx      # 0x11fb8
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x5719(%rip), %rsi      # 0x11fd0
movq 0x5732(%rip), %rdx      # 0x11ff0
movq %rax, %rdi
callq 0x34e0
movq %rax, %rbx
callq 0x34c0
jmp 0xc914
movq %rax, %rdi
callq 0x3d15
movq %rax, %rbx
jmp 0xc92b
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0xc8fd
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3340
testb %bpl, %bpl
jne 0xc907
jmp 0xc914
movq %rax, %rbx
movq %r14, %rdi
callq 0x3250
jmp 0xc914
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0xc92b
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x3340
movq %rbx, %rdi
callq 0x3510
nop