// File: /workspace/github_cpp_makefile_star2_O1/solaldunckel[P]webserv/srcs/HTTP/Response.cpp
// Function: Response::build()
void Response::build() {
  std::string &method = config_.getMethod();

  file_.set_path(config_.getRoot() + "/" + config_.getTarget());

  if (error_code_ > 1)
    status_code_ = error_code_;
  else if (!config_.methodAccepted(method)) {
    status_code_ = 405;
    headers_["Allow"] = buildMethodList();
  }
  else if (config_.getClientMaxBodySize() > 0 && config_.getBody().length() > config_.getClientMaxBodySize()) {
    status_code_ = 413;
  }
  else if (config_.getAuth() != "off" && !checkAuth())
    status_code_ = 401;
  else
    status_code_ = handleMethods();

  if (status_code_ >= 300 && !body_.length())
    status_code_ = buildErrorPage(status_code_);

  if (!redirect_)
    createResponse();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x9f04
movq %rax, %r14
movq (%rbx), %rdi
callq 0x9e8a
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x6bac
leaq 0x111d7(%rip), %rsi     # 0x25594
movq %r15, %rdi
callq 0x4830
movq (%rbx), %rdi
callq 0x9e54
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq 0x8(%rsp), %rdi
callq 0x4100
leaq 0x8(%rbx), %rdi
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x14409
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x14410
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq 0x28(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
xorl %edx, %edx
callq 0x1c6c6
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x1444a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4460
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x14461
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4460
movl 0xa8(%rbx), %eax
cmpl $0x2, %eax
jl 0x14477
movl %eax, 0xb8(%rbx)
jmp 0x14588
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x9df0
testb %al, %al
je 0x144c4
movq (%rbx), %rdi
callq 0x9ebc
cmpq $0x0, (%rax)
je 0x1454a
movq (%rbx), %rdi
callq 0x9efa
movq 0x8(%rax), %r14
movq (%rbx), %rdi
callq 0x9ebc
cmpq (%rax), %r14
jbe 0x1454a
movl $0x19d, 0xb8(%rbx)      # imm = 0x19D
jmp 0x14588
movl $0x195, 0xb8(%rbx)      # imm = 0x195
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x142c2
leaq 0x58(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1139e(%rip), %rsi     # 0x25889
leaq 0x1139c(%rip), %rdx     # 0x2588e
leaq 0x48(%rsp), %rdi
callq 0x578e
leaq 0x190(%rbx), %rdi
leaq 0x48(%rsp), %rsi
callq 0x104da
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x4560
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x14531
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x4460
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x14588
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4460
jmp 0x14588
movq (%rbx), %rdi
callq 0x9e94
leaq 0x11bbe(%rip), %rsi     # 0x26117
movq %rax, %rdi
callq 0x40f0
testl %eax, %eax
je 0x14571
movq %rbx, %rdi
callq 0x13426
testb %al, %al
je 0x1457e
movq %rbx, %rdi
callq 0x14622
jmp 0x1446c
movl $0x191, 0xb8(%rbx)      # imm = 0x191
movl 0xb8(%rbx), %esi
cmpl $0x12c, %esi            # imm = 0x12C
jl 0x145ae
cmpq $0x0, 0xe8(%rbx)
jne 0x145ae
movq %rbx, %rdi
callq 0x1365c
movl %eax, 0xb8(%rbx)
cmpb $0x0, 0x100(%rbx)
jne 0x145bf
movq %rbx, %rdi
callq 0x15a58
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x14602
movq 0x58(%rsp), %rsi
jmp 0x145f3
jmp 0x145ff
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x14602
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4460
jmp 0x14602
jmp 0x145ff
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x14619
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4460
movq %rbx, %rdi
callq 0x4780
nop