// File: /workspace/github_cpp_makefile_star2_O2/kztomita[P]http-dump/http2_frame.cc
// Function: dump(http2_frame const&)
void dump(const http2_frame& frame) {
  auto type = frame.type();
  std::string type_str;
  std::vector<std::string> flags;
  std::function<void(const http2_frame::payload_type&, uint8_t)> dump_payload;

  switch (type) {
  case http2_frame_header::TYPE_DATA:
    type_str = "DATA";
    if (frame.flags() & 0x01) { flags.push_back("END_STREAM"); }
    if (frame.flags() & 0x08) { flags.push_back("PADDED"); }
    break;
  case http2_frame_header::TYPE_HEADERS:
    type_str = "HEADERS";
    if (frame.flags() & 0x01) { flags.push_back("END_STREAM"); }
    if (frame.flags() & 0x04) { flags.push_back("END_HEADERS"); }
    if (frame.flags() & 0x08) { flags.push_back("PADDED"); }
    if (frame.flags() & 0x20) { flags.push_back("PRIORITY"); }
    dump_payload = dump_headers_payload;
    break;
  case http2_frame_header::TYPE_PRIORITY:
    type_str = "PRIORITY";
    break;
  case http2_frame_header::TYPE_RST_STREAM:
    type_str = "RST_STREAM";
    dump_payload = dump_rst_stream_payload;
    break;
  case http2_frame_header::TYPE_SETTINGS:
    type_str = "SETTINGS";
    if (frame.flags() & 0x01) { flags.push_back("ACK"); }
    dump_payload = dump_settings_payload;
    break;
  case http2_frame_header::TYPE_PUSH_PROMISE:
    type_str = "PUSH_PROMISE";
    break;
  case http2_frame_header::TYPE_PING:
    type_str = "PING";
    break;
  case http2_frame_header::TYPE_GOAWAY:
    type_str = "GOAWAY";
    dump_payload = dump_goaway_payload;
    break;
  case http2_frame_header::TYPE_WINDOW_UPDATE:
    type_str = "WINDOW_UPDATE";
    dump_payload = dump_window_update_payload;
    break;
  case http2_frame_header::TYPE_CONTINUATION:
    type_str = "CONTINUATION";
    if (frame.flags() & 0x04) { flags.push_back("END_HEADERS"); }
    break;
  default:
    type_str = "Type: " + type;
    break;
  }

  std::cout << "Frame: " << type_str;
  std::cout << std::endl;

  std::cout << "Header:"
            << " Length=" << frame.length()
            << " StreamId=" << frame.stream_id()
            << " Flags=" << string_util::join(",", flags);
  std::cout << std::endl;

  dump(&frame.header(), sizeof(http2_frame_header));
  if (frame.payload().size() > 0) {
    std::cout << "Payload:" << std::endl;
    dump(frame.payload_buffer(), frame.payload().size(), 200);
    if (dump_payload) {
      dump_payload(frame.payload(), frame.flags());
    }
  }
  std::cout << std::endl;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
movzbl 0x3(%rdi), %eax
leaq 0x60(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
andq $0x0, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
cmpq $0x9, %rax
ja 0x23dc2
leaq 0x99d6(%rip), %rcx      # 0x2d528
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x9a3e(%rip), %rsi      # 0x2d5a0
leaq 0x50(%rsp), %rdi
callq 0xbcf0
movb 0x4(%rbx), %al
testb $0x1, %al
je 0x23ba5
leaq 0x9a2b(%rip), %rsi      # 0x2d5a5
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xd416
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x20a3e
leaq 0x10(%rsp), %rdi
callq 0xb2f0
movb 0x4(%rbx), %al
testb $0x8, %al
je 0x23dfa
leaq 0x99fc(%rip), %rsi      # 0x2d5b0
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xd416
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x20a3e
jmp 0x23c69
leaq 0x99f9(%rip), %rsi      # 0x2d5d7
leaq 0x50(%rsp), %rdi
callq 0xbcf0
testb $0x1, 0x4(%rbx)
je 0x23c1d
leaq 0x898d(%rip), %rsi      # 0x2c582
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xd416
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x20a3e
leaq 0x10(%rsp), %rdi
callq 0xb2f0
leaq 0x550(%rip), %rsi       # 0x24174
jmp 0x23df0
leaq 0x99d7(%rip), %rsi      # 0x2d607
leaq 0x50(%rsp), %rdi
callq 0xbcf0
testb $0x4, 0x4(%rbx)
je 0x23dfa
leaq 0x996c(%rip), %rsi      # 0x2d5b7
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xd416
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x20a3e
leaq 0x10(%rsp), %rdi
callq 0xb2f0
jmp 0x23dfa
leaq 0x9944(%rip), %rsi      # 0x2d5c3
jmp 0x23dcc
leaq 0x9941(%rip), %rsi      # 0x2d5cc
leaq 0x50(%rsp), %rdi
callq 0xbcf0
leaq 0x42d(%rip), %rsi       # 0x240c9
jmp 0x23df0
leaq 0x994a(%rip), %rsi      # 0x2d5f2
leaq 0x50(%rsp), %rdi
callq 0xbcf0
leaq 0x565(%rip), %rsi       # 0x2421e
jmp 0x23df0
leaq 0x98f6(%rip), %rsi      # 0x2d5bb
leaq 0x50(%rsp), %rdi
callq 0xbcf0
movb 0x4(%rbx), %al
testb $0x1, %al
je 0x23d08
leaq 0x98c8(%rip), %rsi      # 0x2d5a5
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xd416
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x20a3e
leaq 0x10(%rsp), %rdi
callq 0xb2f0
movb 0x4(%rbx), %al
testb $0x4, %al
je 0x23d3e
leaq 0x98a4(%rip), %rsi      # 0x2d5b7
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xd416
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x20a3e
leaq 0x10(%rsp), %rdi
callq 0xb2f0
movb 0x4(%rbx), %al
testb $0x8, %al
je 0x23d74
leaq 0x9867(%rip), %rsi      # 0x2d5b0
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xd416
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x20a3e
leaq 0x10(%rsp), %rdi
callq 0xb2f0
movb 0x4(%rbx), %al
testb $0x20, %al
je 0x23da7
leaq 0x9844(%rip), %rsi      # 0x2d5c3
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xd416
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x20a3e
leaq 0x10(%rsp), %rdi
callq 0xb2f0
leaq 0x213(%rip), %rsi       # 0x23fc1
jmp 0x23df0
leaq 0x9829(%rip), %rsi      # 0x2d5e0
jmp 0x23dcc
leaq 0x982d(%rip), %rsi      # 0x2d5ed
jmp 0x23dcc
leaq 0x984b(%rip), %rsi      # 0x2d614
addq %rax, %rsi
leaq 0x50(%rsp), %rdi
callq 0xbcf0
jmp 0x23dfa
leaq 0x981a(%rip), %rsi      # 0x2d5f9
leaq 0x50(%rsp), %rdi
callq 0xbcf0
leaq 0x513(%rip), %rsi       # 0x24303
leaq 0x70(%rsp), %rdi
callq 0x2446a
movq 0x22177(%rip), %rdi     # 0x45f78
leaq 0x9813(%rip), %rsi      # 0x2d61b
callq 0xb5e0
leaq 0x50(%rsp), %rsi
movq %rax, %rdi
callq 0xb570
movq 0x22157(%rip), %rdi     # 0x45f78
callq 0xb320
movq 0x2214b(%rip), %rdi     # 0x45f78
leaq 0x97ef(%rip), %rsi      # 0x2d623
callq 0xb5e0
leaq 0x97eb(%rip), %rsi      # 0x2d62b
movq %rax, %rdi
callq 0xb5e0
movzwl (%rbx), %ecx
movzbl 0x2(%rbx), %esi
shll $0x10, %esi
orl %ecx, %esi
bswapl %esi
shrl $0x8, %esi
movq %rax, %rdi
callq 0xb470
leaq 0x97cc(%rip), %rsi      # 0x2d634
movq %rax, %rdi
callq 0xb5e0
movl 0x5(%rbx), %esi
bswapl %esi
movq %rax, %rdi
callq 0xb470
leaq 0x97bb(%rip), %rsi      # 0x2d63f
movq %rax, %rdi
callq 0xb5e0
movq %rax, %r14
leaq 0x97b1(%rip), %rsi      # 0x2d647
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x244bb
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0xb570
leaq 0x10(%rsp), %rdi
callq 0xb2f0
movq 0x220b5(%rip), %rdi     # 0x45f78
callq 0xb320
pushq $0x9
popq %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x2a35c
movq 0x18(%rbx), %rax
cmpq 0x10(%rbx), %rax
je 0x23f32
movq 0x2208f(%rip), %rdi     # 0x45f78
leaq 0x9759(%rip), %rsi      # 0x2d649
callq 0xb5e0
movq %rax, %rdi
callq 0xb320
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
subq %rdi, %rsi
movl $0xc8, %edx
callq 0x2a35c
cmpq $0x0, 0x80(%rsp)
je 0x23f32
movzbl 0x4(%rbx), %edx
addq $0x10, %rbx
leaq 0x70(%rsp), %rdi
movq %rbx, %rsi
callq 0x24558
movq 0x2203f(%rip), %rdi     # 0x45f78
callq 0xb320
leaq 0x70(%rsp), %rdi
callq 0x13b94
leaq 0x30(%rsp), %rdi
callq 0x1643c
leaq 0x50(%rsp), %rdi
callq 0xb2f0
addq $0x98, %rsp
popq %rbx
popq %r14
retq
jmp 0x23f87
jmp 0x23f98
jmp 0x23f87
jmp 0x23f98
jmp 0x23f87
jmp 0x23f87
jmp 0x23f98
jmp 0x23f87
jmp 0x23f98
jmp 0x23f87
jmp 0x23f87
jmp 0x23f87
jmp 0x23f98
jmp 0x23f98
jmp 0x23f98
jmp 0x23f98
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xb2f0
jmp 0x23f9b
jmp 0x23f98
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x13b94
leaq 0x30(%rsp), %rdi
callq 0x1643c
leaq 0x50(%rsp), %rdi
callq 0xb2f0
movq %rbx, %rdi
callq 0xbba0