// File: llefranc[P]42_webserv/srcs/server/Request.cpp
// Function: Request::parseMethodToken(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void Request::parseMethodToken(const std::string& token)
{
	std::string methods[NB_METHODS] = {"GET", "HEAD", "POST", "DELETE"};
	
	for (int i = 0; i < NB_METHODS; ++i)
	{
		// Token should exactly match one of the five methods
		if (!token.compare(_index, methods[i].size(), methods[i]) &&
				token.size() == methods[i].size())
		{
			_reqLine.setMethod(i);
			return ;
		}
	}

	throw StatusLine(400, REASON_400, "unknown method");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movb $0x1, -0xb0(%rbp)
leaq -0x90(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq %rax, -0x98(%rbp)
leaq -0x99(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x58f0
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rdx
leaq 0xab94(%rip), %rsi      # 0x23bb6
callq 0x63e0
jmp 0x19029
leaq -0x70(%rbp), %rax
movq %rax, -0x108(%rbp)
movq %rax, -0x98(%rbp)
leaq -0xad(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x58f0
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rdx
leaq 0xa22c(%rip), %rsi      # 0x2328f
callq 0x63e0
jmp 0x1906a
leaq -0x50(%rbp), %rax
movq %rax, -0x118(%rbp)
movq %rax, -0x98(%rbp)
leaq -0xae(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x58f0
movq -0x118(%rbp), %rdi
movq -0x110(%rbp), %rdx
leaq 0xab43(%rip), %rsi      # 0x23be7
callq 0x63e0
jmp 0x190ab
leaq -0x30(%rbp), %rax
movq %rax, -0x128(%rbp)
movq %rax, -0x98(%rbp)
leaq -0xaf(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x58f0
movq -0x128(%rbp), %rdi
movq -0x120(%rbp), %rdx
leaq 0xa165(%rip), %rsi      # 0x2324a
callq 0x63e0
jmp 0x190ec
movb $0x0, -0xb0(%rbp)
leaq -0xaf(%rbp), %rdi
callq 0x55c0
leaq -0xae(%rbp), %rdi
callq 0x55c0
leaq -0xad(%rbp), %rdi
callq 0x55c0
leaq -0x99(%rbp), %rdi
callq 0x55c0
movl $0x0, -0xb4(%rbp)
cmpl $0x4, -0xb4(%rbp)
jge 0x1932c
movq -0xf8(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, -0x140(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x138(%rbp)
movslq -0xb4(%rbp), %rax
shlq $0x5, %rax
leaq -0x90(%rbp,%rax), %rdi
callq 0x53b0
movq -0x140(%rbp), %rdi
movq -0x138(%rbp), %rsi
movq %rax, %rdx
movslq -0xb4(%rbp), %rax
shlq $0x5, %rax
leaq -0x90(%rbp,%rax), %rcx
callq 0x56e0
movl %eax, -0x12c(%rbp)
jmp 0x191a0
movl -0x12c(%rbp), %eax
cmpl $0x0, %eax
jne 0x19316
movq -0x10(%rbp), %rdi
callq 0x53b0
movq %rax, -0x148(%rbp)
movslq -0xb4(%rbp), %rax
leaq -0x90(%rbp), %rdi
shlq $0x5, %rax
addq %rax, %rdi
callq 0x53b0
movq %rax, %rcx
movq -0x148(%rbp), %rax
cmpq %rcx, %rax
jne 0x19316
movq -0xf8(%rbp), %rdi
addq $0x30, %rdi
movl -0xb4(%rbp), %esi
callq 0x19eb0
jmp 0x19204
leaq -0x90(%rbp), %rax
movq %rax, -0x158(%rbp)
addq $0x80, %rax
movq %rax, -0x150(%rbp)
jmp 0x19411
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x19296
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x1928a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x1927e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0xaf(%rbp), %rdi
callq 0x55c0
leaq -0xae(%rbp), %rdi
callq 0x55c0
leaq -0xad(%rbp), %rdi
callq 0x55c0
leaq -0x99(%rbp), %rdi
callq 0x55c0
testb $0x1, -0xb0(%rbp)
jne 0x192ad
jmp 0x192fa
movq -0x98(%rbp), %rax
leaq -0x90(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x160(%rbp)
je 0x192f8
movq -0x160(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x168(%rbp)
callq 0x5a08
movq -0x168(%rbp), %rax
leaq -0x90(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x160(%rbp)
jne 0x192c7
jmp 0x192fa
jmp 0x19499
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x1944b
jmp 0x19318
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x1912d
movb $0x1, -0xda(%rbp)
movl $0x48, %edi
callq 0x5290
movq %rax, -0x178(%rbp)
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0x58f0
movq -0x170(%rbp), %rdx
leaq 0xa432(%rip), %rsi      # 0x23797
leaq -0xd8(%rbp), %rdi
callq 0x63e0
jmp 0x19373
movq -0x178(%rbp), %rdi
leaq 0xa276(%rip), %rdx      # 0x235f7
movl $0x190, %esi            # imm = 0x190
leaq -0xd8(%rbp), %rcx
callq 0x199d0
jmp 0x19394
movq -0x178(%rbp), %rdi
movb $0x0, -0xda(%rbp)
leaq 0x179e7(%rip), %rsi     # 0x30d90
leaq 0x6d0(%rip), %rdx       # 0x19a80
callq 0x58a0
jmp 0x194a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x193ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x5a08
leaq -0xd9(%rbp), %rdi
callq 0x55c0
testb $0x1, -0xda(%rbp)
jne 0x19403
jmp 0x1940f
movq -0x178(%rbp), %rdi
callq 0x53f0
jmp 0x1944b
movq -0x150(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x180(%rbp)
callq 0x5a08
movq -0x158(%rbp), %rcx
movq -0x180(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x150(%rbp)
jne 0x19411
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
leaq -0x90(%rbp), %rax
movq %rax, -0x190(%rbp)
addq $0x80, %rax
movq %rax, -0x188(%rbp)
movq -0x188(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x198(%rbp)
callq 0x5a08
movq -0x190(%rbp), %rcx
movq -0x198(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x188(%rbp)
jne 0x19466
jmp 0x19499
movq -0xa8(%rbp), %rdi
callq 0x58e0
nopw %cs:(%rax,%rax)