// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
movzbl 0x3(%rdi), %eax
xorl %ecx, %ecx
leaq 0x50(%rsp), %r12
movq %r12, -0x10(%r12)
movq %rcx, -0x8(%r12)
movb $0x0, (%r12)
movq %rcx, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
cmpq $0x9, %rax
ja 0x28711
leaq 0xb165(%rip), %rcx      # 0x33528
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xb1cd(%rip), %rcx      # 0x335a0
leaq 0x40(%rsp), %rdi
movl $0x4, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0xba50
movb 0x4(%rbx), %al
testb $0x1, %al
je 0x28433
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xb1a7(%rip), %rsi      # 0x335a5
leaq 0xb1aa(%rip), %rdx      # 0x335af
movq %rsp, %rdi
callq 0x1025a
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x242ea
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x28430
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
movb 0x4(%rbx), %al
testb $0x8, %al
je 0x28765
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xb165(%rip), %rsi      # 0x335b0
leaq 0xb164(%rip), %rdx      # 0x335b6
movq %rsp, %rdi
callq 0x1025a
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x242ea
jmp 0x2852c
leaq 0xb164(%rip), %rcx      # 0x335d7
leaq 0x40(%rsp), %rdi
movl $0x8, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0xba50
testb $0x1, 0x4(%rbx)
je 0x284cf
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xa0e5(%rip), %rsi      # 0x32582
leaq 0xa0e1(%rip), %rdx      # 0x32585
movq %rsp, %rdi
callq 0x1025a
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x242ea
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x284cf
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
leaq 0x85a(%rip), %rsi       # 0x28d30
jmp 0x2875b
leaq 0xb125(%rip), %rcx      # 0x33607
leaq 0x40(%rsp), %rdi
movl $0xc, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0xba50
testb $0x4, 0x4(%rbx)
je 0x28765
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xb0a7(%rip), %rsi      # 0x335b7
leaq 0xb0ab(%rip), %rdx      # 0x335c2
movq %rsp, %rdi
callq 0x1025a
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x242ea
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x28765
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
jmp 0x28765
movl $0x8, %r8d
leaq 0xb06b(%rip), %r14      # 0x335c3
jmp 0x28726
leaq 0xb068(%rip), %rcx      # 0x335cc
leaq 0x40(%rsp), %rdi
movl $0xa, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0xba50
leaq 0x6a8(%rip), %rsi       # 0x28c27
jmp 0x2875b
leaq 0xb067(%rip), %rcx      # 0x335f2
leaq 0x40(%rsp), %rdi
movl $0x6, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0xba50
leaq 0x8c6(%rip), %rsi       # 0x28e6c
jmp 0x2875b
leaq 0xb009(%rip), %rcx      # 0x335bb
leaq 0x40(%rsp), %rdi
movl $0x7, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0xba50
movb 0x4(%rbx), %al
testb $0x1, %al
je 0x28612
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xafc8(%rip), %rsi      # 0x335a5
leaq 0xafcb(%rip), %rdx      # 0x335af
movq %rsp, %rdi
callq 0x1025a
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x242ea
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x2860f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
movb 0x4(%rbx), %al
testb $0x4, %al
je 0x2865b
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xaf91(%rip), %rsi      # 0x335b7
leaq 0xaf95(%rip), %rdx      # 0x335c2
movq %rsp, %rdi
callq 0x1025a
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x242ea
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x28658
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
movb 0x4(%rbx), %al
testb $0x8, %al
je 0x286a4
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xaf41(%rip), %rsi      # 0x335b0
leaq 0xaf40(%rip), %rdx      # 0x335b6
movq %rsp, %rdi
callq 0x1025a
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x242ea
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x286a1
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
movb 0x4(%rbx), %al
testb $0x20, %al
je 0x286ea
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xaf0b(%rip), %rsi      # 0x335c3
leaq 0xaf0c(%rip), %rdx      # 0x335cb
movq %rsp, %rdi
callq 0x1025a
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x242ea
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x286ea
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
leaq 0x370(%rip), %rsi       # 0x28a61
jmp 0x2875b
movl $0xc, %r8d
leaq 0xaee0(%rip), %r14      # 0x335e0
jmp 0x28726
movl $0x4, %r8d
leaq 0xaede(%rip), %r14      # 0x335ed
jmp 0x28726
leaq 0xaefc(%rip), %r14      # 0x33614
addq %rax, %r14
movq %r14, %rdi
callq 0xb2c0
movq %rax, %r8
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %r14, %rcx
callq 0xba50
jmp 0x28765
leaq 0xaeb9(%rip), %rcx      # 0x335f9
leaq 0x40(%rsp), %rdi
movl $0xd, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0xba50
leaq 0x880(%rip), %rsi       # 0x28fdb
leaq 0x60(%rsp), %rdi
callq 0x2919e
movq 0x1e814(%rip), %rdi     # 0x46f80
leaq 0xaea8(%rip), %rsi      # 0x3361b
movl $0x7, %edx
callq 0xb730
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x1e7f2(%rip), %r14     # 0x46f80
movq %r14, %rdi
callq 0xb730
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0xb5b0
movsbl %al, %esi
movq 0x1e7cc(%rip), %rdi     # 0x46f80
callq 0xb050
movq %rax, %rdi
callq 0xb450
movq 0x1e7b8(%rip), %rdi     # 0x46f80
leaq 0xae54(%rip), %rsi      # 0x33623
movl $0x7, %edx
callq 0xb730
movq 0x1e7a0(%rip), %rdi     # 0x46f80
leaq 0xae44(%rip), %rsi      # 0x3362b
movl $0x8, %edx
callq 0xb730
movzwl (%rbx), %eax
movzbl 0x2(%rbx), %esi
shll $0x10, %esi
orl %eax, %esi
bswapl %esi
shrl $0x8, %esi
movq 0x1e777(%rip), %r14     # 0x46f80
movq %r14, %rdi
callq 0xb440
movq %rax, %r15
leaq 0xae19(%rip), %rsi      # 0x33634
movl $0xa, %edx
movq %rax, %rdi
callq 0xb730
movl 0x5(%rbx), %esi
bswapl %esi
movq %r15, %rdi
callq 0xb440
movq %rax, %r15
leaq 0xae00(%rip), %rsi      # 0x3363f
movl $0x7, %edx
movq %rax, %rdi
callq 0xb730
leaq 0xadf4(%rip), %rsi      # 0x33647
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x29211
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r15, %rdi
callq 0xb730
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2888c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0xb5b0
movsbl %al, %esi
movq 0x1e6d6(%rip), %r14     # 0x46f80
movq %r14, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb450
movl $0x9, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x309e0
movq 0x18(%rbx), %rax
cmpq 0x10(%rbx), %rax
je 0x28950
movq 0x1e6a3(%rip), %r15     # 0x46f80
leaq 0xad65(%rip), %rsi      # 0x33649
movl $0x8, %edx
movq %r15, %rdi
callq 0xb730
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0xb5b0
movsbl %al, %esi
movq 0x1e671(%rip), %rdi     # 0x46f80
callq 0xb050
movq %rax, %rdi
callq 0xb450
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
subq %rdi, %rsi
movl $0xc8, %edx
callq 0x309e0
cmpq $0x0, 0x70(%rsp)
je 0x28950
movb 0x4(%rbx), %al
addq $0x10, %rbx
movq %rsp, %rdx
movb %al, (%rdx)
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq *0x18(%rdi)
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0xb5b0
movsbl %al, %esi
movq 0x1e612(%rip), %rdi     # 0x46f80
callq 0xb050
movq %rax, %rdi
callq 0xb450
movq 0x70(%rsp), %rax
testq %rax, %rax
je 0x28994
leaq 0x60(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x20(%rsp), %rdi
callq 0x18772
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x289b5
movq 0x50(%rsp), %rsi
incq %rsi
callq 0xb600
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x289da
jmp 0x28a14
jmp 0x289da
jmp 0x28a14
jmp 0x289da
jmp 0x289da
jmp 0x28a14
jmp 0x289da
jmp 0x28a14
jmp 0x289da
jmp 0x289da
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
jne 0x28a03
jmp 0x28a17
jmp 0x28a14
jmp 0x28a14
jmp 0x28a14
jmp 0x28a14
jmp 0x28a59
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28a17
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
jmp 0x28a17
jmp 0x28a14
movq %rax, %rbx
movq 0x70(%rsp), %rax
testq %rax, %rax
je 0x28a30
leaq 0x60(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x20(%rsp), %rdi
callq 0x18772
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x28a51
movq 0x50(%rsp), %rsi
incq %rsi
callq 0xb600
movq %rbx, %rdi
callq 0xbbb0
movq %rax, %rdi
callq 0xd8d9