// File: kztomita[P]http-dump/httpv2.cc
// Function: httpv2::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 httpv2::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& req_headers) {
  if (scheme != http_scheme::https) {
    throw std::invalid_argument("http scheme not supported on http/2.");
  }

  ssl_stream ssl_stream_wrapper(g_verify_cert, true);
  ssl_stream_wrapper.set_host(host);
  ssl_stream_wrapper.connect(ip, port);

  asio::ssl::stream<asio::ip::tcp::socket>& stream = ssl_stream_wrapper.inner_stream();

  const unsigned char* alpn_data = nullptr;
  unsigned int alpn_len = 0;
  SSL_get0_alpn_selected(stream.native_handle(), &alpn_data, &alpn_len);
  if (alpn_len == 0) {
    throw std::runtime_error("http/2 is not selected.");
  }
  if (std::string_view(reinterpret_cast<const char*>(alpn_data), alpn_len) != "h2") {
    throw std::runtime_error("http/2 is not selected.");
  }

  std::ostringstream request_stream;
  request_stream << "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n";
  asio::write(stream, asio::buffer(request_stream.str()));

  // SETTINGS送信
#if 1
  send_http2_settings(stream);
#else
  // パラメータを指定する場合
  std::vector<settings_parameter> params{
    {SETTINGS_MAX_CONCURRENT_STREAMS, 10},
    {SETTINGS_MAX_FRAME_SIZE, 16384},
  };
  send_http2_settings(stream, params);
#endif

  // SETTINGS受信
  bool rcv_settings = false;
  bool rcv_settings_ack = false;
  while (!rcv_settings || !rcv_settings_ack) {
    auto frame = read_http2_frame(stream);
    if (frame.type() == http2_frame_header::TYPE_SETTINGS) {
      if (frame.flags() & HTTP2_SETTINGS_ACK_FLAG) {
        rcv_settings_ack = true;
      } else {
        rcv_settings = true;
        // SETTINGS ACK送信
        send_http2_settings_ack(stream);
      }
    }
  }

  uint32_t stream_id = 1;

  // HEADERS送信
  send_http2_headers(stream, stream_id, host, path, req_headers);

  // HEADERS受信
  // Header Block FragmentからHeader Blockを構築
  http2_frame::payload_type header_block;
  auto headers_frame = read_http2_frame(stream);
  if (headers_frame.type() != http2_frame_header::TYPE_HEADERS) {
    throw std::runtime_error("The frame which isn't a HEADERS frame was received.");
  }
  std::size_t fragment_offset = 0;
  std::size_t pad_length = 0;
  if (headers_frame.flags() & HTTP2_HEADERS_PADDED_FLAG) {
    pad_length = headers_frame.payload()[fragment_offset];
    fragment_offset += 1;
  }
  if (headers_frame.flags() & HTTP2_HEADERS_PRIORITY_FLAG) {
    fragment_offset += 5;
  }
  header_block.insert(header_block.end(),
                      headers_frame.payload().begin() + fragment_offset,
                      headers_frame.payload().end() - pad_length);

  if (!(headers_frame.flags() & HTTP2_HEADERS_END_HEADERS_FLAG)) {
    // CONTINUATIONが続く
    while (true) {
      auto continuation_frame = read_http2_frame(stream);
      if (continuation_frame.type() != http2_frame_header::TYPE_CONTINUATION) {
        throw std::runtime_error("The frame which isn't a CONTINUATION frame was received.");
      }

      header_block.insert(header_block.end(),
                          continuation_frame.payload().begin(),
                          continuation_frame.payload().end());

      if (continuation_frame.flags() & HTTP2_CONTINUATION_END_HEADERS_FLAG) {
        break;
      }
    }
  }

  hpack::hpack_decoder decoder(&header_block[0], header_block.size());
  hpack::decoding_context context;
  auto header_list = decoder.decode(context);

  debug_message("HPACK Dynamic Table");
  debug_dump(*context.dynamic_table);
  debug_message("");

  debug_message("HPACK Decoded header list");
  for (const auto& h : header_list) {
    debug_message(h.first + " " + h.second);
  }
  debug_message("");

  // DATA受信
  http_response::payload_type response_body;

  while (true) {
    auto data_frame = read_http2_frame(stream);
    if (data_frame.type() != http2_frame_header::TYPE_DATA) {
      throw std::runtime_error("The frame which isn't a DATA frame was received.");
    }
    if (data_frame.flags() & HTTP2_DATA_PADDED_FLAG) {
      throw std::runtime_error("padding flag not supported.");
    }
    response_body.insert(response_body.end(), data_frame.payload().begin(), data_frame.payload().end());
    if (data_frame.flags() & HTTP2_DATA_END_STREAM_FLAG) {
      break;
    }

    // WINDOW UPDATE送信
    send_http2_window_update(stream, stream_id, data_frame.length());
    send_http2_window_update(stream, 0, data_frame.length());         // connection level
  }

  // GOAWAY送信
  send_http2_goaway(stream, stream_id);

  http_response r;

  auto status_header = std::find_if(header_list.begin(), header_list.end(),
                                    [] (const hpack::header_type& h) {
                                      return h.first == ":status";
                                    });
  if (status_header != header_list.end()) {
    r.code_ = std::stoi(status_header->second);
  } else {
    std::runtime_error("status header not found.");
  }

  for (const auto& h : header_list) {
    if (h.first == ":status") {
      continue;
    }
    r.headers_.push_back(std::make_unique<http_header>(convert_header_name(h.first), h.second));
  }

  swap(r.payload_, response_body);

  return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x730, %rsp            # imm = 0x730
