// File: /workspace/github_cpp_makefile_star2_O3/solaldunckel[P]webserv/srcs/HTTP/Request.cpp
// Function: Request::chunk_trailer()
int Request::chunk_trailer() {
  size_t end, last;
  std::string header;
  std::string value;

  while ((end = buffer_.find("\r\n")) != std::string::npos) {
    if (buffer_.find("\r\n") == 0) {
      buffer_.erase(0, end + 2);
      break;
    }
    if ((last = buffer_.find(':', 0)) != std::string::npos) {
      header = buffer_.substr(0, last);
      value = buffer_.substr(last + 1, end - last - 1);
      headers_[header] = ft::trim_left(value, ' ');
    }
    else
      return 400;
    buffer_.erase(0, end + 2);
  }
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
leaq 0x70(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x30(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x10(%rsp), %r14
leaq 0xc0(%rdi), %rax
movq %rax, 0x80(%rsp)
leaq 0x136be(%rip), %r15     # 0x257df
movq %rsp, %r12
movl $0x2, %ecx
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x4780
movl $0x1, %ebp
cmpq $-0x1, %rax
je 0x1229e
movq %rax, %r13
movl $0x2, %ecx
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x4780
testq %rax, %rax
je 0x12286
movq %rbx, %rdi
movl $0x3a, %esi
xorl %edx, %edx
callq 0x4590
cmpq $-0x1, %rax
je 0x12299
movq %rax, %rbp
movq %r12, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4490
leaq 0x60(%rsp), %rdi
movq %r12, %rsi
callq 0x4570
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x121b2
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x1(%rbp), %rdx
notq %rbp
addq %r13, %rbp
movq %r12, %rdi
movq %rbx, %rsi
movq %rbp, %rcx
callq 0x4490
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x4570
movq (%rsp), %rdi
cmpq %r14, %rdi
leaq 0x40(%rsp), %rbp
je 0x121f2
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x6c2a
movq %r12, %rdi
movq %rbp, %rsi
movl $0x20, %edx
callq 0x241ea
movq 0x80(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0xa8c4
movq %rax, %rdi
movq %r12, %rsi
callq 0x4570
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x12254
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x12270
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4470
addq $0x2, %r13
movq %rbx, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x40b0
jmp 0x12124
addq $0x2, %r13
movq %rbx, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x40b0
jmp 0x1229e
movl $0x190, %ebp            # imm = 0x190
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x122ba
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x122d6
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x4470
movl %ebp, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1232e
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x1230a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x1230a
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x12331
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x12331
jmp 0x1232e
jmp 0x1232e
jmp 0x1232e
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x1234d
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x12369
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4790
nop