// File: /workspace/github_cpp_makefile_star2_O2/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, 0x10(%rsp)
movq %rdi, %rbx
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
addq $0xb8, %rbx
leaq 0xec1f(%rip), %r15      # 0x1c77e
leaq 0x18(%rsp), %r12
leaq 0x58(%rsp), %rbp
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x4870
cmpq $-0x1, %rax
je 0xdc4b
movq %rax, %r14
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x4870
testq %rax, %rax
je 0xdc3a
movq %rbx, %rdi
pushq $0x3a
popq %rsi
xorl %edx, %edx
callq 0x45a0
cmpq $-0x1, %rax
je 0xdc24
movq %rax, %r13
movq %r12, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x44a0
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0x4560
movq %r12, %rdi
callq 0x4898
leaq 0x1(%r13), %rdx
notq %r13
addq %r14, %r13
movq %rbp, %rdi
movq %rbx, %rsi
movq %r13, %rcx
callq 0x44a0
movq %r12, %rdi
movq %rbp, %rsi
pushq $0x20
popq %rdx
callq 0x1b386
movq 0x10(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0xb208
movq %rax, %rdi
movq %r12, %rsi
callq 0x4560
movq %r12, %rdi
callq 0x4898
movq %rbp, %rdi
callq 0x4898
addq $0x2, %r14
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x40a0
jmp 0xdb69
addq $0x2, %r14
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x40a0
leaq 0xe969(%rip), %rsi      # 0x1c5bb
leaq 0x18(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x5328
leaq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0xdd3c
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0x4898
testq %r14, %r14
je 0xdccf
leaq 0xe932(%rip), %rsi      # 0x1c5bb
leaq 0x18(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x5328
leaq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0xdd56
pushq $0xa
popq %rdx
movq %rax, %rdi
xorl %esi, %esi
callq 0x1b536
movslq %eax, %r14
leaq 0x18(%rsp), %rdi
callq 0x4898
pushq $-0x1
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x40a0
leaq 0x38(%rsp), %rdi
callq 0x4898
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xdd1e
jmp 0xdd1e
jmp 0xdd1e
jmp 0xdcf2
jmp 0xdd1e
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0xdd17
movq %rax, %rbx
jmp 0xdd12
jmp 0xdd1e
jmp 0xdd1e
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x4898
leaq 0x58(%rsp), %rdi
callq 0x4898
jmp 0xdd21
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x4898
movq %rbx, %rdi
callq 0x4750
nop