movq %rdi, -0x5c8(%rbp)
movw %cx, %ax
movq %rdi, %rcx
movq %rcx, -0x5c0(%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)
cmpl $0x1, -0x20(%rbp)
je 0x57fb1
movl $0x10, %edi
callq 0xd580
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x5d0(%rbp)
leaq 0x1d4c1(%rip), %rsi     # 0x75434
callq 0xd2e0
jmp 0x57f7a
movq -0x5d0(%rbp), %rdi
movq 0x54fa0(%rip), %rsi     # 0xacf28
movq 0x54f91(%rip), %rdx     # 0xacf20
callq 0xd970
movq -0x5d0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0xdc70
jmp 0x591df
movzbl 0x55990(%rip), %esi     # 0xad948
andl $0x1, %esi
leaq -0x98(%rbp), %rdi
movq %rdi, -0x5d8(%rbp)
movl $0x1, %edx
callq 0x67270
movq -0x5d8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x675a0
jmp 0x57fe5
movq -0x18(%rbp), %rsi
movzwl -0x1a(%rbp), %edx
leaq -0x98(%rbp), %rdi
callq 0x675d0
jmp 0x57ffb
leaq -0x98(%rbp), %rdi
callq 0x67800
movq %rax, -0x5e0(%rbp)
jmp 0x58010
movq -0x5e0(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq $0x0, -0xa8(%rbp)
movl $0x0, -0xac(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x596c0
movq %rax, -0x5e8(%rbp)
jmp 0x58048
movq -0x5e8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
leaq -0xac(%rbp), %rdx
callq 0xdc50
jmp 0x58064
cmpl $0x0, -0xac(%rbp)
jne 0x580df
movl $0x10, %edi
callq 0xd580
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x5f0(%rbp)
leaq 0x1d3ce(%rip), %rsi     # 0x75459
callq 0xd3b0
jmp 0x58092
movq -0x5f0(%rbp), %rdi
movq 0x54ef0(%rip), %rsi     # 0xacf90
movq 0x54eb9(%rip), %rdx     # 0xacf60
callq 0xd970
jmp 0x591e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x591d3
movq -0x5f0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0xdc70
jmp 0x591d3
movq -0xa8(%rbp), %rsi
movl -0xac(%rbp), %eax
movl %eax, %edx
leaq -0xc0(%rbp), %rdi
callq 0x4df10
leaq -0xd0(%rbp), %rdi
leaq 0x1dca3(%rip), %rsi     # 0x75dab
callq 0x10e50
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movq -0xd0(%rbp), %rdx
movq -0xc8(%rbp), %rcx
callq 0x596e0
testb $0x1, %al
jne 0x58134
jmp 0x58195
movl $0x10, %edi
callq 0xd580
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x5f8(%rbp)
leaq 0x1d307(%rip), %rsi     # 0x75459
callq 0xd3b0
jmp 0x58159
movq -0x5f8(%rbp), %rdi
movq 0x54e29(%rip), %rsi     # 0xacf90
movq 0x54df2(%rip), %rdx     # 0xacf60
callq 0xd970
jmp 0x591e8
movq -0x5f8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0xdc70
jmp 0x591d3
leaq -0x248(%rbp), %rdi
callq 0xdd60
jmp 0x581a3
leaq 0x1d2c7(%rip), %rsi     # 0x75471
leaq -0x248(%rbp), %rdi
callq 0xd860
jmp 0x581b8
movq -0xa0(%rbp), %rax
movq %rax, -0x600(%rbp)
leaq -0x278(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0xe0c0
jmp 0x581db
leaq -0x278(%rbp), %rdi
callq 0x4ef40
movq -0x600(%rbp), %rdi
movq %rax, -0x258(%rbp)
movq %rdx, -0x250(%rbp)
xorl %eax, %eax
movl %eax, %edx
leaq -0x258(%rbp), %rsi
callq 0x59740
jmp 0x5820e
leaq -0x278(%rbp), %rdi
callq 0xdac0
movq -0xa0(%rbp), %rdi
callq 0x597b0
jmp 0x58228
movb $0x0, -0x279(%rbp)
movb $0x0, -0x27a(%rbp)
movb $0x1, %al
testb $0x1, -0x279(%rbp)
movb %al, -0x601(%rbp)
je 0x58255
movb -0x27a(%rbp), %al
xorb $-0x1, %al
movb %al, -0x601(%rbp)
movb -0x601(%rbp), %al
testb $0x1, %al
jne 0x58264
jmp 0x5833c
movq -0xa0(%rbp), %rsi
leaq -0x2a8(%rbp), %rdi
callq 0x59820
jmp 0x58279
leaq -0x2a8(%rbp), %rdi
callq 0x59b60
movl %eax, -0x608(%rbp)
jmp 0x5828d
movl -0x608(%rbp), %eax
cmpl $0x4, %eax
jne 0x5832b
leaq -0x2a8(%rbp), %rdi
callq 0x59b80
movl %eax, -0x60c(%rbp)
jmp 0x582b0
movl -0x60c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x58312
movb $0x1, -0x27a(%rbp)
jmp 0x58329
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x591c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x278(%rbp), %rdi
callq 0xdac0
jmp 0x591c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0x59c40
jmp 0x591c7
movb $0x1, -0x279(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x59ba0
jmp 0x58327
jmp 0x58329
jmp 0x5832b
leaq -0x2a8(%rbp), %rdi
callq 0x59c40
jmp 0x58236
movl $0x1, -0x2ac(%rbp)
movq -0xa0(%rbp), %rdi
movl -0x2ac(%rbp), %esi
movq -0x28(%rbp), %rdx
movq 0x10(%rbp), %rcx
movq 0x18(%rbp), %r8
movl $0x4000, %r9d           # imm = 0x4000
callq 0x59c60
jmp 0x5836c
leaq -0x2c8(%rbp), %rdi
callq 0x53750
movq -0xa0(%rbp), %rsi
leaq -0x2f0(%rbp), %rdi
callq 0x59820
jmp 0x5838d
leaq -0x2f0(%rbp), %rdi
callq 0x59b60
movl %eax, -0x610(%rbp)
jmp 0x583a1
movl -0x610(%rbp), %eax
cmpl $0x1, %eax
je 0x58433
movl $0x10, %edi
callq 0xd580
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x618(%rbp)
leaq 0x1d0bc(%rip), %rsi     # 0x7548a
callq 0xd3b0
jmp 0x583d5
movq -0x618(%rbp), %rdi
movq 0x54bad(%rip), %rsi     # 0xacf90
movq 0x54b76(%rip), %rdx     # 0xacf60
callq 0xd970
jmp 0x591e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x591bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x591af
movq -0x618(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0xdc70
jmp 0x591af
movq $0x0, -0x2f8(%rbp)
movq $0x0, -0x300(%rbp)
leaq -0x2f0(%rbp), %rdi
callq 0x59b80
movl %eax, -0x61c(%rbp)
jmp 0x5845d
movl -0x61c(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x584af
leaq -0x2f0(%rbp), %rdi
callq 0x5a440
movq %rax, -0x628(%rbp)
jmp 0x58480
movq -0x628(%rbp), %rdi
movq -0x2f8(%rbp), %rsi
callq 0x5a460
movzbl (%rax), %eax
movq %rax, -0x300(%rbp)
movq -0x2f8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2f8(%rbp)
leaq -0x2f0(%rbp), %rdi
callq 0x59b80
movl %eax, -0x62c(%rbp)
jmp 0x584c3
movl -0x62c(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x584e3
movq -0x2f8(%rbp), %rax
addq $0x5, %rax
movq %rax, -0x2f8(%rbp)
leaq -0x2c8(%rbp), %rdi
callq 0x53850
movq %rax, -0x310(%rbp)
leaq -0x308(%rbp), %rdi
leaq -0x310(%rbp), %rsi
callq 0x5a530
leaq -0x2f0(%rbp), %rdi
callq 0x5a440
movq %rax, -0x638(%rbp)
jmp 0x5851e
movq -0x638(%rbp), %rdi
callq 0x5a570
movq %rax, -0x320(%rbp)
movq -0x2f8(%rbp), %rsi
leaq -0x320(%rbp), %rdi
callq 0x57db0
movq %rax, -0x318(%rbp)
leaq -0x2f0(%rbp), %rdi
callq 0x5a440
movq %rax, -0x640(%rbp)
jmp 0x58560
movq -0x640(%rbp), %rdi
callq 0x53850
movq %rax, -0x330(%rbp)
movq -0x300(%rbp), %rsi
leaq -0x330(%rbp), %rdi
callq 0x53880
movq %rax, -0x328(%rbp)
movq -0x308(%rbp), %rsi
movq -0x318(%rbp), %rdx
movq -0x328(%rbp), %rcx
leaq -0x2c8(%rbp), %rdi
callq 0x5a480
movq %rax, -0x648(%rbp)
jmp 0x585b7
movq -0x648(%rbp), %rax
movq %rax, -0x338(%rbp)
leaq -0x2f0(%rbp), %rdi
callq 0x59b80
movl %eax, -0x64c(%rbp)
jmp 0x585d9
movl -0x64c(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x587ad
jmp 0x585ed
jmp 0x585ef
movq -0xa0(%rbp), %rsi
leaq -0x360(%rbp), %rdi
callq 0x59820
jmp 0x58604
leaq -0x360(%rbp), %rdi
callq 0x59b60
movl %eax, -0x650(%rbp)
jmp 0x58618
movl -0x650(%rbp), %eax
cmpl $0x9, %eax
je 0x58695
movl $0x10, %edi
callq 0xd580
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x658(%rbp)
leaq 0x1ce7d(%rip), %rsi     # 0x754be
callq 0xd3b0
jmp 0x58648
movq -0x658(%rbp), %rdi
movq 0x5493a(%rip), %rsi     # 0xacf90
movq 0x54903(%rip), %rdx     # 0xacf60
callq 0xd970
jmp 0x591e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x5879a
movq -0x658(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0xdc70
jmp 0x5879a
leaq -0x2c8(%rbp), %rdi
callq 0x53850
movq %rax, -0x370(%rbp)
leaq -0x368(%rbp), %rdi
leaq -0x370(%rbp), %rsi
callq 0x5a530
leaq -0x360(%rbp), %rdi
callq 0x5a440
movq %rax, -0x660(%rbp)
jmp 0x586d0
movq -0x660(%rbp), %rdi
callq 0x5a570
movq %rax, -0x378(%rbp)
leaq -0x360(%rbp), %rdi
callq 0x5a440
movq %rax, -0x668(%rbp)
jmp 0x586f8
movq -0x668(%rbp), %rdi
callq 0x53850
movq %rax, -0x380(%rbp)
movq -0x368(%rbp), %rsi
movq -0x378(%rbp), %rdx
movq -0x380(%rbp), %rcx
leaq -0x2c8(%rbp), %rdi
callq 0x5a480
movq %rax, -0x670(%rbp)
jmp 0x58735
movq -0x670(%rbp), %rax
movq %rax, -0x388(%rbp)
leaq -0x360(%rbp), %rdi
callq 0x59b80
movl %eax, -0x674(%rbp)
jmp 0x58757
movl -0x674(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x58771
movl $0x5, -0x38c(%rbp)
jmp 0x5877b
movl $0x0, -0x38c(%rbp)
leaq -0x360(%rbp), %rdi
callq 0x59c40
movl -0x38c(%rbp), %eax
testl %eax, %eax
je 0x58795
jmp 0x58793
jmp 0x587ab
jmp 0x585ed
leaq -0x360(%rbp), %rdi
callq 0x59c40
jmp 0x591af
jmp 0x587ad
xorl %eax, %eax
movl %eax, %esi
leaq -0x2c8(%rbp), %rdi
movq %rdi, -0x688(%rbp)
callq 0x5a460
movq -0x688(%rbp), %rdi
movq %rax, -0x680(%rbp)
callq 0x4e6b0
movq -0x680(%rbp), %rsi
movq %rax, %rdx
leaq -0x3a8(%rbp), %rdi
callq 0x62050
jmp 0x587ef
leaq -0x3b0(%rbp), %rdi
callq 0x62010
jmp 0x587fd
leaq -0x3c8(%rbp), %rdi
leaq -0x3a8(%rbp), %rsi
leaq -0x3b0(%rbp), %rdx
callq 0x62080
jmp 0x58819
leaq -0x3e9(%rbp), %rdi
movq %rdi, -0x690(%rbp)
callq 0xddb0
movq -0x690(%rbp), %rdx
leaq 0x1ccbd(%rip), %rsi     # 0x754f7
leaq -0x3e8(%rbp), %rdi
callq 0x10a30
jmp 0x58848
leaq -0x3e8(%rbp), %rdi
callq 0x4ee60
jmp 0x58856
leaq -0x3e8(%rbp), %rdi
callq 0xdac0
leaq -0x3e9(%rbp), %rdi
callq 0xe180
leaq -0x3b0(%rbp), %rdi
callq 0x5a5d0
movq %rax, -0x698(%rbp)
jmp 0x58883
movq -0x698(%rbp), %rdi
callq 0x5a5a0
jmp 0x58891
leaq -0x411(%rbp), %rdi
movq %rdi, -0x6a0(%rbp)
callq 0xddb0
movq -0x6a0(%rbp), %rdx
leaq 0x1cbd7(%rip), %rsi     # 0x75489
leaq -0x410(%rbp), %rdi
callq 0x10a30
jmp 0x588c0
leaq -0x410(%rbp), %rdi
callq 0x4ee60
jmp 0x588ce
leaq -0x410(%rbp), %rdi
callq 0xdac0
leaq -0x411(%rbp), %rdi
callq 0xe180
leaq -0x439(%rbp), %rdi
movq %rdi, -0x6a8(%rbp)
callq 0xddb0
movq -0x6a8(%rbp), %rdx
leaq 0x1cc04(%rip), %rsi     # 0x7550b
leaq -0x438(%rbp), %rdi
callq 0x10a30
jmp 0x58915
leaq -0x438(%rbp), %rdi
callq 0x4ee60
jmp 0x58923
leaq -0x438(%rbp), %rdi
callq 0xdac0
leaq -0x439(%rbp), %rdi
callq 0xe180
leaq -0x3c8(%rbp), %rax
movq %rax, -0x448(%rbp)
movq -0x448(%rbp), %rdi
callq 0x3ff60
movq %rax, -0x450(%rbp)
movq -0x448(%rbp), %rdi
callq 0x3fd60
movq %rax, -0x458(%rbp)
leaq -0x450(%rbp), %rdi
leaq -0x458(%rbp), %rsi
callq 0x5a600
testb $0x1, %al
jne 0x5898b
jmp 0x58b0f
leaq -0x450(%rbp), %rdi
callq 0x40290
movq %rax, -0x460(%rbp)
movq -0x460(%rbp), %rsi
leaq 0x1cef6(%rip), %rdx     # 0x758a2
leaq -0x4a0(%rbp), %rdi
callq 0x5a690
jmp 0x589ba
movq -0x460(%rbp), %rdx
addq $0x20, %rdx
leaq -0x480(%rbp), %rdi
leaq -0x4a0(%rbp), %rsi
callq 0x5a640
jmp 0x589da
leaq -0x480(%rbp), %rdi
callq 0x4ee60
jmp 0x589e8
leaq -0x480(%rbp), %rdi
callq 0xdac0
leaq -0x4a0(%rbp), %rdi
callq 0xdac0
leaq -0x450(%rbp), %rdi
callq 0x5a710
jmp 0x5896f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x591a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x58a48
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x3e8(%rbp), %rdi
callq 0xdac0
leaq -0x3e9(%rbp), %rdi
callq 0xe180
jmp 0x59197
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x59197
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x58a90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x410(%rbp), %rdi
callq 0xdac0
leaq -0x411(%rbp), %rdi
callq 0xe180
jmp 0x59197
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x58ac7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x438(%rbp), %rdi
callq 0xdac0
leaq -0x439(%rbp), %rdi
callq 0xe180
jmp 0x59197
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x58afe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x480(%rbp), %rdi
callq 0xdac0
leaq -0x4a0(%rbp), %rdi
callq 0xdac0
jmp 0x59197
leaq -0x4c1(%rbp), %rdi
movq %rdi, -0x6b0(%rbp)
callq 0xddb0
movq -0x6b0(%rbp), %rdx
leaq 0x1c959(%rip), %rsi     # 0x75489
leaq -0x4c0(%rbp), %rdi
callq 0x10a30
jmp 0x58b3e
leaq -0x4c0(%rbp), %rdi
callq 0x4ee60
jmp 0x58b4c
leaq -0x4c0(%rbp), %rdi
callq 0xdac0
leaq -0x4c1(%rbp), %rdi
callq 0xe180
leaq -0x4e0(%rbp), %rdi
callq 0x53750
jmp 0x58b72
movq -0xa0(%rbp), %rsi
leaq -0x508(%rbp), %rdi
callq 0x59820
jmp 0x58b87
leaq -0x508(%rbp), %rdi
callq 0x59b60
movl %eax, -0x6b4(%rbp)
jmp 0x58b9b
movl -0x6b4(%rbp), %eax
cmpl $0x0, %eax
je 0x58c64
movl $0x10, %edi
callq 0xd580
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x6c0(%rbp)
leaq 0x1c95d(%rip), %rsi     # 0x75525
callq 0xd3b0
jmp 0x58bcf
movq -0x6c0(%rbp), %rdi
movq 0x543b3(%rip), %rsi     # 0xacf90
movq 0x5437c(%rip), %rdx     # 0xacf60
callq 0xd970
jmp 0x591e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x58c14
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x4c0(%rbp), %rdi
callq 0xdac0
leaq -0x4c1(%rbp), %rdi
callq 0xe180
jmp 0x59197
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x5918b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x58e6f
movq -0x6c0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0xdc70
jmp 0x58e6f
leaq -0x508(%rbp), %rdi
callq 0x59b80
movl %eax, -0x6c4(%rbp)
jmp 0x58c78
movl -0x6c4(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x58ce7
movl $0x10, %edi
callq 0xd580
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x6d0(%rbp)
leaq 0x1c8b2(%rip), %rsi     # 0x75556
callq 0xd3b0
jmp 0x58cab
movq -0x6d0(%rbp), %rdi
movq 0x542d7(%rip), %rsi     # 0xacf90
movq 0x542a0(%rip), %rdx     # 0xacf60
callq 0xd970
jmp 0x591e8
movq -0x6d0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0xdc70
jmp 0x58e6f
leaq -0x4e0(%rbp), %rdi
callq 0x53850
movq %rax, -0x518(%rbp)
leaq -0x510(%rbp), %rdi
leaq -0x518(%rbp), %rsi
callq 0x5a530
leaq -0x508(%rbp), %rdi
callq 0x5a440
movq %rax, -0x6d8(%rbp)
jmp 0x58d22
movq -0x6d8(%rbp), %rdi
callq 0x5a570
movq %rax, -0x520(%rbp)
leaq -0x508(%rbp), %rdi
callq 0x5a440
movq %rax, -0x6e0(%rbp)
jmp 0x58d4a
movq -0x6e0(%rbp), %rdi
callq 0x53850
movq %rax, -0x528(%rbp)
movq -0x510(%rbp), %rsi
movq -0x520(%rbp), %rdx
movq -0x528(%rbp), %rcx
leaq -0x4e0(%rbp), %rdi
callq 0x5a480
movq %rax, -0x6e8(%rbp)
jmp 0x58d87
movq -0x6e8(%rbp), %rax
movq %rax, -0x530(%rbp)
leaq -0x508(%rbp), %rdi
callq 0x59b80
movl %eax, -0x6ec(%rbp)
jmp 0x58da9
movl -0x6ec(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x58dc6
movl $0x9, -0x38c(%rbp)
jmp 0x58e50
movq -0xa0(%rbp), %rax
movq %rax, -0x700(%rbp)
movl -0x2ac(%rbp), %eax
movl %eax, -0x6f4(%rbp)
leaq -0x508(%rbp), %rdi
callq 0x5a860
movl %eax, -0x6f0(%rbp)
jmp 0x58df4
movl -0x6f0(%rbp), %edx
movl -0x6f4(%rbp), %esi
movq -0x700(%rbp), %rdi
callq 0x5a730
jmp 0x58e0e
movq -0xa0(%rbp), %rax
movq %rax, -0x710(%rbp)
leaq -0x508(%rbp), %rdi
callq 0x5a860
movl %eax, -0x704(%rbp)
jmp 0x58e30
movl -0x704(%rbp), %edx
movq -0x710(%rbp), %rdi
xorl %esi, %esi
callq 0x5a730
jmp 0x58e46
movl $0x0, -0x38c(%rbp)
leaq -0x508(%rbp), %rdi
callq 0x59c40
movl -0x38c(%rbp), %eax
testl %eax, %eax
je 0x58e6a
jmp 0x58e68
jmp 0x58e80
jmp 0x58b70
leaq -0x508(%rbp), %rdi
callq 0x59c40
jmp 0x5918b
movq -0xa0(%rbp), %rdi
movl -0x2ac(%rbp), %esi
callq 0x5a880
jmp 0x58e94
movq -0x5c8(%rbp), %rdi
movb $0x0, -0x531(%rbp)
callq 0x52cd0
leaq -0x3c8(%rbp), %rdi
movq %rdi, -0x720(%rbp)
callq 0x3ff60
movq -0x720(%rbp), %rdi
movq %rax, -0x548(%rbp)
callq 0x3fd60
movq %rax, -0x550(%rbp)
movq -0x548(%rbp), %rdi
movq -0x550(%rbp), %rsi
callq 0x591f0
movq %rax, -0x718(%rbp)
jmp 0x58ef0
movq -0x718(%rbp), %rax
movq %rax, -0x540(%rbp)
leaq -0x3c8(%rbp), %rdi
callq 0x3fd60
movq %rax, -0x560(%rbp)
leaq -0x540(%rbp), %rdi
leaq -0x560(%rbp), %rsi
callq 0x5a600
testb $0x1, %al
jne 0x58f2a
jmp 0x58f75
leaq -0x540(%rbp), %rdi
callq 0x5a970
movq %rax, %rdi
addq $0x20, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x24e50
movl %eax, -0x724(%rbp)
jmp 0x58f53
movq -0x5c8(%rbp), %rax
movl -0x724(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x58f96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x5917f
leaq 0x1c5f6(%rip), %rsi     # 0x75572
leaq -0x570(%rbp), %rdi
callq 0xd3b0
jmp 0x58f8a
leaq -0x570(%rbp), %rdi
callq 0xe198
leaq -0x3c8(%rbp), %rax
movq %rax, -0x578(%rbp)
movq -0x578(%rbp), %rdi
callq 0x3ff60
movq %rax, -0x580(%rbp)
movq -0x578(%rbp), %rdi
callq 0x3fd60
movq %rax, -0x588(%rbp)
leaq -0x580(%rbp), %rdi
leaq -0x588(%rbp), %rsi
callq 0x5a600
testb $0x1, %al
jne 0x58fe6
jmp 0x590de
leaq -0x580(%rbp), %rdi
callq 0x40290
movq %rax, -0x590(%rbp)
movq -0x590(%rbp), %rdi
leaq 0x1c584(%rip), %rsi     # 0x7558b
callq 0x10bd0
movb %al, -0x725(%rbp)
jmp 0x59014
movb -0x725(%rbp), %al
testb $0x1, %al
jne 0x59020
jmp 0x59022
jmp 0x59096
movq -0x5c8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x730(%rbp)
movq -0x590(%rbp), %rsi
leaq -0x5b8(%rbp), %rdi
callq 0x59230
jmp 0x59049
movq -0x590(%rbp), %rdx
addq $0x20, %rdx
leaq -0x598(%rbp), %rdi
leaq -0x5b8(%rbp), %rsi
callq 0x5a990
jmp 0x59069
movq -0x730(%rbp), %rdi
leaq -0x598(%rbp), %rsi
callq 0x53340
jmp 0x5907e
leaq -0x598(%rbp), %rdi
callq 0x10b60
leaq -0x5b8(%rbp), %rdi
callq 0xdac0
leaq -0x580(%rbp), %rdi
callq 0x5a710
jmp 0x58fca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x590cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x598(%rbp), %rdi
callq 0x10b60
leaq -0x5b8(%rbp), %rdi
callq 0xdac0
jmp 0x5917f
movq -0x5c8(%rbp), %rdi
addq $0x20, %rdi
leaq -0x4e0(%rbp), %rsi
callq 0x536d0
movb $0x1, -0x531(%rbp)
movl $0x1, -0x38c(%rbp)
testb $0x1, -0x531(%rbp)
jne 0x5911b
movq -0x5c8(%rbp), %rdi
callq 0x11110
leaq -0x4e0(%rbp), %rdi
callq 0x18ac0
leaq -0x3c8(%rbp), %rdi
callq 0x38d30
leaq -0x3b0(%rbp), %rdi
callq 0x62030
leaq -0x2f0(%rbp), %rdi
callq 0x59c40
leaq -0x2c8(%rbp), %rdi
callq 0x18ac0
leaq -0x248(%rbp), %rdi
callq 0xdcb0
leaq -0x98(%rbp), %rdi
callq 0x50220
movq -0x5c0(%rbp), %rax
addq $0x730, %rsp            # imm = 0x730
popq %rbp
retq
movq -0x5c8(%rbp), %rdi
callq 0x11110
leaq -0x4e0(%rbp), %rdi
callq 0x18ac0
leaq -0x3c8(%rbp), %rdi
callq 0x38d30
leaq -0x3b0(%rbp), %rdi
callq 0x62030
leaq -0x2f0(%rbp), %rdi
callq 0x59c40
leaq -0x2c8(%rbp), %rdi
callq 0x18ac0
leaq -0x248(%rbp), %rdi
callq 0xdcb0
leaq -0x98(%rbp), %rdi
callq 0x50220
movq -0x30(%rbp), %rdi
callq 0xd990
nopl (%rax,%rax)