// File: kztomita[P]http-dump/httpv1.cc
// Function: httpv1::get(boost::asio::ip::address const&, unsigned short, http_scheme, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::list<std::unique_ptr<http_header, std::default_delete<http_header>>, std::allocator<std::unique_ptr<http_header, std::default_delete<http_header>>>> const&)
http_response httpv1::get(const boost::asio::ip::address& ip, uint16_t port, http_scheme scheme, const std::string& host, const std::string& path, const http_header_list& headers) {
  std::unique_ptr<sync_stream_wrapper> socket = create_socket(scheme);

  socket->set_host(host);
  socket->connect(ip, port);

  std::ostringstream request_stream;
  request_stream << "GET " << path << " HTTP/1.1\r\n"
                 << "Host: " << host << "\r\n";
                 //<< "Connection: Close\r\n"
  for (const auto& h : headers) {
    request_stream << h->key << ": " << h->value << "\r\n";
  }
  request_stream << "\r\n";

  debug_message("Sending Request");
  debug_message(request_stream.str());
  asio::write(*socket, asio::buffer(request_stream.str()));

  return read_response(*socket);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rdi, -0x268(%rbp)
movw %cx, %ax
movq %rdi, %rcx
movq %rcx, -0x260(%rbp)
movq 0x18(%rbp), %rcx
movq 0x10(%rbp), %rcx
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movw %ax, -0x1a(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movl -0x20(%rbp), %esi
leaq -0x30(%rbp), %rdi
movq %rdi, -0x258(%rbp)
xorl %edx, %edx
callq 0x4ecc0
movq -0x258(%rbp), %rdi
callq 0x4ed40
movq %rax, %rdi
movq -0x28(%rbp), %rsi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
jmp 0x4e881
leaq -0x30(%rbp), %rdi
callq 0x4ed40
movq %rax, %rdi
movq -0x18(%rbp), %rsi
movzwl -0x1a(%rbp), %edx
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
jmp 0x4e8a0
leaq -0x1b8(%rbp), %rdi
callq 0xdd60
jmp 0x4e8ae
leaq 0x2683e(%rip), %rsi     # 0x750f3
leaq -0x1b8(%rbp), %rdi
callq 0xd860
movq %rax, -0x270(%rbp)
jmp 0x4e8ca
movq -0x270(%rbp), %rdi
movq 0x10(%rbp), %rsi
callq 0xd480
movq %rax, -0x278(%rbp)
jmp 0x4e8e3
movq -0x278(%rbp), %rdi
leaq 0x26807(%rip), %rsi     # 0x750f8
callq 0xd860
movq %rax, -0x280(%rbp)
jmp 0x4e8ff
movq -0x280(%rbp), %rdi
leaq 0x267f7(%rip), %rsi     # 0x75104
callq 0xd860
movq %rax, -0x288(%rbp)
jmp 0x4e91b
movq -0x288(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xd480
movq %rax, -0x290(%rbp)
jmp 0x4e934
movq -0x290(%rbp), %rdi
leaq 0x26b45(%rip), %rsi     # 0x75487
callq 0xd860
jmp 0x4e949
movq 0x18(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movq -0x1c0(%rbp), %rdi
callq 0x4ed60
movq %rax, -0x1c8(%rbp)
movq -0x1c0(%rbp), %rdi
callq 0x4ed90
movq %rax, -0x1d0(%rbp)
leaq -0x1c8(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x4edc0
testb $0x1, %al
jne 0x4e996
jmp 0x4ea5b
leaq -0x1c8(%rbp), %rdi
callq 0x4edf0
movq %rax, -0x1d8(%rbp)
movq -0x1d8(%rbp), %rdi
callq 0x4ee20
movq %rax, %rsi
leaq -0x1b8(%rbp), %rdi
callq 0xd480
movq %rax, -0x298(%rbp)
jmp 0x4e9cd
movq -0x298(%rbp), %rdi
leaq 0x26ec6(%rip), %rsi     # 0x758a1
callq 0xd860
movq %rax, -0x2a0(%rbp)
jmp 0x4e9e9
movq -0x1d8(%rbp), %rdi
callq 0x4ee20
movq -0x2a0(%rbp), %rdi
movq %rax, %rsi
addq $0x20, %rsi
callq 0xd480
movq %rax, -0x2a8(%rbp)
jmp 0x4ea11
movq -0x2a8(%rbp), %rdi
leaq 0x26a68(%rip), %rsi     # 0x75487
callq 0xd860
jmp 0x4ea26
jmp 0x4ea28
leaq -0x1c8(%rbp), %rdi
callq 0x4ee40
jmp 0x4e97a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4ec18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4ec0c
leaq 0x26a25(%rip), %rsi     # 0x75487
leaq -0x1b8(%rbp), %rdi
callq 0xd860
jmp 0x4ea70
leaq -0x1f9(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0xddb0
movq -0x2b0(%rbp), %rdx
leaq 0x2667a(%rip), %rsi     # 0x7510b
leaq -0x1f8(%rbp), %rdi
callq 0x10a30
jmp 0x4ea9f
leaq -0x1f8(%rbp), %rdi
callq 0x4ee60
jmp 0x4eaad
leaq -0x1f8(%rbp), %rdi
callq 0xdac0
leaq -0x1f9(%rbp), %rdi
callq 0xe180
leaq -0x220(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0xe0c0
jmp 0x4eada
leaq -0x220(%rbp), %rdi
callq 0x4ee60
jmp 0x4eae8
leaq -0x220(%rbp), %rdi
callq 0xdac0
leaq -0x30(%rbp), %rdi
callq 0x4ef10
movq %rax, -0x2b8(%rbp)
jmp 0x4eb06
leaq -0x250(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0xe0c0
jmp 0x4eb1b
leaq -0x250(%rbp), %rdi
callq 0x4ef40
movq -0x2b8(%rbp), %rdi
movq %rax, -0x230(%rbp)
movq %rdx, -0x228(%rbp)
xorl %eax, %eax
movl %eax, %edx
leaq -0x230(%rbp), %rsi
callq 0x4eea0
jmp 0x4eb4e
leaq -0x250(%rbp), %rdi
callq 0xdac0
leaq -0x30(%rbp), %rdi
callq 0x4ef10
movq %rax, -0x2c0(%rbp)
jmp 0x4eb6c
movq -0x2c0(%rbp), %rsi
movq -0x268(%rbp), %rdi
callq 0x4ef80
jmp 0x4eb81
leaq -0x1b8(%rbp), %rdi
callq 0xdcb0
leaq -0x30(%rbp), %rdi
callq 0x4faa0
movq -0x260(%rbp), %rax
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4ebcc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0xdac0
leaq -0x1f9(%rbp), %rdi
callq 0xe180
jmp 0x4ec0c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x220(%rbp), %rdi
callq 0xdac0
jmp 0x4ec0c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x250(%rbp), %rdi
callq 0xdac0
leaq -0x1b8(%rbp), %rdi
callq 0xdcb0
leaq -0x30(%rbp), %rdi
callq 0x4faa0
movq -0x38(%rbp), %rdi
callq 0xd990
nopw (%rax,%rax)