// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
subq $0xa8, %rsp
movq %rsi, %rcx
movq 0x20(%rdi), %rdx
subq %rdx, %rcx
je 0xb8d0
movq %rdi, %rbx
leaq -0x78(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4460
leaq 0x5f3f(%rip), %rsi      # 0x11732
movq %r14, %rdi
xorl %edx, %edx
callq 0x4240
cmpq $-0x1, %rax
jne 0xb928
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %rsi
addq %rdi, %rsi
leaq -0x58(%rbp), %rdx
movb $0x20, (%rdx)
callq 0xc90a
cmpq $0x3, %rax
jge 0xb980
leaq -0xb8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x4580
leaq -0x38(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
pushq $0x20
popq %rdx
callq 0xfe28
leaq -0xb8(%rbp), %rdi
callq 0x47d8
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rax
subq %rsi, %rax
cmpq $0x60, %rax
jne 0xb9d5
addq $0x20, %rsi
leaq -0x98(%rbp), %rdi
callq 0x4580
leaq -0x98(%rbp), %rsi
movq %rbx, %rdi
callq 0xc04e
leaq -0x98(%rbp), %rdi
callq 0x47d8
movq -0x38(%rbp), %rsi
movq %rbx, %rdi
callq 0xc1b6
movq -0x38(%rbp), %rsi
addq $0x40, %rsi
callq 0xc34c
leaq -0x38(%rbp), %rdi
callq 0x5ef4
leaq -0x78(%rbp), %rdi
callq 0x47d8
addq $0xa8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x48
popq %rdi
callq 0x4220
movq %rax, %r14
leaq 0x5e3c(%rip), %rsi      # 0x1171e
leaq -0x78(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x4ec8
movb $0x1, %r15b
leaq 0x5cec(%rip), %rdx      # 0x115e5
leaq -0x78(%rbp), %rcx
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
callq 0xc540
xorl %r15d, %r15d
leaq 0xd47c(%rip), %rsi      # 0x18d90
leaq 0xc7b(%rip), %rdx       # 0xc596
movq %r14, %rdi
callq 0x46b0
jmp 0xba28
pushq $0x48
popq %rdi
callq 0x4220
movq %rax, %r14
leaq 0x5dfe(%rip), %rsi      # 0x11738
leaq -0x58(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0x4ec8
movb $0x1, %r15b
leaq 0x5c94(%rip), %rdx      # 0x115e5
leaq -0x58(%rbp), %rcx
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
callq 0xc540
xorl %r15d, %r15d
leaq 0xd424(%rip), %rsi      # 0x18d90
leaq 0xc23(%rip), %rdx       # 0xc596
movq %r14, %rdi
callq 0x46b0
jmp 0xba28
pushq $0x48
popq %rdi
callq 0x4220
movq %rax, %r14
leaq 0x5dbe(%rip), %rsi      # 0x11750
leaq -0x58(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0x4ec8
movb $0x1, %r15b
leaq 0x5c3c(%rip), %rdx      # 0x115e5
leaq -0x58(%rbp), %rcx
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
callq 0xc540
xorl %r15d, %r15d
leaq 0xd3cc(%rip), %rsi      # 0x18d90
leaq 0xbcb(%rip), %rdx       # 0xc596
movq %r14, %rdi
callq 0x46b0
jmp 0xba28
pushq $0x48
popq %rdi
callq 0x4220
movq %rax, %r14
leaq 0x5d79(%rip), %rsi      # 0x11760
leaq -0x58(%rbp), %rdi
leaq -0x19(%rbp), %rdx
callq 0x4ec8
movb $0x1, %r15b
leaq 0x5be7(%rip), %rdx      # 0x115e5
leaq -0x58(%rbp), %rcx
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
callq 0xc540
xorl %r15d, %r15d
leaq 0xd377(%rip), %rsi      # 0x18d90
leaq 0xb76(%rip), %rdx       # 0xc596
movq %r14, %rdi
callq 0x46b0
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x47d8
testb %r15b, %r15b
jne 0xba3e
jmp 0xbab8
movq %rax, %rbx
movq %r14, %rdi
callq 0x4330
jmp 0xbab8
jmp 0xba4c
jmp 0xba5f
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x47d8
testb %r15b, %r15b
jne 0xba62
jmp 0xbac1
movq %rax, %rbx
movq %r14, %rdi
callq 0x4330
jmp 0xbac1
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x47d8
testb %r15b, %r15b
jne 0xba82
jmp 0xbaca
movq %rax, %rbx
movq %r14, %rdi
callq 0x4330
jmp 0xbaca
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x47d8
jmp 0xbab8
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0x47d8
jmp 0xbac1
jmp 0xbab0
movq %rax, %rbx
jmp 0xbac1
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x5ef4
leaq -0x78(%rbp), %rdi
callq 0x47d8
movq %rbx, %rdi
callq 0x46d0