// File: /workspace/github_cpp_makefile_star2_O1/llefranc[P]42_webserv/srcs/server/Request.cpp
// Function: Request::parseRequestLine(unsigned long)
void Request::parseRequestLine(size_t posCLRF)
{
	// Checking that first line is not empty or contains whitespaces
	if (posCLRF == _index)
		throw StatusLine(400, REASON_400, "first line is empty");

    std::string requestLine = _buffer.substr(_index, posCLRF - _index);
	
    if (requestLine.find_first_of("\r\n\t\v\f") != std::string::npos)
		throw StatusLine(400, REASON_400, "whitespaces not allowed");
	else if (std::count(requestLine.begin(), requestLine.end(), ' ') > 2)
		throw StatusLine(400, REASON_400, "too many spaces");

	// Splitting the request line
	std::vector<std::string> tokens = splitWithSep(requestLine, ' ');
		
	if (tokens.size() != 3)
		throw StatusLine(400, REASON_400, "a field from request line is missing");

	// Parsing the request line
    parseURI(tokens[1]);    
	parseMethodToken(tokens[0]);
	parseHTTPVersion(tokens[2]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xa0, %rsp
movq %rsi, %rcx
movq 0x20(%rdi), %rdx
subq %rdx, %rcx
je 0xd0f4
movq %rdi, %rbx
leaq -0x60(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4410
leaq 0x8784(%rip), %rsi      # 0x15739
movl $0x5, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x45a0
cmpq $-0x1, %rax
jne 0xd15a
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
testq %rdx, %rdx
je 0xcffe
xorl %eax, %eax
xorl %ecx, %ecx
xorl %edi, %edi
cmpb $0x20, (%rsi,%rax)
sete %dil
addq %rdi, %rcx
incq %rax
cmpq %rax, %rdx
jne 0xcfdf
cmpq $0x3, %rcx
jae 0xd223
addq %rsi, %rdx
leaq -0xa8(%rbp), %r14
movq %r14, -0x10(%r14)
leaq -0xb8(%rbp), %rdi
callq 0x67a2
leaq -0x78(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
movl $0x20, %edx
callq 0x13978
movq -0xb8(%rbp), %rdi
cmpq %r14, %rdi
je 0xd048
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x43e0
movq -0x78(%rbp), %rax
movq -0x70(%rbp), %rcx
subq %rax, %rcx
cmpq $0x60, %rcx
jne 0xd1c0
leaq -0x88(%rbp), %r14
movq %r14, -0x10(%r14)
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
addq %rsi, %rdx
leaq -0x98(%rbp), %rdi
callq 0x67a2
leaq -0x98(%rbp), %rsi
movq %rbx, %rdi
callq 0xdaca
movq -0x98(%rbp), %rdi
cmpq %r14, %rdi
je 0xd0a9
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x43e0
movq -0x78(%rbp), %rsi
movq %rbx, %rdi
callq 0xdc94
movq -0x78(%rbp), %rsi
addq $0x40, %rsi
callq 0xdec4
leaq -0x78(%rbp), %rdi
callq 0x6396
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xd0e4
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x43e0
addq $0xa0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x48, %edi
callq 0x41f0
movq %rax, %r14
leaq -0x50(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x8614(%rip), %rsi      # 0x15725
leaq 0x8620(%rip), %rdx      # 0x15738
leaq -0x60(%rbp), %rdi
callq 0x5790
movb $0x1, %r15b
leaq 0x84c1(%rip), %rdx      # 0x155ec
leaq -0x60(%rbp), %rcx
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
callq 0xe106
xorl %r15d, %r15d
leaq 0xfc2a(%rip), %rsi      # 0x1cd70
leaq 0x1027(%rip), %rdx      # 0xe174
movq %r14, %rdi
callq 0x46a0
jmp 0xd284
movl $0x48, %edi
callq 0x41f0
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x85c8(%rip), %rsi      # 0x1573f
leaq 0x85d8(%rip), %rdx      # 0x15756
leaq -0x40(%rbp), %rdi
callq 0x5790
movb $0x1, %r15b
leaq 0x845b(%rip), %rdx      # 0x155ec
leaq -0x40(%rbp), %rcx
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
callq 0xe106
xorl %r15d, %r15d
leaq 0xfbc4(%rip), %rsi      # 0x1cd70
leaq 0xfc1(%rip), %rdx       # 0xe174
movq %r14, %rdi
callq 0x46a0
jmp 0xd284
movl $0x48, %edi
callq 0x41f0
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x858a(%rip), %rsi      # 0x15767
leaq 0x85a7(%rip), %rdx      # 0x1578b
leaq -0x40(%rbp), %rdi
callq 0x5790
movb $0x1, %r15b
leaq 0x83f5(%rip), %rdx      # 0x155ec
leaq -0x40(%rbp), %rcx
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
callq 0xe106
xorl %r15d, %r15d
leaq 0xfb5e(%rip), %rsi      # 0x1cd70
leaq 0xf5b(%rip), %rdx       # 0xe174
movq %r14, %rdi
callq 0x46a0
jmp 0xd284
movl $0x48, %edi
callq 0x41f0
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x8517(%rip), %rsi      # 0x15757
leaq 0x851f(%rip), %rdx      # 0x15766
leaq -0x40(%rbp), %rdi
callq 0x5790
movb $0x1, %r15b
leaq 0x8392(%rip), %rdx      # 0x155ec
leaq -0x40(%rbp), %rcx
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
callq 0xe106
xorl %r15d, %r15d
leaq 0xfafb(%rip), %rsi      # 0x1cd70
leaq 0xef8(%rip), %rdx       # 0xe174
movq %r14, %rdi
callq 0x46a0
jmp 0xd2be
jmp 0xd2d8
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xd2a8
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x43e0
jmp 0xd2a8
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xd36b
movq %r14, %rdi
callq 0x42e0
jmp 0xd36b
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xd2de
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x43e0
jmp 0xd2de
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xd374
movq %r14, %rdi
callq 0x42e0
jmp 0xd374
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0xd314
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x43e0
jmp 0xd314
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xd38d
movq %r14, %rdi
callq 0x42e0
jmp 0xd38d
movq %rax, %rbx
movq -0x98(%rbp), %rdi
cmpq %r14, %rdi
je 0xd36b
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x43e0
jmp 0xd36b
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
cmpq %r14, %rdi
je 0xd374
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x43e0
jmp 0xd374
movq %rax, %rbx
jmp 0xd374
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x6396
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xd38d
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x43e0
movq %rbx, %rdi
callq 0x46d0
nop