// File: /workspace/github_cpp_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
subq $0xe8, %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 0x34407
movq 0x198(%rbx), %rdx
incq %rdx
leaq 0x9500(%rip), %rsi      # 0x3d8f0
movl $0x2, %ecx
movq %r14, %rdi
callq 0x77f0
cmpq $-0x1, %rax
je 0x34703
movq 0x198(%rbx), %r15
incq %r15
leaq 0x94d8(%rip), %rsi      # 0x3d8f0
movl $0x2, %ecx
movq %r14, %rdi
movq %r15, %rdx
callq 0x77f0
movq 0x198(%rbx), %rcx
notq %rcx
addq %rax, %rcx
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x74d0
leaq 0x78(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x676d(%rip), %rsi      # 0x3abc3
leaq 0x676e(%rip), %rdx      # 0x3abcb
leaq 0x68(%rsp), %rdi
callq 0x80f4
movq 0x10(%rsp), %rcx
leaq 0x28(%rsp), %rdi
leaq 0x68(%rsp), %rsi
xorl %edx, %edx
callq 0x74d0
movq 0x30(%rsp), %rdx
cmpq 0x10(%rsp), %rdx
jne 0x344a8
movq 0x28(%rsp), %r15
testq %rdx, %rdx
je 0x34520
movq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x74c0
testl %eax, %eax
je 0x34520
leaq 0x58(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x8ce1(%rip), %rsi      # 0x3d199
leaq 0x8ce2(%rip), %rdx      # 0x3d1a1
leaq 0x48(%rsp), %rdi
callq 0x80f4
movq 0x10(%rsp), %rcx
leaq 0xc8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
xorl %edx, %edx
callq 0x74d0
movq 0xd0(%rsp), %rdx
cmpq 0x10(%rsp), %rdx
jne 0x34513
movq 0xc8(%rsp), %r15
testq %rdx, %rdx
je 0x34524
movq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x74c0
testl %eax, %eax
setne %bpl
jmp 0x34526
movb $0x1, %bpl
movq 0xc8(%rsp), %r15
jmp 0x34526
xorl %ebp, %ebp
jmp 0x34562
xorl %ebp, %ebp
leaq 0xd8(%rsp), %rax
cmpq %rax, %r15
je 0x34546
movq 0xd8(%rsp), %rsi
incq %rsi
movq %r15, %rdi
callq 0x74b0
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x3455d
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x28(%rsp), %r15
leaq 0x38(%rsp), %rax
cmpq %rax, %r15
je 0x3457c
movq 0x38(%rsp), %rsi
incq %rsi
movq %r15, %rdi
callq 0x74b0
movq 0x68(%rsp), %rdi
cmpq %r12, %rdi
je 0x34593
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x74b0
testb %bpl, %bpl
jne 0x3473d
movq 0x198(%rbx), %rdx
incq %rdx
leaq 0x9343(%rip), %rsi      # 0x3d8f0
movl $0x2, %ecx
movq %r14, %rdi
callq 0x77f0
cmpq $-0x1, %rax
je 0x345d9
leaq 0x65fc(%rip), %rsi      # 0x3abc3
leaq 0x8(%rsp), %rdi
callq 0x7180
testl %eax, %eax
je 0x34661
movq 0x198(%rbx), %rdx
incq %rdx
leaq 0x9306(%rip), %rsi      # 0x3d8f0
movl $0x2, %ecx
movq %r14, %rdi
callq 0x77f0
cmpq $-0x1, %rax
je 0x34715
leaq 0x8b91(%rip), %rsi      # 0x3d199
leaq 0x8(%rsp), %rdi
callq 0x7180
testl %eax, %eax
jne 0x34715
leaq 0x98(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x91b8(%rip), %rsi      # 0x3d7e5
leaq 0x91d6(%rip), %rdx      # 0x3d80a
leaq 0x88(%rsp), %rdi
callq 0x80f4
leaq 0x88(%rsp), %rdi
movl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x32966
movq 0x88(%rsp), %rdi
jmp 0x346a6
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x914b(%rip), %rsi      # 0x3d7bf
leaq 0x9169(%rip), %rdx      # 0x3d7e4
leaq 0xa8(%rsp), %rdi
callq 0x80f4
leaq 0xa8(%rsp), %rdi
movl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x32966
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x346b6
movq (%r15), %rsi
incq %rsi
callq 0x74b0
leaq 0x120(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0x72c0
leaq 0x9222(%rip), %rsi      # 0x3d8f0
movl $0x2, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x77f0
addq $0x2, %rax
movq %rax, 0x198(%rbx)
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x34703
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x190, 0x188(%rbx)     # imm = 0x190
movl $0x10, %edi
callq 0x7260
movq %rax, %r14
leaq 0x905a(%rip), %rsi      # 0x3d78d
movq %rax, %rdi
callq 0x78c0
jmp 0x34763
movl $0x190, 0x188(%rbx)     # imm = 0x190
movl $0x10, %edi
callq 0x7260
movq %rax, %r14
leaq 0x9032(%rip), %rsi      # 0x3d78d
movq %rax, %rdi
callq 0x78c0
movq 0x1985e(%rip), %rsi     # 0x4dfc8
movq 0x1983f(%rip), %rdx     # 0x4dfb0
movq %r14, %rdi
callq 0x77d0
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x34824
movq 0xb8(%rsp), %rsi
jmp 0x34815
jmp 0x34821
jmp 0x347f6
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x347bd
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x347bd
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x34806
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x34806
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x34824
movq 0x98(%rsp), %rsi
jmp 0x34815
jmp 0x34821
movq %rax, %rbx
movq %r14, %rdi
callq 0x7390
jmp 0x34824
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r12, %rdi
je 0x34824
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x34824
jmp 0x34821
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3483f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
movq %rbx, %rdi
callq 0x7810
nop