// File: king1600[P]cordpp/src/http.cc
// Function: cordpp::RestClient::to_string[abi:cxx11](cordpp::Request const&)
const std::string RestClient::to_string(const Request &req) {
  std::ostringstream output;

  // add method and endpoint
  output << req.method << " " << base_endpoint << req.endpoint << " HTTP/1.1\r\n";

  // add default headers
  output << "Accept: */*\r\n";
  //output << "Accept-Encoding: gzip\r\n";
  output << "Connection: keep-alive\r\n";
  output << "Host: " << base_host << ":443\r\n";
  output << "Authorization: Bot " << token << "\r\n";
  output << "User-Agent: DiscordBot (" << lib << ", " << version << ")\r\n";

  // add variable headers
  if (!req.audit_reason.empty())
    output << "X-Audit-Log-Reason: " << req.audit_reason << CLRF;
  if (!cookies.empty()) {
    output << "Cookie: ";
    for (const std::string &cookie : cookies)
      output << cookie << "; ";
    output << CLRF;
  }

  // add conditional body headers & create content
  if (!req.body.empty() && req.body.is_object()) {
    std::string content = req.body.dump();
    //output << "Content-Encoding: gzip\r\n";
    output << "Content-Type: application/json; charset=UTF-8\r\n";
    output << "Content-Length: " << std::to_string(content.size()) << CLRF;
    output << CLRF << content;
  } else output << CLRF;

  // return built http request
  return output.str();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2b0, %rsp            # imm = 0x2B0
movq %rdi, -0x228(%rbp)
movq %rdi, %rax
movq %rax, -0x220(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x218(%rbp)
leaq -0x190(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0xcc30
movq -0x210(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x10, %rsi
callq 0xc460
movq %rax, -0x208(%rbp)
jmp 0x4f683
movq -0x208(%rbp), %rdi
leaq 0x44901(%rip), %rsi     # 0x93f92
callq 0xc7e0
movq %rax, -0x230(%rbp)
jmp 0x4f69f
movq -0x230(%rbp), %rdi
leaq 0x8d8b3(%rip), %rsi     # 0xdcf60
callq 0xc460
movq %rax, -0x238(%rbp)
jmp 0x4f6bb
movq -0x238(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x30, %rsi
callq 0xc460
movq %rax, -0x240(%rbp)
jmp 0x4f6d8
movq -0x240(%rbp), %rdi
leaq 0x45868(%rip), %rsi     # 0x94f4e
callq 0xc7e0
jmp 0x4f6ed
leaq 0x4483b(%rip), %rsi     # 0x93f2f
leaq -0x190(%rbp), %rdi
callq 0xc7e0
jmp 0x4f702
leaq 0x44834(%rip), %rsi     # 0x93f3d
leaq -0x190(%rbp), %rdi
callq 0xc7e0
jmp 0x4f717
leaq 0x44838(%rip), %rsi     # 0x93f56
leaq -0x190(%rbp), %rdi
callq 0xc7e0
movq %rax, -0x248(%rbp)
jmp 0x4f733
movq -0x248(%rbp), %rdi
leaq 0x8d7ff(%rip), %rsi     # 0xdcf40
callq 0xc460
movq %rax, -0x250(%rbp)
jmp 0x4f74f
movq -0x250(%rbp), %rdi
leaq 0x44800(%rip), %rsi     # 0x93f5d
callq 0xc7e0
jmp 0x4f764
leaq 0x447f9(%rip), %rsi     # 0x93f64
leaq -0x190(%rbp), %rdi
callq 0xc7e0
movq %rax, -0x258(%rbp)
jmp 0x4f780
movq -0x258(%rbp), %rdi
movq -0x218(%rbp), %rsi
addq $0x8, %rsi
callq 0xc460
movq %rax, -0x260(%rbp)
jmp 0x4f7a0
movq -0x260(%rbp), %rdi
leaq 0x44aa0(%rip), %rsi     # 0x9424e
callq 0xc7e0
jmp 0x4f7b5
leaq 0x447bc(%rip), %rsi     # 0x93f78
leaq -0x190(%rbp), %rdi
callq 0xc7e0
movq %rax, -0x268(%rbp)
jmp 0x4f7d1
movq -0x268(%rbp), %rdi
leaq 0x8d6e1(%rip), %rsi     # 0xdcec0
callq 0xc460
movq %rax, -0x270(%rbp)
jmp 0x4f7ed
movq -0x270(%rbp), %rdi
leaq 0x44796(%rip), %rsi     # 0x93f91
callq 0xc7e0
movq %rax, -0x278(%rbp)
jmp 0x4f809
movq -0x278(%rbp), %rdi
leaq 0x8d6e9(%rip), %rsi     # 0xdcf00
callq 0xc460
movq %rax, -0x280(%rbp)
jmp 0x4f825
movq -0x280(%rbp), %rdi
leaq 0x44761(%rip), %rsi     # 0x93f94
callq 0xc7e0
jmp 0x4f83a
movq -0x18(%rbp), %rdi
addq $0x50, %rdi
callq 0xc410
testb $0x1, %al
jne 0x4f8b2
leaq 0x44746(%rip), %rsi     # 0x93f98
leaq -0x190(%rbp), %rdi
callq 0xc7e0
movq %rax, -0x288(%rbp)
jmp 0x4f867
movq -0x288(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x50, %rsi
callq 0xc460
movq %rax, -0x290(%rbp)
jmp 0x4f884
movq -0x290(%rbp), %rdi
leaq 0x8d70e(%rip), %rsi     # 0xdcfa0
callq 0xc460
jmp 0x4f899
jmp 0x4f8b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x4fb34
movq -0x218(%rbp), %rdi
addq $0x130, %rdi            # imm = 0x130
callq 0x54610
testb $0x1, %al
jne 0x4f9a0
leaq 0x446d9(%rip), %rsi     # 0x93fad
leaq -0x190(%rbp), %rdi
callq 0xc7e0
jmp 0x4f8e2
movq -0x218(%rbp), %rax
addq $0x130, %rax            # imm = 0x130
movq %rax, -0x1a8(%rbp)
movq -0x1a8(%rbp), %rdi
callq 0x54650
movq %rax, -0x1b0(%rbp)
movq -0x1a8(%rbp), %rdi
callq 0x54680
movq %rax, -0x1b8(%rbp)
leaq -0x1b0(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x546b0
testb $0x1, %al
jne 0x4f935
jmp 0x4f989
leaq -0x1b0(%rbp), %rdi
callq 0x546f0
movq %rax, -0x1c0(%rbp)
movq -0x1c0(%rbp), %rsi
leaq -0x190(%rbp), %rdi
callq 0xc460
movq %rax, -0x298(%rbp)
jmp 0x4f964
movq -0x298(%rbp), %rdi
leaq 0x44644(%rip), %rsi     # 0x93fb6
callq 0xc7e0
jmp 0x4f979
jmp 0x4f97b
leaq -0x1b0(%rbp), %rdi
callq 0x54710
jmp 0x4f91c
leaq 0x8d610(%rip), %rsi     # 0xdcfa0
leaq -0x190(%rbp), %rdi
callq 0xc460
jmp 0x4f99e
jmp 0x4f9a0
movq -0x18(%rbp), %rdi
callq 0x54730
testb $0x1, %al
jne 0x4faec
movq -0x18(%rbp), %rdi
callq 0x1f720
testb $0x1, %al
jne 0x4f9c3
jmp 0x4faec
movq -0x18(%rbp), %rsi
leaq -0x1e0(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x20, %ecx
xorl %r8d, %r8d
callq 0x29440
jmp 0x4f9e2
leaq 0x445d0(%rip), %rsi     # 0x93fb9
leaq -0x190(%rbp), %rdi
callq 0xc7e0
jmp 0x4f9f7
leaq 0x445eb(%rip), %rsi     # 0x93fe9
leaq -0x190(%rbp), %rdi
callq 0xc7e0
movq %rax, -0x2a0(%rbp)
jmp 0x4fa13
leaq -0x1e0(%rbp), %rdi
callq 0xc420
movq %rax, %rsi
leaq -0x200(%rbp), %rdi
callq 0x4a320
jmp 0x4fa30
movq -0x2a0(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0xc460
movq %rax, -0x2a8(%rbp)
jmp 0x4fa4c
movq -0x2a8(%rbp), %rdi
leaq 0x8d546(%rip), %rsi     # 0xdcfa0
callq 0xc460
jmp 0x4fa61
leaq -0x200(%rbp), %rdi
callq 0xcfb8
leaq 0x8d52c(%rip), %rsi     # 0xdcfa0
leaq -0x190(%rbp), %rdi
callq 0xc460
movq %rax, -0x2b0(%rbp)
jmp 0x4fa89
movq -0x2b0(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0xc460
jmp 0x4fa9e
leaq -0x1e0(%rbp), %rdi
callq 0xcfb8
jmp 0x4fb03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x4fade
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x200(%rbp), %rdi
callq 0xcfb8
leaq -0x1e0(%rbp), %rdi
callq 0xcfb8
jmp 0x4fb34
leaq 0x8d4ad(%rip), %rsi     # 0xdcfa0
leaq -0x190(%rbp), %rdi
callq 0xc460
jmp 0x4fb01
jmp 0x4fb03
movq -0x228(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0xcee0
jmp 0x4fb18
leaq -0x190(%rbp), %rdi
callq 0xcb60
movq -0x220(%rbp), %rax
addq $0x2b0, %rsp            # imm = 0x2B0
popq %rbp
retq
leaq -0x190(%rbp), %rdi
callq 0xcb60
movq -0x198(%rbp), %rdi
callq 0xc8c0
nopl (%rax)