// File: /workspace/github_cpp_makefile_star2_O1/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 0x28aff
leaq 0xbd71(%rip), %rcx      # 0x34528
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xbdd9(%rip), %rcx      # 0x345a0
leaq 0x40(%rsp), %rdi
movl $0x4, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0xba50
testb $0x1, 0x4(%rbx)
je 0x28823
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xbdb4(%rip), %rsi      # 0x345a5
leaq 0xbdb7(%rip), %rdx      # 0x345af
movq %rsp, %rdi
callq 0x10322
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x24542
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x28823
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
testb $0x8, 0x4(%rbx)
je 0x28b53
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xbd73(%rip), %rsi      # 0x345b0
leaq 0xbd72(%rip), %rdx      # 0x345b6
movq %rsp, %rdi
callq 0x10322
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x24542
jmp 0x2891e
leaq 0xbd72(%rip), %rcx      # 0x345d7
leaq 0x40(%rsp), %rdi
movl $0x8, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0xba50
testb $0x1, 0x4(%rbx)
je 0x288c1
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xacf3(%rip), %rsi      # 0x33582
leaq 0xacef(%rip), %rdx      # 0x33585
movq %rsp, %rdi
callq 0x10322
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x24542
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x288c1
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
leaq 0x856(%rip), %rsi       # 0x2911e
jmp 0x28b49
leaq 0xbd33(%rip), %rcx      # 0x34607
leaq 0x40(%rsp), %rdi
movl $0xc, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0xba50
testb $0x4, 0x4(%rbx)
je 0x28b53
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xbcb5(%rip), %rsi      # 0x345b7
leaq 0xbcb9(%rip), %rdx      # 0x345c2
movq %rsp, %rdi
callq 0x10322
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x24542
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x28b53
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
jmp 0x28b53
movl $0x8, %r8d
leaq 0xbc79(%rip), %r14      # 0x345c3
jmp 0x28b14
leaq 0xbc76(%rip), %rcx      # 0x345cc
leaq 0x40(%rsp), %rdi
movl $0xa, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0xba50
leaq 0x6a4(%rip), %rsi       # 0x29015
jmp 0x28b49
leaq 0xbc75(%rip), %rcx      # 0x345f2
leaq 0x40(%rsp), %rdi
movl $0x6, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0xba50
leaq 0x8c2(%rip), %rsi       # 0x2925a
jmp 0x28b49
leaq 0xbc17(%rip), %rcx      # 0x345bb
leaq 0x40(%rsp), %rdi
movl $0x7, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0xba50
testb $0x1, 0x4(%rbx)
je 0x28a00
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xbbd7(%rip), %rsi      # 0x345a5
leaq 0xbbda(%rip), %rdx      # 0x345af
movq %rsp, %rdi
callq 0x10322
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x24542
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x28a00
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
testb $0x4, 0x4(%rbx)
je 0x28a48
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xbba1(%rip), %rsi      # 0x345b7
leaq 0xbba5(%rip), %rdx      # 0x345c2
movq %rsp, %rdi
callq 0x10322
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x24542
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x28a48
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
testb $0x8, 0x4(%rbx)
je 0x28a90
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xbb52(%rip), %rsi      # 0x345b0
leaq 0xbb51(%rip), %rdx      # 0x345b6
movq %rsp, %rdi
callq 0x10322
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x24542
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x28a90
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
testb $0x20, 0x4(%rbx)
je 0x28ad8
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xbb1d(%rip), %rsi      # 0x345c3
leaq 0xbb1e(%rip), %rdx      # 0x345cb
movq %rsp, %rdi
callq 0x10322
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x24542
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x28ad8
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
leaq 0x370(%rip), %rsi       # 0x28e4f
jmp 0x28b49
movl $0xc, %r8d
leaq 0xbaf2(%rip), %r14      # 0x345e0
jmp 0x28b14
movl $0x4, %r8d
leaq 0xbaf0(%rip), %r14      # 0x345ed
jmp 0x28b14
leaq 0xbb0e(%rip), %r14      # 0x34614
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 0x28b53
leaq 0xbacb(%rip), %rcx      # 0x345f9
leaq 0x40(%rsp), %rdi
movl $0xd, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0xba50
leaq 0x880(%rip), %rsi       # 0x293c9
leaq 0x60(%rsp), %rdi
callq 0x29580
movq 0x1f42e(%rip), %rdi     # 0x47f88
leaq 0xbaba(%rip), %rsi      # 0x3461b
movl $0x7, %edx
callq 0xb730
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x1f40c(%rip), %r14     # 0x47f88
movq %r14, %rdi
callq 0xb730
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0xb5b0
movsbl %al, %esi
movq 0x1f3e6(%rip), %rdi     # 0x47f88
callq 0xb050
movq %rax, %rdi
callq 0xb450
movq 0x1f3d2(%rip), %rdi     # 0x47f88
leaq 0xba66(%rip), %rsi      # 0x34623
movl $0x7, %edx
callq 0xb730
movq 0x1f3ba(%rip), %rdi     # 0x47f88
leaq 0xba56(%rip), %rsi      # 0x3462b
movl $0x8, %edx
callq 0xb730
movzwl (%rbx), %eax
movzbl 0x2(%rbx), %esi
shll $0x10, %esi
orl %eax, %esi
bswapl %esi
shrl $0x8, %esi
movq 0x1f391(%rip), %r14     # 0x47f88
movq %r14, %rdi
callq 0xb440
movq %rax, %r15
leaq 0xba2b(%rip), %rsi      # 0x34634
movl $0xa, %edx
movq %rax, %rdi
callq 0xb730
movl 0x5(%rbx), %esi
bswapl %esi
movq %r15, %rdi
callq 0xb440
movq %rax, %r15
leaq 0xba12(%rip), %rsi      # 0x3463f
movl $0x7, %edx
movq %rax, %rdi
callq 0xb730
leaq 0xba06(%rip), %rsi      # 0x34647
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x29600
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r15, %rdi
callq 0xb730
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28c7a
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 0x1f2f0(%rip), %r14     # 0x47f88
movq %r14, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb450
movl $0x9, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x31004
movq 0x18(%rbx), %rax
cmpq 0x10(%rbx), %rax
je 0x28d3e
movq 0x1f2bd(%rip), %r15     # 0x47f88
leaq 0xb977(%rip), %rsi      # 0x34649
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 0x1f28b(%rip), %rdi     # 0x47f88
callq 0xb050
movq %rax, %rdi
callq 0xb450
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
subq %rdi, %rsi
movl $0xc8, %edx
callq 0x31004
cmpq $0x0, 0x70(%rsp)
je 0x28d3e
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 0x1f22c(%rip), %rdi     # 0x47f88
callq 0xb050
movq %rax, %rdi
callq 0xb450
movq 0x70(%rsp), %rax
testq %rax, %rax
je 0x28d82
leaq 0x60(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x20(%rsp), %rdi
callq 0x18866
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x28da3
movq 0x50(%rsp), %rsi
incq %rsi
callq 0xb600
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x28dc8
jmp 0x28e02
jmp 0x28dc8
jmp 0x28e02
jmp 0x28dc8
jmp 0x28dc8
jmp 0x28e02
jmp 0x28dc8
jmp 0x28e02
jmp 0x28dc8
jmp 0x28dc8
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
jne 0x28df1
jmp 0x28e05
jmp 0x28e02
jmp 0x28e02
jmp 0x28e02
jmp 0x28e02
jmp 0x28e47
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28e05
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xb600
jmp 0x28e05
jmp 0x28e02
movq %rax, %rbx
movq 0x70(%rsp), %rax
testq %rax, %rax
je 0x28e1e
leaq 0x60(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x20(%rsp), %rdi
callq 0x18866
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x28e3f
movq 0x50(%rsp), %rsi
incq %rsi
callq 0xb600
movq %rbx, %rdi
callq 0xbbb0
movq %rax, %rdi
callq 0xd91f