// File: /workspace/github_cpp_makefile_star2_O3/solaldunckel[P]webserv/srcs/HTTP/Request.cpp
// Function: Request::prebody()
int Request::prebody() {
  body_offset_ = 0;

  if (headers_.find("Host") == headers_.end() || headers_["Host"].empty())
    return 400;

  if (headers_["Host"].find("@") != std::string::npos)
    return 400;

  if (headers_.find("Transfer-Encoding") != headers_.end() && headers_["Transfer-Encoding"] == "chunked") {
    status_ = CHUNK;
    chunk_status_ = CHUNK_SIZE;
  } else if (headers_.find("Content-Length") != headers_.end()) {
    if (headers_["Content-Length"].find_first_not_of("0123456789") != std::string::npos)
      return 400;
    try {
      length_ = ft::stoi(headers_["Content-Length"]);
      if (length_ < 0)
        throw std::invalid_argument("negative content-length");
    }
    catch (std::exception &e) {
      return 400;
    }
    status_ = BODY;
  }
  else {
    return 1;
  }
  if (method_ != "POST" && method_ != "PUT")
    return 1;
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movl $0x0, 0xf0(%rdi)
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x139be(%rip), %rsi     # 0x25348
leaq 0x139bb(%rip), %rdx     # 0x2534c
leaq 0x8(%rsp), %rdi
callq 0x579e
leaq 0xc0(%rbx), %r14
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x12612
leaq 0xc8(%rbx), %r13
cmpq %r13, %rax
je 0x11a0b
leaq 0x38(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x1397d(%rip), %rsi     # 0x25348
leaq 0x1397a(%rip), %rdx     # 0x2534c
leaq 0x28(%rsp), %rdi
callq 0x579e
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0xa828
cmpq $0x0, 0x8(%rax)
sete %r15b
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x11a0e
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x11a0e
movb $0x1, %r15b
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x11a25
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
movl $0x190, %ebp            # imm = 0x190
testb %r15b, %r15b
jne 0x11a8d
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x1390a(%rip), %rsi     # 0x25348
leaq 0x13907(%rip), %rdx     # 0x2534c
callq 0x579e
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0xa828
leaq 0x13d1d(%rip), %rsi     # 0x2577b
movl $0x1, %ecx
movq %rax, %rdi
xorl %edx, %edx
callq 0x4780
movq %rax, %r15
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x11a87
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
cmpq $-0x1, %r15
je 0x11a9e
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x13cd0(%rip), %rsi     # 0x2577d
leaq 0x13cda(%rip), %rdx     # 0x2578e
callq 0x579e
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x12612
cmpq %r13, %rax
je 0x11b2c
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x13ca2(%rip), %rsi     # 0x2577d
leaq 0x13cac(%rip), %rdx     # 0x2578e
leaq 0x28(%rsp), %rdi
callq 0x579e
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0xa828
leaq 0x13c8f(%rip), %rsi     # 0x2578f
movq %rax, %rdi
callq 0x40f0
testl %eax, %eax
sete %r15b
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x11b2f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x11b2f
xorl %r15d, %r15d
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x11b46
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
testb %r15b, %r15b
je 0x11b96
movabsq $0x100000004, %rax      # imm = 0x100000004
movq %rax, 0x120(%rbx)
addq $0x20, %rbx
leaq 0x13a28(%rip), %rsi     # 0x2558f
movq %rbx, %rdi
callq 0x40f0
testl %eax, %eax
je 0x11b8f
leaq 0x13c1d(%rip), %rsi     # 0x25797
movq %rbx, %rdi
callq 0x40f0
movl $0x1, %ebp
testl %eax, %eax
jne 0x11a8d
xorl %ebp, %ebp
jmp 0x11a8d
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x13a2c(%rip), %rsi     # 0x255d1
leaq 0x13a33(%rip), %rdx     # 0x255df
callq 0x579e
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x12612
movq %rax, %r15
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x11bd8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
cmpq %r13, %r15
je 0x11ca9
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x139e1(%rip), %rsi     # 0x255d1
leaq 0x139e8(%rip), %rdx     # 0x255df
callq 0x579e
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0xa828
leaq 0x135e1(%rip), %rsi     # 0x251f1
movl $0xa, %ecx
movq %rax, %rdi
xorl %edx, %edx
callq 0x4730
movq %rax, %r15
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x11c39
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
cmpq $-0x1, %r15
jne 0x11a8d
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x1397f(%rip), %rsi     # 0x255d1
leaq 0x13986(%rip), %rdx     # 0x255df
callq 0x579e
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0xa828
movq %rax, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x24471
cltq
movq %rax, 0x118(%rbx)
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x11c9a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
movl $0x3, 0x120(%rbx)
jmp 0x11b5c
movl $0x1, %ebp
jmp 0x11a8d
movq %rdx, %r14
movq %rax, %rbx
jmp 0x11cd8
movq %rdx, %r14
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x11cd8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
cmpl $0x1, %r14d
jne 0x11d53
movq %rbx, %rdi
callq 0x4180
callq 0x4720
jmp 0x11a8d
jmp 0x11d34
jmp 0x11d50
jmp 0x11d34
jmp 0x11d50
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
jne 0x11d23
jmp 0x11d37
jmp 0x11d34
jmp 0x11d34
jmp 0x11d50
jmp 0x11d34
jmp 0x11d50
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x11d37
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x11d37
jmp 0x11d34
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x11d53
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x11d53
movq %rax, %rbx
movq %rbx, %rdi
callq 0x4790
nop