// File: /workspace/github_cpp_makefile_star2_O2/solaldunckel[P]webserv/srcs/HTTP/Client.cpp
// Function: Client::setupResponse(std::vector<ServerConfig, std::allocator<ServerConfig>>&, InputArgs&, int)
void Client::setupResponse(std::vector<ServerConfig> &servers, InputArgs &options, int error_code) {
  if (!request_)
    request_ = getRequest(true);

  if (!config_)
    setupConfig(servers, options);

  response_ = new Response(*config_, worker_id_, error_code);

  int loop = 0;

  for (int ret = 1; ret != 0; loop++) {
    ret = 0;

    response_->build();

    if (response_->redirect()) {
      ret = 1;
      config_->redirectLocation(response_->redirect_target());
      Log.print(INFO, "INTERNAL REDIRECT : [target: " + response_->redirect_target() + "]");
      response_->clear();
    }
    if (loop >= 10) {
      ft::delete_(response_);
      response_ = new Response(*config_, worker_id_, 500);
      response_->build();
      break ;
    }
  }

  ft::delete_(request_);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
cmpq $0x0, 0x38(%rdi)
jne 0xe13a
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xe350
movq %rax, 0x38(%rbx)
movq 0x40(%rbx), %r12
testq %r12, %r12
jne 0xe155
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xe0a6
movq 0x40(%rbx), %r12
movl $0x1c0, %edi            # imm = 0x1C0
callq 0x4460
movq %rax, %r14
movl 0x30(%rbx), %edx
movq %rax, %rdi
movq %r12, %rsi
movl %ebp, %ecx
callq 0xf724
leaq 0x38(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x48(%rbx), %r15
movq %rbx, 0x8(%rsp)
movq %r14, 0x48(%rbx)
pushq $0x1
popq %r13
pushq $0xb
popq %r14
leaq 0x78(%rsp), %r12
leaq 0x58(%rsp), %rbp
testl %r13d, %r13d
je 0xe2d1
movq (%r15), %rdi
callq 0x109e0
movq (%r15), %rdi
callq 0x123f8
xorl %r13d, %r13d
testb %al, %al
je 0xe28f
movq %r15, %rbx
movq %r12, %r15
movq 0x8(%rsp), %rax
movq 0x40(%rax), %r13
movq 0x48(%rax), %rsi
leaq 0x98(%rsp), %r12
movq %r12, %rdi
callq 0x12400
movq %r13, %rdi
movq %r12, %rsi
callq 0x8c2c
movq %r12, %rdi
callq 0x4898
movq (%rbx), %rsi
movq %r15, %r12
movq %r15, %rdi
callq 0x12400
leaq 0x18(%rsp), %r15
movq %r15, %rdi
leaq 0xe4e2(%rip), %rsi      # 0x1c6f3
movq %r12, %rdx
callq 0x8234
leaq 0x38(%rsp), %rdi
movq %r15, %rsi
leaq 0xe119(%rip), %rdx      # 0x1c341
callq 0x5292
pushq $0x1
popq %r13
movq %rbp, %rdi
leaq 0xdddf(%rip), %rsi      # 0x1c01a
leaq 0x7(%rsp), %rdx
callq 0x5328
movq %rbx, %r15
leaq 0x1d299(%rip), %rdi     # 0x2b4e8
movl %r13d, %esi
leaq 0x38(%rsp), %rbx
movq %rbx, %rdx
movq %rbp, %rcx
xorl %r8d, %r8d
callq 0x18e1e
movq %rbp, %rdi
callq 0x4898
movq %rbx, %rdi
callq 0x4898
leaq 0x18(%rsp), %rdi
callq 0x4898
movq %r12, %rdi
callq 0x4898
movq (%r15), %rdi
callq 0xfaa2
decl %r14d
jne 0xe19a
movq %r15, %rdi
callq 0xe483
movl $0x1c0, %edi            # imm = 0x1C0
callq 0x4460
movq %rax, %r14
movq 0x8(%rsp), %rax
movq 0x40(%rax), %rsi
movl 0x30(%rax), %edx
movq %r14, %rdi
movl $0x1f4, %ecx            # imm = 0x1F4
callq 0xf724
movq %r14, (%r15)
movq %r14, %rdi
callq 0x109e0
movq 0x10(%rsp), %rdi
callq 0xe425
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xe2ef
movq %rax, %rbx
movl $0x1c0, %esi            # imm = 0x1C0
movq %r14, %rdi
callq 0x4490
jmp 0xe348
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x4898
jmp 0xe313
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x4898
jmp 0xe322
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x4898
jmp 0xe331
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
jmp 0xe343
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x4898
movq %rbx, %rdi
callq 0x4750