// File: /workspace/github_cpp_makefile_star2_O3/solaldunckel[P]webserv/srcs/HTTP/CGI.cpp
// Function: CGI::parseHeaders(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>&)
void CGI::parseHeaders(std::map<std::string, std::string> &headers) {
  size_t end, last;
  std::string header;

  while ((end = body_.find("\r\n")) != std::string::npos) {
    if (body_.find("\r\n") == 0) {
      body_.erase(0, end + 2);
      break;
    }
    if ((last = body_.find(':', 0)) != std::string::npos) {
      header = body_.substr(0, last);
      headers[header] = ft::trim_left(body_.substr(last + 1, end - last - 1), ' ');
    }
    body_.erase(0, end + 2);
  }
  if (headers.count("Content-Length")) {
    size_t size = ft::stoi(headers["Content-Length"]);

    body_.erase(size);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, 0x28(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rdi, 0x50(%rsp)
leaq 0xb8(%rdi), %r15
leaq 0x15503(%rip), %r12     # 0x257df
leaq 0x8(%rsp), %r13
leaq 0x58(%rsp), %rbx
movl $0x2, %ecx
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x4780
cmpq $-0x1, %rax
je 0x10416
movq %rax, %r14
movl $0x2, %ecx
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x4780
testq %rax, %rax
je 0x10405
movq %r15, %rdi
movl $0x3a, %esi
xorl %edx, %edx
callq 0x4590
cmpq $-0x1, %rax
je 0x103ef
movq %rax, %rbp
movq %r13, %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4490
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0x4570
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x10375
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x1(%rbp), %rdx
notq %rbp
addq %r14, %rbp
movq %rbx, %rdi
movq %r15, %rsi
movq %rbp, %rcx
callq 0x4490
movq %r13, %rdi
movq %rbx, %rsi
movl $0x20, %edx
callq 0x241ea
movq 0x28(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xcf2e
movq %rax, %rdi
movq %r13, %rsi
callq 0x4570
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x103d3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x103ef
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x4470
addq $0x2, %r14
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x40b0
jmp 0x102e6
addq $0x2, %r14
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x40b0
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
movq %rax, (%rdi)
leaq 0x151a7(%rip), %rsi     # 0x255d1
leaq 0x151ae(%rip), %rdx     # 0x255df
callq 0x579e
leaq 0x8(%rsp), %rsi
movq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x10748
movq %rax, %rbx
leaq 0x8(%r15), %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1046b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
cmpq %r14, %rbx
je 0x104ee
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
movq %rax, (%rdi)
leaq 0x1514d(%rip), %rsi     # 0x255d1
leaq 0x15154(%rip), %rdx     # 0x255df
callq 0x579e
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x105ca
movq %rax, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x24471
movslq %eax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x104cb
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x50(%rsp), %rax
movq 0xc0(%rax), %rcx
cmpq %rbx, %rcx
jb 0x10519
movq %rbx, 0xc0(%rax)
movq 0xb8(%rax), %rax
movb $0x0, (%rax,%rbx)
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x1050a
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4470
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x151e9(%rip), %rdi     # 0x25709
leaq 0x15219(%rip), %rsi     # 0x25740
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4650
jmp 0x1059a
jmp 0x1059a
jmp 0x1059a
jmp 0x1053b
jmp 0x1059a
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1059d
movq 0x18(%rsp), %rsi
jmp 0x10590
movq %rax, %rbx
jmp 0x1057c
jmp 0x1059a
jmp 0x1059a
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1057c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1059d
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x1059d
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x105b9
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4790
nop