// File: solaldunckel[P]webserv/srcs/HTTP/Response.cpp
// Function: Response::createResponse()
void Response::createResponse() {
  headers_["Server"] = "webserv/1.0";

  if (config_.getMethod() == "HEAD")
    body_.clear();

  if (status_code_ < 400 && redirect_code_)
    status_code_ = redirect_code_;

  std::string status_code;

  if (headers_.count("Status")) {
    status_code = headers_["Status"];
    headers_.erase("Status");
  }
  else
    status_code = ft::to_string(status_code_) + " " + g_status[status_code_];

  response_ = response_ + config_.getProtocol() + " " + status_code + "\r\n";

  headers_["Date"] = ft::get_http_date();

  for (std::map<std::string, std::string>::iterator it = headers_.begin(); it != headers_.end(); it++)
    response_ += it->first + ": " + it->second + "\r\n";

  response_ += "\r\n";

  header_size_ = response_.size();

  if (!body_.empty()) {
    body_size_ = body_.size();
    response_ += body_;
    body_.clear();
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x320, %rsp            # imm = 0x320
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x290(%rbp)
addq $0x190, %rax            # imm = 0x190
movq %rax, -0x288(%rbp)
leaq -0x29(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x5960
movq -0x280(%rbp), %rdx
leaq 0x1ba7d(%rip), %rsi     # 0x437f2
leaq -0x28(%rbp), %rdi
callq 0x6be0
jmp 0x27d80
movq -0x288(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x20e30
movq %rax, -0x298(%rbp)
jmp 0x27d99
movq -0x298(%rbp), %rdi
leaq 0x1bb03(%rip), %rsi     # 0x438aa
callq 0x5780
jmp 0x27dae
leaq -0x28(%rbp), %rdi
callq 0x5aa8
leaq -0x29(%rbp), %rdi
callq 0x55e0
movq -0x290(%rbp), %rax
movq (%rax), %rdi
callq 0x13030
movq %rax, %rdi
leaq 0x1b9a2(%rip), %rsi     # 0x4377b
callq 0x8ff0
testb $0x1, %al
jne 0x27de4
jmp 0x27e2a
movq -0x290(%rbp), %rdi
addq $0xe0, %rdi
callq 0x5740
jmp 0x27e2a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x27e1c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x5aa8
leaq -0x29(%rbp), %rdi
callq 0x55e0
jmp 0x285b5
movq -0x290(%rbp), %rax
cmpl $0x190, 0xb8(%rax)      # imm = 0x190
jge 0x27e60
movq -0x290(%rbp), %rax
cmpl $0x0, 0x128(%rax)
je 0x27e60
movq -0x290(%rbp), %rax
movl 0x128(%rax), %ecx
movl %ecx, 0xb8(%rax)
leaq -0x60(%rbp), %rdi
callq 0x57b0
movq -0x290(%rbp), %rax
addq $0x190, %rax            # imm = 0x190
movq %rax, -0x2a8(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x5960
movq -0x2a0(%rbp), %rdx
leaq 0x1ba18(%rip), %rsi     # 0x438b6
leaq -0x80(%rbp), %rdi
callq 0x6be0
jmp 0x27ea9
movq -0x2a8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x20dd0
movq %rax, -0x2b0(%rbp)
jmp 0x27ec2
leaq -0x80(%rbp), %rdi
callq 0x5aa8
leaq -0x81(%rbp), %rdi
callq 0x55e0
movq -0x2b0(%rbp), %rax
cmpq $0x0, %rax
je 0x28088
movq -0x290(%rbp), %rax
addq $0x190, %rax            # imm = 0x190
movq %rax, -0x2c0(%rbp)
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
callq 0x5960
movq -0x2b8(%rbp), %rdx
leaq 0x1b999(%rip), %rsi     # 0x438b6
leaq -0xa8(%rbp), %rdi
callq 0x6be0
jmp 0x27f2b
movq -0x2c0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x20e30
movq %rax, -0x2c8(%rbp)
jmp 0x27f47
movq -0x2c8(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x5050
jmp 0x27f59
leaq -0xa8(%rbp), %rdi
callq 0x5aa8
leaq -0xa9(%rbp), %rdi
callq 0x55e0
movq -0x290(%rbp), %rax
addq $0x190, %rax            # imm = 0x190
movq %rax, -0x2d8(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x2d0(%rbp)
callq 0x5960
movq -0x2d0(%rbp), %rdx
leaq 0x1b910(%rip), %rsi     # 0x438b6
leaq -0xd0(%rbp), %rdi
callq 0x6be0
jmp 0x27fb4
movq -0x2d8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x2a060
jmp 0x27fc9
leaq -0xd0(%rbp), %rdi
callq 0x5aa8
leaq -0xd1(%rbp), %rdi
callq 0x55e0
jmp 0x2817b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x28009
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x5aa8
leaq -0x81(%rbp), %rdi
callq 0x55e0
jmp 0x285ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x28040
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x5aa8
leaq -0xa9(%rbp), %rdi
callq 0x55e0
jmp 0x285ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x28077
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x5aa8
leaq -0xd1(%rbp), %rdi
callq 0x55e0
jmp 0x285ac
movq -0x290(%rbp), %rax
movl 0xb8(%rax), %esi
leaq -0x138(%rbp), %rdi
callq 0x9070
jmp 0x280a3
leaq 0x1b7b9(%rip), %rdx     # 0x43863
leaq -0x118(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x6a80
jmp 0x280bf
movq -0x290(%rbp), %rax
movl 0xb8(%rax), %esi
leaq 0x34575(%rip), %rdi     # 0x5c648
callq 0x40e10
movq %rax, -0x2e0(%rbp)
jmp 0x280e1
movq -0x2e0(%rbp), %rdx
leaq -0xf8(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x6a30
jmp 0x280fd
leaq -0x60(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x56d0
leaq -0xf8(%rbp), %rdi
callq 0x5aa8
leaq -0x118(%rbp), %rdi
callq 0x5aa8
leaq -0x138(%rbp), %rdi
callq 0x5aa8
jmp 0x2817b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x285ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x2816a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x5aa8
leaq -0x138(%rbp), %rdi
callq 0x5aa8
jmp 0x285ac
movq -0x290(%rbp), %rax
movq %rax, %rcx
addq $0xc0, %rcx
movq %rcx, -0x2f0(%rbp)
movq (%rax), %rdi
callq 0x130a0
movq %rax, -0x2e8(%rbp)
jmp 0x281a4
movq -0x2e8(%rbp), %rdx
movq -0x2f0(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x2a090
jmp 0x281c0
leaq 0x1b69c(%rip), %rdx     # 0x43863
leaq -0x198(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x6a80
jmp 0x281dc
leaq -0x178(%rbp), %rdi
leaq -0x198(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x6a30
jmp 0x281f5
leaq 0x1b5bf(%rip), %rdx     # 0x437bb
leaq -0x158(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x6a80
jmp 0x28211
movq -0x290(%rbp), %rdi
addq $0xc0, %rdi
leaq -0x158(%rbp), %rsi
movq %rsi, -0x2f8(%rbp)
callq 0x56d0
movq -0x2f8(%rbp), %rdi
callq 0x5aa8
leaq -0x178(%rbp), %rdi
callq 0x5aa8
leaq -0x198(%rbp), %rdi
callq 0x5aa8
leaq -0x1b8(%rbp), %rdi
callq 0x5aa8
leaq -0x1d8(%rbp), %rdi
callq 0x42320
jmp 0x28270
movq -0x290(%rbp), %rax
addq $0x190, %rax            # imm = 0x190
movq %rax, -0x308(%rbp)
leaq -0x1f9(%rbp), %rdi
movq %rdi, -0x300(%rbp)
callq 0x5960
movq -0x300(%rbp), %rdx
leaq 0x1b618(%rip), %rsi     # 0x438bd
leaq -0x1f8(%rbp), %rdi
callq 0x6be0
jmp 0x282b3
movq -0x308(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x20e30
movq %rax, -0x310(%rbp)
jmp 0x282cf
movq -0x310(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x56d0
leaq -0x1f8(%rbp), %rdi
callq 0x5aa8
leaq -0x1f9(%rbp), %rdi
callq 0x55e0
leaq -0x1d8(%rbp), %rdi
callq 0x5aa8
movq -0x290(%rbp), %rdi
addq $0x190, %rdi            # imm = 0x190
callq 0x210e0
movq %rax, -0x208(%rbp)
movq -0x290(%rbp), %rdi
addq $0x190, %rdi            # imm = 0x190
callq 0x1dc40
movq %rax, -0x210(%rbp)
leaq -0x208(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x13de0
testb $0x1, %al
jne 0x28356
jmp 0x284fd
leaq -0x208(%rbp), %rdi
callq 0x13e40
movq %rax, %rsi
leaq 0x1b6be(%rip), %rdx     # 0x43a2a
leaq -0x270(%rbp), %rdi
callq 0x8f70
jmp 0x2837a
leaq -0x208(%rbp), %rdi
callq 0x13e40
movq %rax, %rdx
addq $0x20, %rdx
leaq -0x250(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x6a30
jmp 0x283a2
leaq 0x1b412(%rip), %rdx     # 0x437bb
leaq -0x230(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x6a80
jmp 0x283be
movq -0x290(%rbp), %rdi
addq $0xc0, %rdi
leaq -0x230(%rbp), %rsi
callq 0x5710
jmp 0x283da
leaq -0x230(%rbp), %rdi
callq 0x5aa8
leaq -0x250(%rbp), %rdi
callq 0x5aa8
leaq -0x270(%rbp), %rdi
callq 0x5aa8
leaq -0x208(%rbp), %rdi
xorl %esi, %esi
callq 0x13e60
movq %rax, -0x278(%rbp)
jmp 0x28320
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x28458
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x2844c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x5aa8
leaq -0x198(%rbp), %rdi
callq 0x5aa8
leaq -0x1b8(%rbp), %rdi
callq 0x5aa8
jmp 0x285ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x2848f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x5aa8
leaq -0x1f9(%rbp), %rdi
callq 0x55e0
leaq -0x1d8(%rbp), %rdi
callq 0x5aa8
jmp 0x285ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x284ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x284e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x5aa8
leaq -0x250(%rbp), %rdi
callq 0x5aa8
leaq -0x270(%rbp), %rdi
callq 0x5aa8
jmp 0x285ac
movq -0x290(%rbp), %rdi
addq $0xc0, %rdi
leaq 0x1b2a9(%rip), %rsi     # 0x437bb
callq 0x5520
jmp 0x28519
movq -0x290(%rbp), %rdi
addq $0xc0, %rdi
callq 0x5380
movq -0x290(%rbp), %rdi
movq %rax, 0x130(%rdi)
addq $0xe0, %rdi
callq 0x5900
testb $0x1, %al
jne 0x2859a
movq -0x290(%rbp), %rdi
addq $0xe0, %rdi
movq %rdi, -0x318(%rbp)
callq 0x5380
movq -0x290(%rbp), %rdi
movq -0x318(%rbp), %rsi
movq %rax, 0x138(%rdi)
addq $0xc0, %rdi
callq 0x5710
jmp 0x28587
movq -0x290(%rbp), %rdi
addq $0xe0, %rdi
callq 0x5740
leaq -0x60(%rbp), %rdi
callq 0x5aa8
addq $0x320, %rsp            # imm = 0x320
popq %rbp
retq
leaq -0x60(%rbp), %rdi
callq 0x5aa8
movq -0x38(%rbp), %rdi
callq 0x5950
nop