// File: /workspace/github_cpp_makefile_star2_O2/solaldunckel[P]webserv/srcs/HTTP/Request.cpp
// Function: Request::method_line()
int Request::method_line() {
  if (buffer_.find("\r\n") != std::string::npos) {
    std::string tmp = buffer_.substr(0, buffer_.find(' '));

    if (isValidMethod(tmp)) {
      method_ = tmp;
      buffer_.erase(0, method_.length() + 1);
    } else
      return 501;

    if (buffer_.find(' ') == 0)
      return 400;

    tmp = buffer_.substr(0, buffer_.find(' '));

    if (tmp[0] != '/')
      return 400;

    if (!check_validity(tmp))
      return 403;

    if (tmp.length() < 100000) {
      target_ = tmp;
      buffer_.erase(0, target_.length() + 1);
    } else
      return 414;

    if (target_.find('?') != std::string::npos) {
      query_string_ = target_.substr(target_.find('?') + 1);
      target_.erase(target_.find('?'));
    }

    if (buffer_.find(' ') == 0)
      return 400;

    size_t end = buffer_.find("\r\n");
    tmp = buffer_.substr(0, end);

    if (tmp == "HTTP/1.1") {
      protocol_ = tmp;
      buffer_.erase(0, end + 2);
    } else
      return 505;

    status_ = HEADERS;
  }

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
leaq 0xe04a(%rip), %rsi      # 0x1c77e
xorl %edx, %edx
callq 0x4870
cmpq $-0x1, %rax
je 0xe953
pushq $0x20
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x45a0
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x44a0
movq %r14, %rdi
callq 0x1b710
testb %al, %al
je 0xe93e
leaq 0x20(%rbx), %rdi
movq %rsp, %rsi
callq 0x4240
movq 0x28(%rbx), %rdx
incq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x40a0
xorl %r14d, %r14d
pushq $0x20
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x45a0
movl $0x190, %ebp            # imm = 0x190
testq %rax, %rax
je 0xe946
pushq $0x20
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x45a0
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x44a0
movq %rsp, %r14
leaq 0x20(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x4560
movq %r15, %rdi
callq 0x4898
movq (%r14), %rax
cmpb $0x2f, (%rax)
jne 0xe943
movq %rsp, %rdi
callq 0xf0fc
testb %al, %al
je 0xe964
cmpq $0x1869f, 0x8(%rsp)     # imm = 0x1869F
ja 0xe96b
leaq 0x40(%rbx), %r14
movq %rsp, %rsi
movq %r14, %rdi
callq 0x4240
movq 0x48(%rbx), %rdx
incq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x40a0
pushq $0x3f
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x45a0
cmpq $-0x1, %rax
je 0xe89d
pushq $0x3f
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x45a0
leaq 0x1(%rax), %rdx
leaq 0x20(%rsp), %rdi
pushq $-0x1
popq %rcx
movq %r14, %rsi
callq 0x44a0
leaq 0x60(%rbx), %rdi
leaq 0x20(%rsp), %r15
movq %r15, %rsi
callq 0x4560
movq %r15, %rdi
callq 0x4898
pushq $0x3f
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x45a0
pushq $-0x1
popq %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x40a0
xorl %r14d, %r14d
pushq $0x20
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x45a0
testq %rax, %rax
je 0xe946
leaq 0xdec1(%rip), %rsi      # 0x1c77e
movq %rbx, %rdi
xorl %edx, %edx
callq 0x4870
movq %rax, %r14
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x44a0
movq %rsp, %r15
leaq 0x20(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x4560
movq %r12, %rdi
callq 0x4898
leaq 0xde13(%rip), %rsi      # 0x1c711
movq %r15, %rdi
callq 0x610b
movl $0x1f9, %ebp            # imm = 0x1F9
testb %al, %al
je 0xe943
leaq 0x80(%rbx), %rdi
movq %rsp, %rsi
callq 0x4240
addq $0x2, %r14
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x40a0
movl $0x1, 0x120(%rbx)
movb $0x1, %r14b
jmp 0xe946
movl $0x1f5, %ebp            # imm = 0x1F5
xorl %r14d, %r14d
movq %rsp, %rdi
callq 0x4898
testb %r14b, %r14b
je 0xe955
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x193, %ebp            # imm = 0x193
jmp 0xe943
movl $0x19e, %ebp            # imm = 0x19E
jmp 0xe943
jmp 0xe97a
jmp 0xe97a
jmp 0xe97a
jmp 0xe97a
movq %rax, %rbx
movq %rsp, %rdi
callq 0x4898
movq %rbx, %rdi
callq 0x4750
nop