// File: /workspace/github_cpp_makefile_star2_O2/alfanick[P]rest-cpp/src/rest/response.cpp
// Function: REST::Response::send()
size_t Response::send() {
  if (is_streamed)
    return 0;

  size_t bytes_sent = 0;

  std::string payload;

  if (!data.empty()) {
    headers["Content-Type"] = "application/json; charset=utf-8";
    payload = data.dump();
  } else {
    payload = raw;
  }

  // start http
  std::string content = "HTTP/1.1 " + std::to_string(status) + " " + status_message + "\r\n";

  // content size
  headers["Server"] += ", took " + std::to_string(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - start_time).count() / 1000.0f) + "ms";
  headers.emplace("Content-Length", std::to_string(payload.size()));
  headers.emplace("Date", Utils::rfc1123_datetime(time(0)));

  // add headers
  for (auto header : headers)
    content += header.first + ": " + header.second + "\r\n";

  content += "\r\n";

  content += payload;

  // send every byte
  bytes_sent = ::send(handle, content.c_str(), content.size(), MSG_DONTWAIT | MSG_NOSIGNAL);

  // close connection with client
  close(handle);

  return bytes_sent;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
cmpb $0x0, 0x9c(%rdi)
je 0x47323
xorl %ebx, %ebx
jmp 0x476a9
leaq 0xe8(%rsp), %rax
leaq 0x78(%rdi), %rbx
movq %rdi, %r15
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movq %rbx, %rdi
movb $0x0, (%rax)
callq 0x31f40
testb %al, %al
je 0x4735d
leaq 0x28(%r15), %rsi
leaq 0xd8(%rsp), %rdi
callq 0x30e50
jmp 0x473ca
leaq 0x2de2(%rip), %rsi      # 0x4a146
leaq 0x10(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
callq 0x30a10
leaq 0x48(%r15), %rdi
leaq 0x10(%rsp), %rsi
callq 0x33820
leaq 0x5562(%rip), %rsi      # 0x4c8ed
movq %rax, %rdi
callq 0x33930
leaq 0x10(%rsp), %rdi
callq 0x33b38
leaq 0x10(%rsp), %rdi
pushq $-0x1
popq %rdx
movq %rbx, %rsi
callq 0x323a0
leaq 0x10(%rsp), %rbx
leaq 0xd8(%rsp), %rdi
movq %rbx, %rsi
callq 0x32380
movq %rbx, %rdi
callq 0x33b38
movl (%r15), %esi
leaq 0x50(%rsp), %rdi
callq 0x325e0
leaq 0x54fa(%rip), %rsi      # 0x4c8d8
leaq 0x70(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x332a0
leaq 0x3bb0(%rip), %rdx      # 0x4afa4
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x30490
leaq 0x8(%r15), %rdx
leaq 0x10(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x32c70
leaq 0x54bf(%rip), %rdx      # 0x4c8e2
leaq 0xb0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x30490
leaq 0x10(%rsp), %rdi
callq 0x33b38
leaq 0x90(%rsp), %rdi
callq 0x33b38
leaq 0x70(%rsp), %rdi
callq 0x33b38
leaq 0x50(%rsp), %rdi
callq 0x33b38
callq 0x30130
subq 0x88(%r15), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
vcvtsi2ss %rax, %xmm0, %xmm0
vdivss 0x53c9(%rip), %xmm0, %xmm0 # 0x4c84c
leaq 0x70(%rsp), %rdi
callq 0x30f50
leaq 0x5479(%rip), %rsi      # 0x4c90d
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x332a0
leaq 0x5468(%rip), %rdx      # 0x4c915
leaq 0x10(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x30490
leaq 0x50b7(%rip), %rsi      # 0x4c57d
leaq 0x50(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x30a10
leaq 0x48(%r15), %r14
leaq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x33820
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x33a00
leaq 0x50(%rsp), %rdi
callq 0x33b38
leaq 0x10(%rsp), %rdi
callq 0x33b38
leaq 0x90(%rsp), %rdi
callq 0x33b38
leaq 0x70(%rsp), %rdi
callq 0x33b38
movq 0xe0(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x308e0
leaq 0x2c00(%rip), %rsi      # 0x4a137
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x30cf0
leaq 0x10(%rsp), %rdi
callq 0x33b38
xorl %edi, %edi
callq 0x31b20
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x31bb0
leaq 0x537c(%rip), %rsi      # 0x4c8e5
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x30b40
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x33b38
movq 0x60(%r15), %r13
movq %r15, 0xd0(%rsp)
addq $0x50, %r15
leaq 0x50(%rsp), %rbp
leaq 0x70(%rsp), %rbx
leaq 0x90(%rsp), %r12
cmpq %r15, %r13
je 0x4762e
leaq 0x20(%r13), %rsi
movq %r14, %rdi
callq 0x318b0
leaq 0x5329(%rip), %rdx      # 0x4c8ea
movq %rbp, %rdi
movq %r14, %rsi
callq 0x324e0
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x32c70
leaq 0x52ff(%rip), %rdx      # 0x4c8e2
movq %r12, %rdi
movq %rbx, %rsi
callq 0x30490
leaq 0xb0(%rsp), %rdi
movq %r12, %rsi
callq 0x33a00
movq %r12, %rdi
callq 0x33b38
movq %rbx, %rdi
callq 0x33b38
movq %rbp, %rdi
callq 0x33b38
movq %r14, %rdi
callq 0x30390
movq %r13, %rdi
callq 0x31360
movq %rax, %r13
jmp 0x475a5
leaq 0x52ad(%rip), %rsi      # 0x4c8e2
leaq 0xb0(%rsp), %rdi
callq 0x33910
movq 0xd0(%rsp), %r14
leaq 0xb0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x33a00
movq 0xb8(%rsp), %rdx
movl 0x98(%r14), %edi
movq 0xb0(%rsp), %rsi
movl $0x4040, %ecx           # imm = 0x4040
callq 0x30cc0
movl 0x98(%r14), %edi
movq %rax, %rbx
callq 0x33a20
leaq 0xb0(%rsp), %rdi
callq 0x33b38
leaq 0xd8(%rsp), %rdi
callq 0x33b38
movq %rbx, %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4772e
jmp 0x4772e
jmp 0x4772e
jmp 0x476cb
jmp 0x477b1
leaq 0x10(%rsp), %rdi
movq %rax, %rbx
jmp 0x47769
jmp 0x477b1
movq %rax, %rbx
jmp 0x4774d
movq %rax, %rbx
jmp 0x47757
movq %rax, %rbx
jmp 0x47764
jmp 0x477b1
leaq 0x10(%rsp), %rdi
movq %rax, %rbx
callq 0x33b38
jmp 0x47703
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x33b38
jmp 0x47715
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x33b38
jmp 0x47724
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
jmp 0x477bc
movq %rax, %rbx
jmp 0x477c1
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
jmp 0x477bc
leaq 0x50(%rsp), %rdi
movq %rax, %rbx
callq 0x33b38
leaq 0x10(%rsp), %rdi
callq 0x33b38
leaq 0x90(%rsp), %rdi
callq 0x33b38
leaq 0x70(%rsp), %rdi
callq 0x33b38
jmp 0x477b4
jmp 0x477b1
movq %rax, %rbx
jmp 0x477a5
movq %rax, %rbx
jmp 0x4779b
movq %rax, %rbx
jmp 0x47791
leaq 0x90(%rsp), %rdi
movq %rax, %rbx
callq 0x33b38
leaq 0x70(%rsp), %rdi
callq 0x33b38
leaq 0x50(%rsp), %rdi
callq 0x33b38
leaq 0x10(%rsp), %rdi
callq 0x30390
jmp 0x477b4
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x33b38
leaq 0xd8(%rsp), %rdi
callq 0x33b38
movq %rbx, %rdi
callq 0x33510