// File: /workspace/github_cpp_makefile_star2_O2/solaldunckel[P]webserv/srcs/HTTP/Request.cpp
// Function: Request::headers()
int Request::chunk() {
  size_t end;

  while ((end = buffer_.find("\r\n")) != std::string::npos) {
    if (chunk_status_ == CHUNK_SIZE) {
      std::string hex = buffer_.substr(0, end);
      chunk_size_ = ft::to_hex(hex);
      buffer_.erase(0, end + 2);
      chunk_status_ = CHUNK_BODY;
    } else if (chunk_status_ == CHUNK_BODY) {
      if (chunk_size_ == 0) {
        if (!buffer_.empty())
          return chunk_trailer();
        return 1;
      }
      req_body_ += buffer_.substr(0, end);
      buffer_.erase(0, end + 2);
      chunk_size_ = 0;
      chunk_status_ = CHUNK_SIZE;
    }
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movq %rdi, %rbx
xorl %ecx, %ecx
leaq 0x28(%rsp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %cl, (%rax)
movb %cl, (%rdx)
leaq 0xc0(%rdi), %rax
movq %rax, 0x8(%rsp)
leaq 0xdda7(%rip), %r12      # 0x1c77e
leaq 0x98(%rsp), %r13
leaq 0x38(%rsp), %rbp
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x4870
movq %rax, 0x10(%rsp)
cmpq $-0x1, %rax
je 0xebc0
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x4870
testq %rax, %rax
je 0xebca
movq %rbp, %r12
movq %rbx, %rbp
movq %r13, %rbx
movq %rbp, %rdi
pushq $0x3a
popq %rsi
xorl %edx, %edx
callq 0x45a0
movq %rax, %r13
movl $0x190, %eax            # imm = 0x190
movq %rax, (%rsp)
leaq 0x1(%r13), %r14
cmpq $0x2, %r14
jb 0xebef
movq (%rbp), %rax
cmpb $0x20, -0x1(%rax,%r13)
je 0xebef
movq %rbx, %rdi
movq %rbp, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x44a0
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4560
movq %rbx, %rdi
callq 0x4898
notq %r13
addq 0x10(%rsp), %r13
movq %rbx, %rdi
movq %rbp, %r15
movq %rbp, %rsi
movq %r14, %rdx
movq %r13, %rcx
callq 0x44a0
leaq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x4560
movq %rbx, %rdi
callq 0x4898
movq %r12, %rdi
leaq 0xd87e(%rip), %rsi      # 0x1c332
callq 0x610b
testb %al, %al
movq 0x8(%rsp), %rdi
movq %rbx, %r13
movq %r12, %rbp
je 0xeaf3
movq %rbp, %rsi
callq 0xf402
leaq 0xdca7(%rip), %r12      # 0x1c77e
testq %rax, %rax
jne 0xebef
movq %r15, %rbx
cmpq $0x3e8, 0x40(%rsp)      # imm = 0x3E8
jbe 0xeb0c
jmp 0xebef
cmpq $0x3e8, 0x40(%rsp)      # imm = 0x3E8
leaq 0xdc7b(%rip), %r12      # 0x1c77e
movq %r15, %rbx
ja 0xebef
cmpq $0xfa0, 0x20(%rsp)      # imm = 0xFA0
ja 0xebef
leaq 0x58(%rsp), %r15
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
callq 0x45e0
leaq 0x78(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
pushq $0x20
popq %r15
movl %r15d, %edx
callq 0x1b3c5
movq %r13, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x1b386
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x9266
movq %rax, %rdi
movq %r13, %rsi
callq 0x4560
movq %r13, %rdi
callq 0x4898
leaq 0x78(%rsp), %rdi
callq 0x4898
leaq 0x58(%rsp), %rdi
callq 0x4898
movq %r14, %rdi
movq %rbp, %rsi
callq 0x9266
cmpq $0x0, 0x8(%rax)
jne 0xeba8
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0xf4fc
movq 0x10(%rsp), %rdx
addq $0x2, %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x40a0
jmp 0xe9e4
movq $0x0, (%rsp)
jmp 0xebef
movq 0x10(%rsp), %rdx
addq $0x2, %rdx
movq $0x0, (%rsp)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x40a0
movl $0x2, 0x120(%rbx)
leaq 0x18(%rsp), %rdi
callq 0x4898
leaq 0x38(%rsp), %rdi
callq 0x4898
movq (%rsp), %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xec51
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x4898
jmp 0xec30
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x4898
jmp 0xec3f
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x4898
jmp 0xec54
jmp 0xec51
jmp 0xec51
jmp 0xec51
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x4898
leaq 0x38(%rsp), %rdi
callq 0x4898
movq %rbx, %rdi
callq 0x4750