// File: /workspace/github_cpp_makefile_star2_O3/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 0xd12e
movq %rdi, %rbx
leaq -0x60(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4410
leaq 0x874a(%rip), %rsi      # 0x15739
movl $0x5, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x45a0
cmpq $-0x1, %rax
jne 0xd193
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
testq %rdx, %rdx
je 0xd038
xorl %eax, %eax
xorl %ecx, %ecx
xorl %edi, %edi
cmpb $0x20, (%rsi,%rax)
sete %dil
addq %rdi, %rcx
incq %rax
cmpq %rax, %rdx
jne 0xd019
cmpq $0x3, %rcx
jae 0xd25a
addq %rsi, %rdx
leaq -0xa8(%rbp), %r14
movq %r14, -0x10(%r14)
leaq -0xb8(%rbp), %rdi
callq 0x67e2
leaq -0x78(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
movl $0x20, %edx
callq 0x138a8
movq -0xb8(%rbp), %rdi
cmpq %r14, %rdi
je 0xd082
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x43e0
movq -0x78(%rbp), %rax
movq -0x70(%rbp), %rcx
subq %rax, %rcx
cmpq $0x60, %rcx
jne 0xd1f8
leaq -0x88(%rbp), %r14
movq %r14, -0x10(%r14)
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
addq %rsi, %rdx
leaq -0x98(%rbp), %rdi
callq 0x67e2
leaq -0x98(%rbp), %rsi
movq %rbx, %rdi
callq 0xdac2
movq -0x98(%rbp), %rdi
cmpq %r14, %rdi
je 0xd0e3
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x43e0
movq -0x78(%rbp), %rsi
movq %rbx, %rdi
callq 0xdc88
movq -0x78(%rbp), %rsi
addq $0x40, %rsi
callq 0xde96
leaq -0x78(%rbp), %rdi
callq 0x63d2
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xd11e
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), %r15
movq %r15, -0x10(%r15)
leaq 0x85db(%rip), %rsi      # 0x15725
leaq 0x85e7(%rip), %rdx      # 0x15738
leaq -0x60(%rbp), %rdi
callq 0x5796
movb $0x1, %r12b
leaq 0x8488(%rip), %rdx      # 0x155ec
leaq -0x60(%rbp), %rcx
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
callq 0xe0d4
xorl %r12d, %r12d
leaq 0xfbf1(%rip), %rsi      # 0x1cd70
leaq 0xfbc(%rip), %rdx       # 0xe142
movq %r14, %rdi
callq 0x46a0
jmp 0xd2ba
movl $0x48, %edi
callq 0x41f0
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x8590(%rip), %rsi      # 0x1573f
leaq 0x85a0(%rip), %rdx      # 0x15756
leaq -0x40(%rbp), %rdi
callq 0x5796
movb $0x1, %r12b
leaq 0x8423(%rip), %rdx      # 0x155ec
leaq -0x40(%rbp), %rcx
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
callq 0xe0d4
xorl %r12d, %r12d
leaq 0xfb8c(%rip), %rsi      # 0x1cd70
leaq 0xf57(%rip), %rdx       # 0xe142
movq %r14, %rdi
callq 0x46a0
jmp 0xd2ba
movl $0x48, %edi
callq 0x41f0
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x8553(%rip), %rsi      # 0x15767
leaq 0x8570(%rip), %rdx      # 0x1578b
leaq -0x40(%rbp), %rdi
callq 0x5796
movb $0x1, %r12b
leaq 0x83be(%rip), %rdx      # 0x155ec
leaq -0x40(%rbp), %rcx
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
callq 0xe0d4
xorl %r12d, %r12d
leaq 0xfb27(%rip), %rsi      # 0x1cd70
leaq 0xef2(%rip), %rdx       # 0xe142
movq %r14, %rdi
callq 0x46a0
jmp 0xd2ba
movl $0x48, %edi
callq 0x41f0
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x84e1(%rip), %rsi      # 0x15757
leaq 0x84e9(%rip), %rdx      # 0x15766
leaq -0x40(%rbp), %rdi
callq 0x5796
movb $0x1, %r12b
leaq 0x835c(%rip), %rdx      # 0x155ec
leaq -0x40(%rbp), %rcx
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
callq 0xe0d4
xorl %r12d, %r12d
leaq 0xfac5(%rip), %rsi      # 0x1cd70
leaq 0xe90(%rip), %rdx       # 0xe142
movq %r14, %rdi
callq 0x46a0
jmp 0xd2f0
jmp 0xd312
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0xd2d6
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x43e0
testb %r12b, %r12b
jne 0xd2e3
jmp 0xd393
movq %rax, %rbx
movq %r14, %rdi
callq 0x42e0
jmp 0xd393
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0xd308
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x43e0
testb %r12b, %r12b
jne 0xd315
jmp 0xd39c
movq %rax, %rbx
movq %r14, %rdi
callq 0x42e0
jmp 0xd39c
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r15, %rdi
je 0xd337
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x43e0
testb %r12b, %r12b
jne 0xd341
jmp 0xd3b5
movq %rax, %rbx
movq %r14, %rdi
callq 0x42e0
jmp 0xd3b5
movq %rax, %rbx
movq -0x98(%rbp), %rdi
cmpq %r14, %rdi
je 0xd393
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x43e0
jmp 0xd393
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
cmpq %r14, %rdi
je 0xd39c
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x43e0
jmp 0xd39c
movq %rax, %rbx
jmp 0xd39c
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x63d2
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xd3b5
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x43e0
movq %rbx, %rdi
callq 0x46d0
nop