// File: /workspace/github_cpp_makefile_star2_O1/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 0x13764(%rip), %r15     # 0x257df
movq %rsp, %r12
movl $0x2, %ecx
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x4770
movl $0x1, %ebp
cmpq $-0x1, %rax
je 0x121f8
movq %rax, %r13
movl $0x2, %ecx
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x4770
testq %rax, %rax
je 0x121e0
movq %rbx, %rdi
movl $0x3a, %esi
xorl %edx, %edx
callq 0x4580
cmpq $-0x1, %rax
je 0x121f3
movq %rax, %rbp
movq %r12, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4480
leaq 0x60(%rsp), %rdi
movq %r12, %rsi
callq 0x4560
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x1210c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4460
leaq 0x1(%rbp), %rdx
notq %rbp
addq %r13, %rbp
movq %r12, %rdi
movq %rbx, %rsi
movq %rbp, %rcx
callq 0x4480
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x4560
movq (%rsp), %rdi
cmpq %r14, %rdi
leaq 0x40(%rsp), %rbp
je 0x1214c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4460
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x6bac
movq %r12, %rdi
movq %rbp, %rsi
movl $0x20, %edx
callq 0x24262
movq 0x80(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0xa86c
movq %rax, %rdi
movq %r12, %rsi
callq 0x4560
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x121ae
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4460
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x121ca
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4460
addq $0x2, %r13
movq %rbx, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x40b0
jmp 0x1207e
addq $0x2, %r13
movq %rbx, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x40b0
jmp 0x121f8
movl $0x190, %ebp            # imm = 0x190
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x12214
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4460
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x12230
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x4460
movl %ebp, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x12288
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x12264
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4460
jmp 0x12264
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x1228b
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4460
jmp 0x1228b
jmp 0x12288
jmp 0x12288
jmp 0x12288
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x122a7
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4460
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x122c3
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x4460
movq %rbx, %rdi
callq 0x4780
nop