// File: kztomita[P]http-dump/./http2_socket.h
// Function: void send_http2_goaway<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>>>>>&, unsigned int)
void send_http2_goaway(SyncWriteStream& stream, uint32_t stream_id) {
  http2_frame goaway;

  auto& header = goaway.header();
  header.set_length(8);
  header.type = http2_frame_header::TYPE_GOAWAY;
  header.flags = 0x00;
  header.set_stream_id(0);

  auto& payload = goaway.payload();
  payload.resize(8);
  uint32_t value;
  value = htonl(stream_id);   // Last Stream Id
  std::memcpy(&payload[0], &value, 4);
  value = htonl(0);           // Error Code
  std::memcpy(&payload[4], &value, 4);

  write_http2_frame(stream, goaway);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0x68(%rbp)
callq 0x5c510
movq -0x68(%rbp), %rdi
callq 0x5c530
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movl $0x8, %esi
callq 0x5c6c0
jmp 0x5a8b9
movq -0x40(%rbp), %rax
movb $0x7, 0x3(%rax)
movq -0x40(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x5c540
jmp 0x5a8d6
leaq -0x38(%rbp), %rdi
callq 0x5a440
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
movl $0x8, %esi
callq 0x53770
jmp 0x5a8f3
movl -0xc(%rbp), %edi
callq 0xda40
movl %eax, -0x5c(%rbp)
movq -0x58(%rbp), %rdi
xorl %eax, %eax
movl %eax, -0x6c(%rbp)
movl %eax, %esi
callq 0x5a460
movl -0x6c(%rbp), %edi
movl -0x5c(%rbp), %ecx
movl %ecx, (%rax)
callq 0xda40
movl %eax, -0x5c(%rbp)
movq -0x58(%rbp), %rdi
movl $0x4, %esi
callq 0x5a460
movl -0x5c(%rbp), %ecx
movl %ecx, (%rax)
movq -0x8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x5c770
jmp 0x5a940
leaq -0x38(%rbp), %rdi
callq 0x59c40
addq $0x70, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x59c40
movq -0x48(%rbp), %rdi
callq 0xd990
nopl (%rax)