// File: /workspace/github_cpp_makefile_star2_O1/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 0x155f3(%rip), %r12     # 0x257df
leaq 0x8(%rsp), %r13
leaq 0x58(%rsp), %rbx
movl $0x2, %ecx
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x4770
cmpq $-0x1, %rax
je 0x10326
movq %rax, %r14
movl $0x2, %ecx
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x4770
testq %rax, %rax
je 0x10315
movq %r15, %rdi
movl $0x3a, %esi
xorl %edx, %edx
callq 0x4580
cmpq $-0x1, %rax
je 0x102ff
movq %rax, %rbp
movq %r13, %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4480
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0x4560
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x10285
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4460
leaq 0x1(%rbp), %rdx
notq %rbp
addq %r14, %rbp
movq %rbx, %rdi
movq %r15, %rsi
movq %rbp, %rcx
callq 0x4480
movq %r13, %rdi
movq %rbx, %rsi
movl $0x20, %edx
callq 0x24262
movq 0x28(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xce88
movq %rax, %rdi
movq %r13, %rsi
callq 0x4560
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x102e3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4460
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x102ff
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x4460
addq $0x2, %r14
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x40b0
jmp 0x101f6
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 0x15297(%rip), %rsi     # 0x255d1
leaq 0x1529e(%rip), %rdx     # 0x255df
callq 0x578e
leaq 0x8(%rsp), %rsi
movq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x10658
movq %rax, %rbx
leaq 0x8(%r15), %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1037b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4460
cmpq %r14, %rbx
je 0x103fe
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
movq %rax, (%rdi)
leaq 0x1523d(%rip), %rsi     # 0x255d1
leaq 0x15244(%rip), %rdx     # 0x255df
callq 0x578e
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x104da
movq %rax, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x244f4
movslq %eax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x103db
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4460
movq 0x50(%rsp), %rax
movq 0xc0(%rax), %rcx
cmpq %rbx, %rcx
jb 0x10429
movq %rbx, 0xc0(%rax)
movq 0xb8(%rax), %rax
movb $0x0, (%rax,%rbx)
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x1041a
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4460
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x152d9(%rip), %rdi     # 0x25709
leaq 0x15309(%rip), %rsi     # 0x25740
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4640
jmp 0x104aa
jmp 0x104aa
jmp 0x104aa
jmp 0x1044b
jmp 0x104aa
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x104ad
movq 0x18(%rsp), %rsi
jmp 0x104a0
movq %rax, %rbx
jmp 0x1048c
jmp 0x104aa
jmp 0x104aa
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1048c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4460
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x104ad
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x4460
jmp 0x104ad
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x104c9
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4460
movq %rbx, %rdi
callq 0x4780
nop