// File: /workspace/github_cpp_makefile_star2_O3/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 0x1455b(%rip), %rsi     # 0x257df
movl $0x2, %ecx
xorl %edx, %edx
callq 0x4780
cmpq $-0x1, %rax
je 0x11504
movq %rbx, %rdi
movl $0x20, %esi
xorl %edx, %edx
callq 0x4590
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4490
movq %r14, %rdi
callq 0x24690
testb %al, %al
je 0x114dc
leaq 0x20(%rbx), %rdi
movq %rsp, %rsi
callq 0x4230
movq 0x28(%rbx), %rdx
incq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x40b0
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x20, %esi
xorl %edx, %edx
callq 0x4590
movl $0x190, %ebp            # imm = 0x190
testq %rax, %rax
je 0x114e4
movq %rbx, %rdi
movl $0x20, %esi
xorl %edx, %edx
callq 0x4590
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4490
movq %rsp, %rdi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0x4570
movq (%r14), %rdi
leaq 0x30(%rsp), %r12
cmpq %r12, %rdi
je 0x11354
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4470
movq (%rsp), %rax
cmpb $0x2f, (%rax)
jne 0x114e1
movq %rsp, %rdi
callq 0x11f51
testb %al, %al
je 0x11515
cmpq $0x1869f, 0x8(%rsp)     # imm = 0x1869F
ja 0x1151c
leaq 0x40(%rbx), %r14
movq %rsp, %rsi
movq %r14, %rdi
callq 0x4230
movq 0x48(%rbx), %rdx
incq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x40b0
movq %r14, %rdi
movl $0x3f, %esi
xorl %edx, %edx
callq 0x4590
cmpq $-0x1, %rax
je 0x1142a
movq %r14, %rdi
movl $0x3f, %esi
xorl %edx, %edx
callq 0x4590
leaq 0x1(%rax), %rdx
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
movq $-0x1, %rcx
callq 0x4490
leaq 0x60(%rbx), %rdi
leaq 0x20(%rsp), %r15
movq %r15, %rsi
callq 0x4570
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x11402
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4470
movq %r14, %rdi
movl $0x3f, %esi
xorl %edx, %edx
callq 0x4590
movq 0x48(%rbx), %rcx
cmpq %rax, %rcx
jb 0x11523
movq %rax, 0x48(%rbx)
movq 0x40(%rbx), %rcx
movb $0x0, (%rcx,%rax)
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x20, %esi
xorl %edx, %edx
callq 0x4590
testq %rax, %rax
je 0x114e4
leaq 0x14393(%rip), %rsi     # 0x257df
movl $0x2, %ecx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x4780
movq %rax, %r14
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4490
movq %rsp, %rdi
leaq 0x20(%rsp), %r15
movq %r15, %rsi
callq 0x4570
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x11495
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x142d6(%rip), %rsi     # 0x25772
movq %rsp, %rdi
callq 0x40f0
movl $0x1f9, %ebp            # imm = 0x1F9
testl %eax, %eax
jne 0x114e1
leaq 0x80(%rbx), %rdi
movq %rsp, %rsi
callq 0x4230
addq $0x2, %r14
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x40b0
movl $0x1, 0x120(%rbx)
movb $0x1, %r14b
jmp 0x114e4
movl $0x1f5, %ebp            # imm = 0x1F5
xorl %r14d, %r14d
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x114ff
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4470
testb %r14b, %r14b
je 0x11506
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 0x114e1
movl $0x19e, %ebp            # imm = 0x19E
jmp 0x114e1
leaq 0x141df(%rip), %rdi     # 0x25709
leaq 0x1420f(%rip), %rsi     # 0x25740
movq %rax, %rdx
xorl %eax, %eax
callq 0x4650
jmp 0x11543
jmp 0x11543
jmp 0x11543
jmp 0x11543
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11561
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4790
nop