// File: 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
movq %rsp, %rbp
subq $0x390, %rsp            # imm = 0x390
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2d0(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x20(%rbp), %rdi
callq 0x9d80
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0xbbdf
movl -0x14(%rbp), %eax
movl %eax, -0x2d4(%rbp)
movq -0x20(%rbp), %rdi
callq 0xf710
movl -0x2d4(%rbp), %edi
movq %rax, %rsi
movslq -0x2c(%rbp), %rax
addq %rax, %rsi
movl -0x30(%rbp), %eax
subl -0x2c(%rbp), %eax
movslq %eax, %rdx
xorl %ecx, %ecx
callq 0x41c0
movl %eax, -0x34(%rbp)
cmpl $-0x1, -0x34(%rbp)
jne 0xbbd1
movb $0x1, -0x6d(%rbp)
movl $0x28, %edi
callq 0x41b0
movq %rax, -0x2e8(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x4650
movq -0x2e0(%rbp), %rdx
leaq 0xd86e(%rip), %rsi      # 0x193ba
leaq -0x58(%rbp), %rdi
callq 0x4bf0
jmp 0xbb57
movq -0x2e8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x9240
jmp 0xbb69
movq -0x2e8(%rbp), %rdi
movb $0x0, -0x6d(%rbp)
leaq 0x1817d(%rip), %rsi     # 0x23cf8
leaq -0x28d2(%rip), %rdx     # 0x92b0
callq 0x4610
jmp 0xc4c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xbbaf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4250
leaq -0x59(%rbp), %rdi
callq 0x4420
testb $0x1, -0x6d(%rbp)
jne 0xbbc0
jmp 0xbbcc
movq -0x2e8(%rbp), %rdi
callq 0x42d0
jmp 0xc4af
movl -0x34(%rbp), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0xbace
movb $0x0, -0x89(%rbp)
leaq -0x8a(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x4650
movq -0x2f0(%rbp), %rcx
leaq -0x88(%rbp), %rdi
movl $0x10000, %esi          # imm = 0x10000
leaq -0x89(%rbp), %rdx
callq 0x9390
jmp 0xbc1a
leaq -0x8a(%rbp), %rdi
callq 0x4420
movl -0x14(%rbp), %eax
movl %eax, -0x2fc(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x9410
movl -0x2fc(%rbp), %edi
movq %rax, %rsi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
callq 0x40f0
movq %rax, -0x2f8(%rbp)
jmp 0xbc59
movq -0x2f8(%rbp), %rax
movl %eax, -0x90(%rbp)
cmpl $-0x1, -0x90(%rbp)
jne 0xbd71
movb $0x1, -0xb2(%rbp)
movl $0x28, %edi
callq 0x41b0
movq %rax, -0x310(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x308(%rbp)
callq 0x4650
movq -0x308(%rbp), %rdx
leaq 0xd73e(%rip), %rsi      # 0x193ea
leaq -0xb0(%rbp), %rdi
callq 0x4bf0
jmp 0xbcba
movq -0x310(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x9240
jmp 0xbccf
movq -0x310(%rbp), %rdi
movb $0x0, -0xb2(%rbp)
leaq 0x18014(%rip), %rsi     # 0x23cf8
leaq -0x2a3b(%rip), %rdx     # 0x92b0
callq 0x4610
jmp 0xc4c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x8a(%rbp), %rdi
callq 0x4420
jmp 0xc4af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xc4a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xbd49
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x4250
leaq -0xb1(%rbp), %rdi
callq 0x4420
testb $0x1, -0xb2(%rbp)
jne 0xbd60
jmp 0xbd6c
movq -0x310(%rbp), %rdi
callq 0x42d0
jmp 0xc4a3
movslq -0x90(%rbp), %rsi
leaq -0x88(%rbp), %rdi
movq %rdi, -0x320(%rbp)
callq 0x9430
movq -0x320(%rbp), %rdi
movb $0x0, (%rax)
callq 0xa150
movq -0x320(%rbp), %rdi
movq %rax, -0xe0(%rbp)
callq 0xa150
movq %rax, -0xf0(%rbp)
movslq -0x90(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0xa180
movq %rax, -0xe8(%rbp)
leaq -0xf1(%rbp), %rdi
movq %rdi, -0x318(%rbp)
callq 0x4650
movq -0x318(%rbp), %rcx
movq -0xe0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
callq 0x10cb0
jmp 0xbe04
leaq -0xf1(%rbp), %rdi
callq 0x4420
movq -0x2d0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x10d30
movb %al, -0x321(%rbp)
jmp 0xbe2b
movb -0x321(%rbp), %al
andb $0x1, %al
movb %al, -0xf2(%rbp)
testb $0x1, -0xf2(%rbp)
je 0xc110
movq -0x2d0(%rbp), %rsi
leaq -0x118(%rbp), %rdi
leaq -0xd8(%rbp), %rdx
callq 0x10de0
jmp 0xbe62
movl -0xc(%rbp), %esi
leaq -0x1b8(%rbp), %rdi
callq 0x7bb0
jmp 0xbe73
leaq 0xd5a3(%rip), %rdx      # 0x1941d
leaq -0x198(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x7b60
jmp 0xbe8f
leaq -0x178(%rbp), %rdi
leaq -0x198(%rbp), %rsi
leaq -0x118(%rbp), %rdx
callq 0x7b10
jmp 0xbeab
leaq 0xd240(%rip), %rdx      # 0x190f2
leaq -0x158(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x7b60
jmp 0xbec7
movq -0x28(%rbp), %rdx
leaq -0x138(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x7b10
jmp 0xbee0
leaq -0x158(%rbp), %rdi
callq 0x4250
leaq -0x178(%rbp), %rdi
callq 0x4250
leaq -0x198(%rbp), %rdi
callq 0x4250
leaq -0x1b8(%rbp), %rdi
callq 0x4250
movq -0x2d0(%rbp), %rdi
addq $0x8, %rdi
leaq -0x138(%rbp), %rsi
callq 0x7cd0
jmp 0xbf29
movl -0xc(%rbp), %esi
leaq -0x218(%rbp), %rdi
callq 0x7bb0
jmp 0xbf3a
leaq 0xd4e8(%rip), %rdx      # 0x19429
leaq -0x1f8(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x7b60
jmp 0xbf56
leaq -0x1d8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
leaq -0x118(%rbp), %rdx
callq 0x7b10
jmp 0xbf72
leaq -0x138(%rbp), %rdi
movq %rdi, -0x330(%rbp)
leaq -0x1d8(%rbp), %rsi
movq %rsi, -0x338(%rbp)
callq 0x4490
movq -0x338(%rbp), %rdi
callq 0x4250
leaq -0x1f8(%rbp), %rdi
callq 0x4250
leaq -0x218(%rbp), %rdi
callq 0x4250
movq -0x2d0(%rbp), %rdi
movq -0x330(%rbp), %rsi
addq $0x8, %rdi
callq 0x7cd0
jmp 0xbfd0
movq -0x2d0(%rbp), %rdi
movl -0x10(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0xb510
jmp 0xbfe5
movl $0x1, -0x21c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x4250
leaq -0x118(%rbp), %rdi
callq 0x4250
jmp 0xc46a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xf1(%rbp), %rdi
callq 0x4420
jmp 0xc4a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xc497
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xc0ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xc0a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xc099
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xc08d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x4250
leaq -0x178(%rbp), %rdi
callq 0x4250
leaq -0x198(%rbp), %rdi
callq 0x4250
leaq -0x1b8(%rbp), %rdi
callq 0x4250
jmp 0xc0ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xc0f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xc0e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x4250
leaq -0x218(%rbp), %rdi
callq 0x4250
leaq -0x138(%rbp), %rdi
callq 0x4250
leaq -0x118(%rbp), %rdi
callq 0x4250
jmp 0xc497
leaq -0x238(%rbp), %rdi
callq 0xd730
leaq -0x88(%rbp), %rdi
movq %rdi, -0x348(%rbp)
callq 0xa150
movq -0x348(%rbp), %rdi
movq %rax, -0x258(%rbp)
callq 0xa150
movq %rax, -0x268(%rbp)
movslq -0x90(%rbp), %rsi
leaq -0x268(%rbp), %rdi
callq 0xa180
movq %rax, -0x260(%rbp)
leaq -0x269(%rbp), %rdi
movq %rdi, -0x340(%rbp)
callq 0x4650
movq -0x340(%rbp), %rcx
movq -0x258(%rbp), %rsi
movq -0x260(%rbp), %rdx
leaq -0x250(%rbp), %rdi
callq 0xa1c0
jmp 0xc199
leaq -0x238(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x10e40
jmp 0xc1ae
leaq -0x250(%rbp), %rdi
callq 0x6130
leaq -0x269(%rbp), %rdi
callq 0x4420
movq -0x2d0(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x90(%rbp), %ecx
leaq -0x88(%rbp), %rdx
callq 0x10e70
movb %al, -0x349(%rbp)
jmp 0xc1ea
movb -0x349(%rbp), %al
andb $0x1, %al
movb %al, -0x26a(%rbp)
testb $0x1, -0x26a(%rbp)
jne 0xc31d
movb $0x1, -0x292(%rbp)
movl $0x28, %edi
callq 0x41b0
movq %rax, -0x360(%rbp)
leaq -0x291(%rbp), %rdi
movq %rdi, -0x358(%rbp)
callq 0x4650
movq -0x358(%rbp), %rdx
leaq 0xd1f9(%rip), %rsi      # 0x19437
leaq -0x290(%rbp), %rdi
callq 0x4bf0
jmp 0xc24c
movq -0x360(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x9240
jmp 0xc261
movq -0x360(%rbp), %rdi
movb $0x0, -0x292(%rbp)
leaq 0x17a82(%rip), %rsi     # 0x23cf8
leaq -0x2fcd(%rip), %rdx     # 0x92b0
callq 0x4610
jmp 0xc4c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xc2ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x6130
leaq -0x269(%rbp), %rdi
callq 0x4420
jmp 0xc48b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xc48b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xc2f5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x4250
leaq -0x291(%rbp), %rdi
callq 0x4420
testb $0x1, -0x292(%rbp)
jne 0xc30c
jmp 0xc318
movq -0x360(%rbp), %rdi
callq 0x42d0
jmp 0xc48b
leaq -0x2b9(%rbp), %rdi
movq %rdi, -0x368(%rbp)
callq 0x4650
movq -0x368(%rbp), %rdx
leaq 0xcde5(%rip), %rsi      # 0x19123
leaq -0x2b8(%rbp), %rdi
callq 0x4bf0
jmp 0xc34c
leaq -0x2b9(%rbp), %rdi
callq 0x4420
movq -0x2d0(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movl -0x14(%rbp), %ecx
movq -0x28(%rbp), %r8
movl -0x90(%rbp), %r9d
movq %rsp, %rax
leaq -0x2b8(%rbp), %r10
movq %r10, 0x10(%rax)
movl %r9d, 0x8(%rax)
leaq -0x238(%rbp), %r9
movq %r9, (%rax)
leaq -0xd8(%rbp), %r9
callq 0x10ef0
jmp 0xc39d
leaq -0x2b8(%rbp), %rdi
callq 0x4250
jmp 0xc454
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x2b9(%rbp), %rdi
callq 0x4420
jmp 0xc3e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x2b8(%rbp), %rdi
callq 0x4250
movl -0x6c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0xc48b
movq -0x68(%rbp), %rdi
callq 0x4120
movq %rax, -0x2c8(%rbp)
movl $0x8, %edi
callq 0x41b0
movq %rax, %rdi
movq %rdi, -0x370(%rbp)
movq -0x2c8(%rbp), %rsi
callq 0x7db0
movq -0x370(%rbp), %rdi
movq 0x17ba2(%rip), %rsi     # 0x23fd0
movq 0x17bbb(%rip), %rdx     # 0x23ff0
callq 0x4610
jmp 0xc4c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
callq 0x45d0
jmp 0xc452
jmp 0xc48b
leaq -0x238(%rbp), %rdi
callq 0x5a00
movl $0x0, -0x21c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x4250
leaq -0x88(%rbp), %rdi
callq 0x6130
addq $0x390, %rsp            # imm = 0x390
popq %rbp
retq
leaq -0x238(%rbp), %rdi
callq 0x5a00
leaq -0xd8(%rbp), %rdi
callq 0x4250
leaq -0x88(%rbp), %rdi
callq 0x6130
movq -0x68(%rbp), %rdi
callq 0x4640
movq %rax, %rdi
callq 0x52e0