// File: /workspace/github_cpp_makefile_star2_O2/solaldunckel[P]webserv/srcs/HTTP/Response.cpp
// Function: Response::buildErrorPage(int)
int Response::buildErrorPage(int status_code) {
  if (!config_.getErrorPages()[status_code].empty()) {
    std::string target = ft::unique_char(config_.getErrorPages()[status_code]);
    std::string cur_target = ft::unique_char("/" + config_.getTarget());

    if (target != cur_target) {
      config_.getMethod() = "GET";

      redirect_ = true;
      redirect_code_ = status_code;
      redirect_target_ = target;

      return 0;
    }
  }
  body_ += "<html>\r\n";
  body_ += "<head><title>" + ft::to_string(status_code) + " " + g_status[status_code] + "</title></head>\r\n";
  body_ += "<body>\r\n";
  body_ += "<center><h1>" + ft::to_string(status_code) + " " + g_status[status_code] + "</h1></center>\r\n";
  body_ += "<hr><center>" + headers_["Server"] + "</center>\r\n";
  body_ += "</body>\r\n";
  body_ += "</html>\r\n";
  headers_["Content-Type"] = g_mimes.getType(".html");
  headers_["Content-Length"] = ft::to_string(body_.length());
  if (status_code == 401)
    headers_["WWW-Authenticate"] = "Basic realm=\"Access to restricted area\"";
  if (status_code == 408 || status_code == 503)
    headers_["Connection"] = "close";
  if (status_code == 503)
    headers_["Retry-After"] = "30";
  return status_code;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
movq %rdi, %rbx
leaq 0xc(%rsp), %r14
movl %esi, (%r14)
movq (%rdi), %rdi
callq 0x8e30
movq %rax, %rdi
movq %r14, %rsi
callq 0xb1ba
cmpq $0x0, 0x8(%rax)
je 0x10420
movq (%rbx), %rdi
callq 0x8e30
leaq 0xc(%rsp), %rsi
movq %rax, %rdi
callq 0xb1ba
leaq 0xf0(%rsp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x45e0
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x1b4d0
leaq 0xf0(%rsp), %rdi
callq 0x4898
movq (%rbx), %rdi
callq 0x8d9e
leaq 0xc20b(%rip), %rsi      # 0x1c57e
leaq 0xd0(%rsp), %rdi
movq %rax, %rdx
callq 0x52b1
leaq 0x30(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x1b4d0
leaq 0xd0(%rsp), %rdi
callq 0x4898
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x128fa
testb %al, %al
je 0x1040c
movq (%rbx), %rdi
callq 0x8e4e
leaq 0xc376(%rip), %rsi      # 0x1c73a
movq %rax, %rdi
callq 0x4830
movb $0x1, 0x100(%rbx)
movl 0xc(%rsp), %eax
movl %eax, 0x128(%rbx)
addq $0x108, %rbx            # imm = 0x108
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x4240
leaq 0x30(%rsp), %rdi
callq 0x4898
leaq 0x10(%rsp), %rdi
callq 0x4898
xorl %eax, %eax
jmp 0x1080c
leaq 0x30(%rsp), %rdi
callq 0x4898
leaq 0x10(%rsp), %rdi
callq 0x4898
leaq 0xe0(%rbx), %r15
leaq 0xc32a(%rip), %rsi      # 0x1c758
movq %r15, %rdi
callq 0x4820
movl 0xc(%rsp), %esi
leaq 0x90(%rsp), %r14
movq %r14, %rdi
callq 0x6118
leaq 0xc310(%rip), %rsi      # 0x1c761
leaq 0x70(%rsp), %rdi
movq %r14, %rdx
callq 0x8234
leaq 0xc3c1(%rip), %rdx      # 0x1c826
leaq 0x50(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x5292
movl 0xc(%rsp), %esi
leaq 0x1b0b9(%rip), %rdi     # 0x2b538
callq 0x1b1e4
leaq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movq %rax, %rdx
callq 0x5273
leaq 0xc2d2(%rip), %rdx      # 0x1c76f
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x5292
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x4840
leaq 0x10(%rsp), %rdi
callq 0x4898
leaq 0x30(%rsp), %rdi
callq 0x4898
leaq 0x50(%rsp), %rdi
callq 0x4898
leaq 0x70(%rsp), %rdi
callq 0x4898
leaq 0x90(%rsp), %rdi
callq 0x4898
leaq 0xc28c(%rip), %rsi      # 0x1c781
movq %r15, %rdi
callq 0x4820
movl 0xc(%rsp), %esi
leaq 0x90(%rsp), %r14
movq %r14, %rdi
callq 0x6118
leaq 0xc272(%rip), %rsi      # 0x1c78a
leaq 0x70(%rsp), %rdi
movq %r14, %rdx
callq 0x8234
leaq 0xc2fa(%rip), %rdx      # 0x1c826
leaq 0x50(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x5292
movl 0xc(%rsp), %esi
leaq 0x1aff2(%rip), %rdi     # 0x2b538
callq 0x1b1e4
leaq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movq %rax, %rdx
callq 0x5273
leaq 0xc233(%rip), %rdx      # 0x1c797
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x5292
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x4840
leaq 0x10(%rsp), %rdi
callq 0x4898
leaq 0x30(%rsp), %rdi
callq 0x4898
leaq 0x50(%rsp), %rdi
callq 0x4898
leaq 0x70(%rsp), %rdi
callq 0x4898
leaq 0x90(%rsp), %rdi
callq 0x4898
leaq 0xc1f9(%rip), %rsi      # 0x1c7b5
leaq 0x50(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x5328
leaq 0x190(%rbx), %r14
leaq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0xdd56
leaq 0xc1c2(%rip), %rsi      # 0x1c7a8
leaq 0x30(%rsp), %rdi
movq %rax, %rdx
callq 0x52b1
leaq 0xc1a2(%rip), %rdx      # 0x1c79c
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x5292
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x4840
leaq 0x10(%rsp), %rdi
callq 0x4898
leaq 0x30(%rsp), %rdi
callq 0x4898
leaq 0x50(%rsp), %rdi
callq 0x4898
leaq 0xc878(%rip), %rsi      # 0x1ceb3
movq %r15, %rdi
callq 0x4820
leaq 0xc172(%rip), %rsi      # 0x1c7bc
movq %r15, %rdi
callq 0x4820
leaq 0xc16d(%rip), %rsi      # 0x1c7c6
leaq 0xb0(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x5328
leaq 0x1aef6(%rip), %rsi     # 0x2b568
leaq 0x10(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
callq 0x1ab78
leaq 0xbf3f(%rip), %rsi      # 0x1c5ca
leaq 0x30(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x5328
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0xdd56
leaq 0x10(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x4560
leaq 0x30(%rsp), %rdi
callq 0x4898
movq %r15, %rdi
callq 0x4898
leaq 0xb0(%rsp), %rdi
callq 0x4898
movq 0xe8(%rbx), %rsi
leaq 0x10(%rsp), %rdi
callq 0xddbc
leaq 0xbecd(%rip), %rsi      # 0x1c5bb
leaq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x5328
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0xdd56
leaq 0x10(%rsp), %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4560
leaq 0x30(%rsp), %rdi
callq 0x4898
movq %rbx, %rdi
callq 0x4898
movl 0xc(%rsp), %eax
cmpl $0x191, %eax            # imm = 0x191
jne 0x10777
leaq 0xc0b6(%rip), %rsi      # 0x1c7f4
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x5328
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0xdd56
leaq 0xc06b(%rip), %rsi      # 0x1c7cc
movq %rax, %rdi
callq 0x4830
leaq 0x10(%rsp), %rdi
callq 0x4898
movl 0xc(%rsp), %eax
cmpl $0x1f7, %eax            # imm = 0x1F7
je 0x10785
cmpl $0x198, %eax            # imm = 0x198
jne 0x107c5
leaq 0xc07f(%rip), %rsi      # 0x1c80b
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x5328
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0xdd56
leaq 0xc056(%rip), %rsi      # 0x1c805
movq %rax, %rdi
callq 0x4830
leaq 0x10(%rsp), %rdi
callq 0x4898
movl 0xc(%rsp), %eax
cmpl $0x1f7, %eax            # imm = 0x1F7
jne 0x1080c
leaq 0xc046(%rip), %rsi      # 0x1c819
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x5328
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0xdd56
leaq 0xc020(%rip), %rsi      # 0x1c816
movq %rax, %rdi
callq 0x4830
leaq 0x10(%rsp), %rdi
callq 0x4898
movl 0xc(%rsp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r14
popq %r15
retq
jmp 0x108b2
jmp 0x108b2
jmp 0x108b2
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
jmp 0x108fc
movq %rax, %rbx
movq %r15, %r14
jmp 0x10906
jmp 0x108ea
jmp 0x108ea
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4898
jmp 0x108ed
jmp 0x108ea
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4898
jmp 0x10876
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4898
jmp 0x10885
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
jmp 0x10936
jmp 0x108b2
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4898
jmp 0x108a6
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4898
jmp 0x1090e
movq %rax, %rbx
jmp 0x1093b
jmp 0x108c2
jmp 0x108d1
jmp 0x108e0
jmp 0x108e5
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4898
jmp 0x108d4
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4898
jmp 0x1091a
movq %rax, %rbx
jmp 0x10924
movq %rax, %rbx
jmp 0x1092e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
jmp 0x10936
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4898
jmp 0x10906
movq %rax, %rbx
movq %r14, %rdi
jmp 0x10936
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
jmp 0x10936
jmp 0x10917
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4898
leaq 0x70(%rsp), %rdi
callq 0x4898
leaq 0x90(%rsp), %rdi
callq 0x4898
movq %rbx, %rdi
callq 0x4750
nop