// File: /workspace/github_cpp_makefile_star2_O3/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 0x9f5a
movq %rax, %r14
movq (%rbx), %rdi
callq 0x9ee0
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 0x6c2a
leaq 0x1112d(%rip), %rsi     # 0x25594
movq %r15, %rdi
callq 0x4840
movq (%rbx), %rdi
callq 0x9eaa
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 0x144b3
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x144ba
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 0x1c752
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x144f4
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x1450b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
movl 0xa8(%rbx), %esi
cmpl $0x2, %esi
jl 0x14521
movl %esi, 0xb8(%rbx)
jmp 0x14647
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x9e46
testb %al, %al
je 0x14573
movq (%rbx), %rdi
callq 0x9f12
cmpq $0x0, (%rax)
je 0x145ff
movq (%rbx), %rdi
callq 0x9f50
movq 0x8(%rax), %r14
movq (%rbx), %rdi
callq 0x9f12
cmpq (%rax), %r14
jbe 0x145ff
movl $0x19d, 0xb8(%rbx)      # imm = 0x19D
movl $0x19d, %esi            # imm = 0x19D
jmp 0x14647
movl $0x195, 0xb8(%rbx)      # imm = 0x195
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x1436c
leaq 0x58(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x112ef(%rip), %rsi     # 0x25889
leaq 0x112ed(%rip), %rdx     # 0x2588e
leaq 0x48(%rsp), %rdi
callq 0x579e
leaq 0x190(%rbx), %rdi
leaq 0x48(%rsp), %rsi
callq 0x105ca
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x4570
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x145e0
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x145f7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
movl 0xb8(%rbx), %esi
jmp 0x14647
movq (%rbx), %rdi
callq 0x9eea
leaq 0x11b09(%rip), %rsi     # 0x26117
movq %rax, %rdi
callq 0x40f0
testl %eax, %eax
je 0x14626
movq %rbx, %rdi
callq 0x134c8
testb %al, %al
je 0x14638
movq %rbx, %rdi
callq 0x146da
movl %eax, %esi
movl %eax, 0xb8(%rbx)
jmp 0x14647
movl $0x191, 0xb8(%rbx)      # imm = 0x191
movl $0x191, %esi            # imm = 0x191
cmpl $0x12c, %esi            # imm = 0x12C
jl 0x14667
cmpq $0x0, 0xe8(%rbx)
jne 0x14667
movq %rbx, %rdi
callq 0x13706
movl %eax, 0xb8(%rbx)
cmpb $0x0, 0x100(%rbx)
jne 0x14678
movq %rbx, %rdi
callq 0x15aee
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x146bb
movq 0x58(%rsp), %rsi
jmp 0x146ac
jmp 0x146b8
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x146bb
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x146bb
jmp 0x146b8
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x146d2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4790