// File: /workspace/github_cpp_makefile_star2_O2/kztomita[P]http-dump/./http2_socket.h
// Function: http2_frame read_http2_frame<boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::execution::any_executor<boost::asio::execution::context_as_t<boost::asio::execution_context&>, boost::asio::execution::detail::blocking::never_t<0>, boost::asio::execution::prefer_only<boost::asio::execution::detail::blocking::possibly_t<0>>, boost::asio::execution::prefer_only<boost::asio::execution::detail::outstanding_work::tracked_t<0>>, boost::asio::execution::prefer_only<boost::asio::execution::detail::outstanding_work::untracked_t<0>>, boost::asio::execution::prefer_only<boost::asio::execution::detail::relationship::fork_t<0>>, boost::asio::execution::prefer_only<boost::asio::execution::detail::relationship::continuation_t<0>>>>>>(boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::execution::any_executor<boost::asio::execution::context_as_t<boost::asio::execution_context&>, boost::asio::execution::detail::blocking::never_t<0>, boost::asio::execution::prefer_only<boost::asio::execution::detail::blocking::possibly_t<0>>, boost::asio::execution::prefer_only<boost::asio::execution::detail::outstanding_work::tracked_t<0>>, boost::asio::execution::prefer_only<boost::asio::execution::detail::outstanding_work::untracked_t<0>>, boost::asio::execution::prefer_only<boost::asio::execution::detail::relationship::fork_t<0>>, boost::asio::execution::prefer_only<boost::asio::execution::detail::relationship::continuation_t<0>>>>>&)
http2_frame read_http2_frame(SyncReadStream& socket) {
  namespace asio = boost::asio;

  asio::streambuf receive_buffer;

  asio::read(socket, receive_buffer, boost::asio::transfer_exactly(9));

  const char* headerp = asio::buffer_cast<const char*>(receive_buffer.data());

  http2_frame frame;

  std::memcpy(&frame.header(), headerp, 9);
  receive_buffer.consume(9);

  uint payload_size = frame.header().length();

  if (payload_size) {
    frame.payload().resize(payload_size);

    asio::read(socket, receive_buffer, boost::asio::transfer_exactly(payload_size));

    const char* payloadp = asio::buffer_cast<const char*>(receive_buffer.data());
    std::memcpy(frame.payload_buffer(), payloadp, payload_size);
  }

  debug_message("RECV");
  debug_dump(frame);

  return frame;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x28(%rsp), %r14
pushq $-0x1
popq %rsi
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
callq 0x1fb5e
pushq $0x9
popq %r12
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x2300d
movq 0x38(%rsp), %rax
movq 0x50(%rsp), %rdx
movq %rdx, %rcx
subq %rax, %rcx
andq $0x0, 0x20(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movb 0x8(%rax), %sil
movb %sil, 0x8(%rbx)
movq (%rax), %rsi
movq %rsi, (%rbx)
cmpq %rdx, 0x40(%rsp)
jae 0x21c26
movq 0x70(%rsp), %rsi
movq %rsi, 0x30(%rsp)
movq %rdx, 0x40(%rsp)
leaq 0x9(%rax), %rsi
cmpq %rdx, %rsi
movslq %ecx, %rcx
cmovaq %rcx, %r12
leaq 0x10(%rbx), %r14
addq %rax, %r12
movq %r12, 0x38(%rsp)
movzwl (%rbx), %eax
movzbl 0x2(%rbx), %r12d
shll $0x10, %r12d
orl %eax, %r12d
testl %r12d, %r12d
je 0x21c86
bswapl %r12d
shrl $0x8, %r12d
movq %r14, %rdi
movq %r12, %rsi
callq 0x1ff78
leaq 0x28(%rsp), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x2300d
movq 0x38(%rsp), %rsi
movq (%r14), %rdi
movq %r12, %rdx
callq 0xb520
leaq 0xb7e4(%rip), %rsi      # 0x2d471
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0xd416
leaq 0x8(%rsp), %rdi
callq 0x1e6a7
leaq 0x8(%rsp), %rdi
callq 0xb2f0
movq %rbx, %rdi
callq 0x22fcb
leaq 0x28(%rsp), %rdi
callq 0x1ffa4
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xb2f0
jmp 0x21ced
jmp 0x21cea
movq %rax, %rbx
jmp 0x21cf5
movq %rax, %rbx
movq %r14, %rdi
callq 0xf41c
leaq 0x28(%rsp), %rdi
callq 0x1ffa4
movq %rbx, %rdi
callq 0xbba0