// File: /workspace/github_cpp_makefile_star2_O1/mbourand[P]webserv/srcs/Request.cpp
// Function: Request::parse_protocol_version()
void Request::parse_protocol_version()
{
	// _parse_start + 1 is the first character of the protocol version
	if (_raw.find('\r', _parse_start + 1) != std::string::npos && _raw.find("\r\n", _parse_start + 1) == std::string::npos)
		return;
	std::string version = _raw.substr(_parse_start + 1, _raw.find("\r\n", _parse_start + 1) - (_parse_start + 1));
	if (std::string("HTTP/1.1").substr(0, version.size()) != version && std::string("HTTP/1.0").substr(0, version.size()) != version)
	{
		_error_code = 400;
		throw std::invalid_argument("Request protocol version could not be recognized.");
	}
	if (_raw.find("\r\n", _parse_start + 1) != std::string::npos && version == "HTTP/1.1")
	{
		Logger::print("Request protocol version is HTTP/1.1.", true, INFO, VERBOSE);
		_protocolVersion = version;
		_parse_start = _raw.find("\r\n") + 2;
	}
	else if (_raw.find("\r\n", _parse_start + 1) != std::string::npos && version == "HTTP/1.0")
	{
		Logger::print("Request protocol version is HTTP/1.0.", true, INFO, VERBOSE);
		_protocolVersion = version;
		_parse_start = _raw.find("\r\n") + 2;
	}
	else
	{
		_error_code = 400;
		throw std::invalid_argument("Request protocol version could not be recognized.");
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xe0, %rsp
movq %rdi, %rbx
leaq 0x8(%rdi), %r14
movq 0x198(%rdi), %rdx
incq %rdx
movq %r14, %rdi
movl $0xd, %esi
callq 0x75c0
cmpq $-0x1, %rax
je 0x3484d
movq 0x198(%rbx), %rdx
incq %rdx
leaq 0x90ba(%rip), %rsi      # 0x3d8f0
movl $0x2, %ecx
movq %r14, %rdi
callq 0x77f0
cmpq $-0x1, %rax
je 0x34b3c
movq 0x198(%rbx), %r15
incq %r15
leaq 0x9092(%rip), %rsi      # 0x3d8f0
movl $0x2, %ecx
movq %r14, %rdi
movq %r15, %rdx
callq 0x77f0
movq 0x198(%rbx), %rcx
notq %rcx
addq %rax, %rcx
movq %rsp, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x74d0
leaq 0x50(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x632a(%rip), %rsi      # 0x3abc3
leaq 0x632b(%rip), %rdx      # 0x3abcb
leaq 0x40(%rsp), %rdi
callq 0x80f4
movq 0x8(%rsp), %rcx
leaq 0x60(%rsp), %rdi
leaq 0x40(%rsp), %rsi
xorl %edx, %edx
callq 0x74d0
movq 0x68(%rsp), %rdx
movb $0x1, %bpl
cmpq 0x8(%rsp), %rdx
jne 0x348ec
testq %rdx, %rdx
je 0x348ea
movq (%rsp), %rsi
movq 0x60(%rsp), %rdi
callq 0x74c0
testl %eax, %eax
setne %bpl
jmp 0x348ec
xorl %ebp, %ebp
testb %bpl, %bpl
je 0x3495c
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x8897(%rip), %rsi      # 0x3d199
leaq 0x8898(%rip), %rdx      # 0x3d1a1
leaq 0x20(%rsp), %rdi
callq 0x80f4
movq 0x8(%rsp), %rcx
leaq 0xc0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0x74d0
movq 0xc8(%rsp), %rdx
movb $0x1, %r12b
cmpq 0x8(%rsp), %rdx
jne 0x3495f
testq %rdx, %rdx
je 0x3495c
movq (%rsp), %rsi
movq 0xc0(%rsp), %rdi
callq 0x74c0
testl %eax, %eax
setne %r12b
jmp 0x3495f
xorl %r12d, %r12d
testb %bpl, %bpl
je 0x349a0
leaq 0xd0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x34985
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x74b0
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x349a0
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x74b0
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x349bb
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x349d2
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x74b0
testb %r12b, %r12b
jne 0x34b74
movq 0x198(%rbx), %rdx
incq %rdx
leaq 0x8f04(%rip), %rsi      # 0x3d8f0
movl $0x2, %ecx
movq %r14, %rdi
callq 0x77f0
cmpq $-0x1, %rax
je 0x34a16
leaq 0x61bd(%rip), %rsi      # 0x3abc3
movq %rsp, %rdi
callq 0x7180
testl %eax, %eax
je 0x34a9c
movq 0x198(%rbx), %rdx
incq %rdx
leaq 0x8ec9(%rip), %rsi      # 0x3d8f0
movl $0x2, %ecx
movq %r14, %rdi
callq 0x77f0
cmpq $-0x1, %rax
je 0x34b4c
leaq 0x8754(%rip), %rsi      # 0x3d199
movq %rsp, %rdi
callq 0x7180
testl %eax, %eax
jne 0x34b4c
leaq 0x90(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x8d7d(%rip), %rsi      # 0x3d7e5
leaq 0x8d9b(%rip), %rdx      # 0x3d80a
leaq 0x80(%rsp), %rdi
callq 0x80f4
leaq 0x80(%rsp), %rdi
movl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x32d48
movq 0x80(%rsp), %rdi
jmp 0x34ae1
leaq 0xb0(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x8d10(%rip), %rsi      # 0x3d7bf
leaq 0x8d2e(%rip), %rdx      # 0x3d7e4
leaq 0xa0(%rsp), %rdi
callq 0x80f4
leaq 0xa0(%rsp), %rdi
movl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x32d48
movq 0xa0(%rsp), %rdi
cmpq %r15, %rdi
je 0x34af1
movq (%r15), %rsi
incq %rsi
callq 0x74b0
leaq 0x120(%rbx), %rdi
movq %rsp, %rsi
callq 0x72c0
leaq 0x8de9(%rip), %rsi      # 0x3d8f0
movl $0x2, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x77f0
addq $0x2, %rax
movq %rax, 0x198(%rbx)
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x34b3c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x74b0
addq $0xe0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x190, 0x188(%rbx)     # imm = 0x190
movl $0x10, %edi
callq 0x7260
movq %rax, %r14
leaq 0x8c23(%rip), %rsi      # 0x3d78d
movq %rax, %rdi
callq 0x78c0
jmp 0x34b9a
movl $0x190, 0x188(%rbx)     # imm = 0x190
movl $0x10, %edi
callq 0x7260
movq %rax, %r14
leaq 0x8bfb(%rip), %rsi      # 0x3d78d
movq %rax, %rdi
callq 0x78c0
movq 0x19427(%rip), %rsi     # 0x4dfc8
movq 0x19408(%rip), %rdx     # 0x4dfb0
movq %r14, %rdi
callq 0x77d0
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
cmpq %r15, %rdi
je 0x34c5b
movq 0xb0(%rsp), %rsi
jmp 0x34c4c
jmp 0x34c58
jmp 0x34c2d
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x34bf4
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x34bf4
movq %rax, %rbx
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x34c3d
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x34c3d
movq %rax, %rbx
movq 0x80(%rsp), %rdi
cmpq %r15, %rdi
je 0x34c5b
movq 0x90(%rsp), %rsi
jmp 0x34c4c
jmp 0x34c58
movq %rax, %rbx
movq %r14, %rdi
callq 0x7390
jmp 0x34c5b
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x34c5b
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x34c5b
jmp 0x34c58
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x34c76
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x74b0
movq %rbx, %rdi
callq 0x7810