// File: /workspace/github_cpp_makefile_star2_O3/dentiny[P]HTTP-Cache-Proxy/Proxy.cpp
// Function: Proxy::resendCheckStatus(int, int, int, std::vector<char, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void resendCheckStatus(int client_id, int client_fd, int server_fd, const std::vector<char> & content_to_send, const std::string & url)
	{
		// re-send the inserted message to the server
		int sent_length = 0;
		int N = content_to_send.size();
		while(sent_length < N)
		{
			int len = send(server_fd, &content_to_send.data()[0] + sent_length, N - sent_length, 0);
			if(len == -1)
			{
				throw ProxyException("Send with If-None-Match/If-Modified-Since error");
			}
			sent_length += len;
		}

		// receive header from server and decide by the status code
		std::vector<char> buffer(BUFFER_SIZE, '\0'); // buffer to store header temporarily
		int len = recv(server_fd, &buffer.data()[0], BUFFER_SIZE, 0);
		if(len == -1)
		{
			throw ProxyException("Receive with If-None-Match/If-Modified-Since error");
		}
		buffer[len] = '\0';

		// check header status
		const std::string header(buffer.begin(), buffer.begin() + len);
		bool status_304 = checkStatusCode(header);

		// if get true(status code 304), directly return cached content
		if(status_304)
		{
			// write first line of response to log
			std::string first_line = parser.extractFirstLine(header);
			std::string log_content = std::to_string(client_id) + ": Received " + first_line + " from " + url;
			logger.log(log_content);
			log_content = std::to_string(client_id) + ": Responding " + first_line;
			logger.log(log_content);

			// respond to the client with client
			respondCached(client_fd, url);
			return;
		}

		// if get false(status code 200), receive all the sent, and send to the client
		std::vector<std::vector<char>> segment;
		segment.push_back(std::vector<char>(buffer.begin(), buffer.begin() + len));

		// respond header to client, send every character in the buffer to client
		// true for send success, false for send error
		bool respondClient_suc = respondClient(client_fd, buffer, len);
		if(!respondClient_suc) 
		{
			throw ProxyException("Respond header to client error");
		}

		// receive content from server and send it to client segment by segment
		try
		{
			std::string httpAction = "GET"; // for resend, the http action has to be "GET"
			getResponse(client_id, client_fd, server_fd, url, header, segment, len, httpAction);	
		}
		catch(std::exception & e)
		{
			throw e;
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %r9, 0xb8(%rsp)
movl %ecx, %r14d
movl %edx, %ebp
movq %rsi, 0x20(%rsp)
movq %rdi, 0x28(%rsp)
movl 0x8(%r8), %r15d
subl (%r8), %r15d
testl %r15d, %r15d
jle 0x77b2
movq %r8, %rbx
xorl %r12d, %r12d
movslq %r12d, %rax
movq (%rbx), %rsi
addq %rax, %rsi
movl %r15d, %ecx
subl %eax, %ecx
movslq %ecx, %rdx
movl %r14d, %edi
xorl %ecx, %ecx
callq 0x31b0
cmpl $-0x1, %eax
je 0x7ec5
addl %eax, %r12d
cmpl %r15d, %r12d
jl 0x7786
movl $0x10000, %edi          # imm = 0x10000
callq 0x3330
movq %rax, %rbx
movl $0x10000, %edx          # imm = 0x10000
movq %rax, %rdi
xorl %esi, %esi
callq 0x31f0
movl $0x10000, %edx          # imm = 0x10000
movl %r14d, %edi
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x3100
movq %rax, %r15
cmpl $-0x1, %r15d
je 0x7f29
movslq %r15d, %r13
leaq (%rbx,%r13), %r12
movb $0x0, (%rbx,%r13)
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xc0(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0xa4ae
leaq 0xc0(%rsp), %rsi
movq 0x28(%rsp), %rdi
callq 0x912a
testb %al, %al
je 0x78c8
leaq 0xc0(%rsp), %r14
movq %r14, %rdi
movl $0xd, %esi
xorl %edx, %edx
callq 0x33e0
movslq %eax, %rcx
movq %rsp, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3360
movq 0x20(%rsp), %r14
movl %r14d, %r13d
negl %r13d
cmovsl %r14d, %r13d
movl $0x1, %r15d
cmpl $0xa, %r13d
jb 0x7a27
movl $0x4, %r15d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r13d, %ecx
cmpl $0x63, %ecx
jbe 0x7a1e
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x7a24
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x7a27
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r15d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x7886
addl $-0x3, %r15d
jmp 0x7a27
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
movq %rsp, %rdi
leaq 0x98(%rsp), %rcx
movq %rbx, %rsi
movq %r12, %rdx
callq 0x6e64
leaq 0x50(%rsp), %rdi
movq %rsp, %rsi
callq 0xa520
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x7912
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x3340
xorl %r12d, %r12d
cmpl %r15d, %r12d
jge 0x7999
movslq %r12d, %rsi
addq %rbx, %rsi
movl %ebp, %edi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x31b0
addl %eax, %r12d
cmpl $-0x1, %eax
jne 0x7915
movl $0x28, %edi
callq 0x31a0
movq %rax, %r15
leaq 0x118(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x5afa(%rip), %rsi      # 0xd44f
leaq 0x5b11(%rip), %rdx      # 0xd46d
leaq 0x108(%rsp), %rdi
callq 0x3c80
movb $0x1, %bpl
leaq 0x108(%rsp), %rsi
movq %r15, %rdi
callq 0x6a7c
xorl %ebp, %ebp
leaq 0xa383(%rip), %rsi      # 0x11d08
leaq -0xec6(%rip), %rdx      # 0x6ac6
movq %r15, %rdi
callq 0x34e0
jmp 0x7fef
leaq 0x10(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x5792(%rip), %rsi      # 0xd13b
leaq 0x578e(%rip), %rdx      # 0xd13e
movq %rsp, %r12
movq %r12, %rdi
callq 0x3c80
subq $0x8, %rsp
leaq 0xc8(%rsp), %r9
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl %ebp, %edx
movl %r14d, %ecx
movq 0xc0(%rsp), %r8
pushq %r12
pushq %r15
leaq 0x68(%rsp), %rax
pushq %rax
callq 0x9186
addq $0x20, %rsp
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x7a07
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3340
leaq 0x50(%rsp), %rdi
callq 0x3f6e
leaq 0xd0(%rsp), %r14
jmp 0x7e89
addl $-0x2, %r15d
jmp 0x7a27
decl %r15d
shrl $0x1f, %r14d
leal (%r15,%r14), %esi
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xe0(%rsp), %rdi
movl $0x2d, %edx
callq 0x3390
movq %r14, 0x20(%rsp)
movl %r14d, %r14d
leaq 0xe0(%rsp), %r12
movq (%r12), %rdi
addq %r14, %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x7195
leaq 0x59bf(%rip), %rsi      # 0xd435
movq %r12, %rdi
callq 0x3550
leaq 0x88(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7aac
movq %rdx, 0x78(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x88(%rsp)
jmp 0x7ab4
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq 0x78(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x30e0
leaq 0x40(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7b05
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x7b0c
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq 0x30(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x55db(%rip), %rsi      # 0xd10a
callq 0x3550
leaq 0xa8(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7b64
movq %rdx, 0x98(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xa8(%rsp)
jmp 0x7b6a
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
leaq 0x98(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0xb8(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
callq 0x30e0
leaq 0x60(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7bc4
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x7bca
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x58(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x7c07
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3340
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x7c1e
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3340
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0x7c38
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3340
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x7c5d
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x3340
movq 0x28(%rsp), %rax
leaq 0x8(%rax), %rdi
leaq 0x50(%rsp), %rsi
movq %rdi, 0x100(%rsp)
callq 0x56f8
movl $0x1, %r15d
cmpl $0xa, %r13d
jb 0x7cce
movl $0x4, %r15d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r13d, %ecx
cmpl $0x63, %ecx
jbe 0x7cc5
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x7ccb
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x7cce
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r15d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x7c92
addl $-0x3, %r15d
jmp 0x7cce
addl $-0x2, %r15d
jmp 0x7cce
decl %r15d
movq 0x20(%rsp), %rsi
addl %r15d, %esi
leaq 0x78(%rsp), %rdi
movq %r12, (%rdi)
movl $0x2d, %edx
callq 0x3390
leaq 0x78(%rsp), %r12
addq (%r12), %r14
movq %r14, %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x7195
leaq 0x573b(%rip), %rsi      # 0xd441
movq %r12, %rdi
callq 0x3550
leaq 0x40(%rsp), %rsi
movq %rsi, 0x30(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
leaq 0xa8(%rsp), %r12
je 0x7d3e
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x7d44
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
leaq 0x88(%rsp), %r15
movq 0x8(%rax), %rdx
leaq 0x30(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x30e0
movq %r12, 0x98(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7da2
movq %rdx, 0x98(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xa8(%rsp)
jmp 0x7daa
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq 0x98(%rsp), %r14
movq %rdx, 0x8(%r14)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x33b0
movq (%r14), %rdi
cmpq %r12, %rdi
je 0x7dee
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3340
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x7e0a
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3340
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x7e24
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3340
leaq 0x50(%rsp), %rsi
movq 0x100(%rsp), %rdi
callq 0x56f8
movq 0x28(%rsp), %rdi
movl %ebp, %esi
movq 0xb8(%rsp), %rdx
callq 0x7428
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x7e66
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x3340
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
leaq 0xd0(%rsp), %r14
je 0x7e89
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3340
movq 0xc0(%rsp), %rdi
cmpq %r14, %rdi
je 0x7ea6
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x3340
movl $0x10000, %esi          # imm = 0x10000
movq %rbx, %rdi
callq 0x3340
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x31a0
movq %rax, %rbx
leaq 0x158(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x54ed(%rip), %rsi      # 0xd3d2
leaq 0x5515(%rip), %rdx      # 0xd401
leaq 0x148(%rsp), %rdi
callq 0x3c80
movb $0x1, %bpl
leaq 0x148(%rsp), %rsi
movq %rbx, %rdi
callq 0x6a7c
xorl %ebp, %ebp
leaq 0x9df3(%rip), %rsi      # 0x11d08
leaq -0x1456(%rip), %rdx     # 0x6ac6
movq %rbx, %rdi
callq 0x34e0
jmp 0x7fef
movl $0x28, %edi
callq 0x31a0
movq %rax, %r15
leaq 0x138(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x54b8(%rip), %rsi      # 0xd402
leaq 0x54e3(%rip), %rdx      # 0xd434
leaq 0x128(%rsp), %rdi
callq 0x3c80
movb $0x1, %bpl
leaq 0x128(%rsp), %rsi
movq %r15, %rdi
callq 0x6a7c
xorl %ebp, %ebp
leaq 0x9d8e(%rip), %rsi      # 0x11d08
leaq -0x14bb(%rip), %rdx     # 0x6ac6
movq %r15, %rdi
callq 0x34e0
jmp 0x7fef
movq %rdx, %r15
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x7faf
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3340
jmp 0x7faf
movq %rdx, %r15
movq %rax, %r14
cmpl $0x1, %r15d
jne 0x8219
movq %r14, %rdi
callq 0x3130
movl $0x8, %edi
callq 0x31a0
movq 0x9fe6(%rip), %rcx      # 0x11fb8
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x9ff0(%rip), %rsi      # 0x11fd0
movq 0xa009(%rip), %rdx      # 0x11ff0
movq %rax, %rdi
callq 0x34e0
movq %rax, %r14
callq 0x34c0
jmp 0x8219
movq %rax, %rdi
callq 0x3d15
movq %rax, %r14
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x8028
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3340
jmp 0x8028
movq %rax, %r14
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x8171
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3340
jmp 0x8171
jmp 0x816e
movq %rax, %r14
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x8085
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3340
jmp 0x8085
movq %rax, %r14
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x80a6
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3340
jmp 0x80a6
movq %rax, %r14
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0x80c5
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3340
jmp 0x80c5
movq %rax, %r14
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x818d
movq 0xf0(%rsp), %rsi
jmp 0x8185
movq %rax, %r14
jmp 0x818d
movq %rax, %r14
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x8219
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x3340
jmp 0x8219
jmp 0x8216
movq %rax, %r14
jmp 0x8223
movq %rax, %r14
movq 0x128(%rsp), %rdi
cmpq %r12, %rdi
je 0x8142
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x3340
testb %bpl, %bpl
jne 0x814f
jmp 0x8248
movq %rax, %r14
movq %r15, %rdi
callq 0x3250
jmp 0x8248
jmp 0x815e
movq %rax, %r14
jmp 0x8248
movq %rax, %r14
jmp 0x8255
movq %rax, %r14
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x818d
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x3340
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8223
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3340
jmp 0x8223
movq %rax, %r14
movq 0x108(%rsp), %rdi
cmpq %r12, %rdi
je 0x81ce
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x3340
testb %bpl, %bpl
jne 0x81d8
jmp 0x8219
movq %rax, %r14
movq %r15, %rdi
callq 0x3250
jmp 0x8219
movq %rax, %r14
movq 0x148(%rsp), %rdi
cmpq %r15, %rdi
je 0x8202
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x3340
testb %bpl, %bpl
jne 0x820c
jmp 0x8255
movq %rax, %r14
movq %rbx, %rdi
callq 0x3250
jmp 0x8255
movq %rax, %r14
leaq 0x50(%rsp), %rdi
callq 0x3f6e
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x8248
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x3340
movl $0x10000, %esi          # imm = 0x10000
movq %rbx, %rdi
callq 0x3340
movq %r14, %rdi
callq 0x3510
nop