// File: /workspace/github_cpp_makefile_star2_O1/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 0x14655(%rip), %rsi     # 0x257df
movl $0x2, %ecx
xorl %edx, %edx
callq 0x4770
cmpq $-0x1, %rax
je 0x1140a
movq %rbx, %rdi
movl $0x20, %esi
xorl %edx, %edx
callq 0x4580
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4480
movq %r14, %rdi
callq 0x24710
testb %al, %al
je 0x113e2
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 0x4580
movl $0x190, %ebp            # imm = 0x190
testq %rax, %rax
je 0x113ea
movq %rbx, %rdi
movl $0x20, %esi
xorl %edx, %edx
callq 0x4580
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4480
movq %rsp, %rdi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0x4560
movq (%r14), %rdi
leaq 0x30(%rsp), %r12
cmpq %r12, %rdi
je 0x1125a
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4460
movq (%rsp), %rax
cmpb $0x2f, (%rax)
jne 0x113e7
movq %rsp, %rdi
callq 0x11eab
testb %al, %al
je 0x1141b
cmpq $0x1869f, 0x8(%rsp)     # imm = 0x1869F
ja 0x11422
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 0x4580
cmpq $-0x1, %rax
je 0x11330
movq %r14, %rdi
movl $0x3f, %esi
xorl %edx, %edx
callq 0x4580
leaq 0x1(%rax), %rdx
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
movq $-0x1, %rcx
callq 0x4480
leaq 0x60(%rbx), %rdi
leaq 0x20(%rsp), %r15
movq %r15, %rsi
callq 0x4560
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x11308
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4460
movq %r14, %rdi
movl $0x3f, %esi
xorl %edx, %edx
callq 0x4580
movq 0x48(%rbx), %rcx
cmpq %rax, %rcx
jb 0x11429
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 0x4580
testq %rax, %rax
je 0x113ea
leaq 0x1448d(%rip), %rsi     # 0x257df
movl $0x2, %ecx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x4770
movq %rax, %r14
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4480
movq %rsp, %rdi
leaq 0x20(%rsp), %r15
movq %r15, %rsi
callq 0x4560
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x1139b
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4460
leaq 0x143d0(%rip), %rsi     # 0x25772
movq %rsp, %rdi
callq 0x40f0
movl $0x1f9, %ebp            # imm = 0x1F9
testl %eax, %eax
jne 0x113e7
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 0x113ea
movl $0x1f5, %ebp            # imm = 0x1F5
xorl %r14d, %r14d
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11405
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4460
testb %r14b, %r14b
je 0x1140c
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 0x113e7
movl $0x19e, %ebp            # imm = 0x19E
jmp 0x113e7
leaq 0x142d9(%rip), %rdi     # 0x25709
leaq 0x14309(%rip), %rsi     # 0x25740
movq %rax, %rdx
xorl %eax, %eax
callq 0x4640
jmp 0x11449
jmp 0x11449
jmp 0x11449
jmp 0x11449
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11467
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4460
movq %rbx, %rdi
callq 0x4780
nop