// File: /workspace/github_cpp_makefile_star2_O3/kztomita[P]http-dump/hpack_decoder.cc
// Function: hpack::hpack_decoder::decode_representation(hpack::decoding_context&)
hpack_decoder::decoded_result hpack_decoder::decode_representation(decoding_context& context) {

  if (!buffer_view_.test_range(decode_pos_, 1)) {
    return decoded_result(std::nullopt, true);
  }

  int top_byte = buffer_view_.at(decode_pos_);

  if (top_byte & 0x80) {
    // 0b1...
    // Indexed Header Field Representation
    auto index = fetch_integer(7);
    return decoded_result(hpack_table_at(*context.dynamic_table, index),
                          false);
  } else if ((top_byte & 0xc0) == 0x40) {
    // 0b01...
    // Literal Header Field with Incremental Indexing
    auto index = fetch_integer(6);
    header_type header = fetch_header(context, index);
    context.dynamic_table->add(header);
    return decoded_result(std::move(header),
                          false);
  } else if ((top_byte & 0xf0) == 0x00) {
    // 0b0000...
    // Literal Header Field without Indexing
    auto index = fetch_integer(4);
    return decoded_result(fetch_header(context, index),
                          false);
  } else if ((top_byte & 0xf0) == 0x10) {
    // 0b0001...
    // Literal Header Field Never Indexed
    auto index = fetch_integer(4);
    return decoded_result(fetch_header(context, index),
                          false);
  } else if ((top_byte & 0xe0) == 0x20) {
    // 0b001...
    // Dynamic Table Size Update
    // このエントリはコマンドなのでヘッダはない
    auto max_size = fetch_integer(5);
    context.dynamic_table->set_maximum_table_size(max_size);
    return decoded_result(std::nullopt, false);
  }

  throw std::runtime_error("Unknown representation.");
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq 0x10(%rsi), %rsi
cmpq $-0x1, %rsi
je 0x2961b
cmpq %rsi, 0x8(%r15)
jbe 0x2961b
movq %rdx, %r14
movq %r15, %rdi
callq 0x29306
testb %al, %al
js 0x29628
cmpb $0x40, %al
jae 0x29687
movl %eax, %ecx
andb $0x30, %cl
cmpb $0x10, %cl
je 0x295d1
movzbl %cl, %ecx
testl %ecx, %ecx
jne 0x296e3
movq 0x10(%r15), %rsi
movl $0x4, %edx
movq %r15, %rdi
callq 0x2984c
addq %rdx, 0x10(%r15)
movslq %eax, %rcx
movq %rsp, %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x29aa0
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq (%r12), %rcx
leaq 0x10(%rsp), %rdx
cmpq %rdx, %rcx
je 0x29718
movq %rcx, (%rbx)
jmp 0x296d3
movb $0x0, 0x40(%rbx)
movb $0x1, 0x48(%rbx)
jmp 0x297d5
movq 0x10(%r15), %rsi
movl $0x7, %edx
movq %r15, %rdi
callq 0x2984c
addq %rdx, 0x10(%r15)
movq (%r14), %rsi
movslq %eax, %rdx
movq %rsp, %r14
movq %r14, %rdi
callq 0x2a323
movb $0x0, 0x40(%rbx)
cmpb $0x1, 0x40(%r14)
jne 0x2975e
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x10(%rsp), %rcx
movq -0x10(%rcx), %rdx
cmpq %rcx, %rdx
je 0x29764
movq %rdx, (%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rbx)
jmp 0x2976a
movq 0x10(%r15), %rsi
movl $0x6, %edx
movq %r15, %rdi
callq 0x2984c
addq %rdx, 0x10(%r15)
movslq %eax, %rcx
movq %rsp, %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x29aa0
movq (%r14), %rdi
movq %r12, %rsi
callq 0x2a0bc
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x10(%rsp), %rcx
movq -0x10(%rcx), %rdx
cmpq %rcx, %rdx
je 0x296de
movq %rdx, (%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rbx)
jmp 0x2971e
movups (%rcx), %xmm0
jmp 0x2971b
cmpb $0x20, %al
jb 0x297e4
movq 0x10(%r15), %rsi
movl $0x5, %edx
movq %r15, %rdi
callq 0x2984c
addq %rdx, 0x10(%r15)
movq (%r14), %rdi
movslq %eax, %rsi
callq 0x2a006
xorl %eax, %eax
movb %al, 0x40(%rbx)
movb %al, 0x48(%rbx)
jmp 0x297d5
movups (%rdx), %xmm0
movups %xmm0, (%rax)
leaq 0x30(%rsp), %rax
movq -0x28(%rax), %rcx
movq %rcx, 0x8(%rbx)
leaq 0x30(%rbx), %rcx
movq %rcx, 0x20(%rbx)
movq -0x10(%rax), %rdx
cmpq %rax, %rdx
je 0x2974b
movq %rdx, 0x20(%rbx)
movq 0x30(%rsp), %rax
movq %rax, 0x30(%rbx)
jmp 0x29751
movups (%rax), %xmm0
movups %xmm0, (%rcx)
movq 0x28(%rsp), %rax
movq %rax, 0x28(%rbx)
movb $0x1, 0x40(%rbx)
movb $0x0, 0x48(%rbx)
jmp 0x297d5
movups (%rcx), %xmm0
movups %xmm0, (%rax)
leaq 0x30(%rsp), %rax
movq -0x28(%rax), %rdx
movq %rdx, 0x8(%rbx)
movq %rcx, -0x30(%rax)
movq $0x0, -0x28(%rax)
movb $0x0, -0x20(%rax)
leaq 0x30(%rbx), %rcx
movq %rcx, 0x20(%rbx)
movq -0x10(%rax), %rdx
cmpq %rax, %rdx
je 0x297a7
movq %rdx, 0x20(%rbx)
movq 0x30(%rsp), %rcx
movq %rcx, 0x30(%rbx)
jmp 0x297ad
movups (%rax), %xmm0
movups %xmm0, (%rcx)
movq %rsp, %rdi
movq 0x28(%rdi), %rcx
movq %rcx, 0x28(%rbx)
movq %rax, 0x20(%rdi)
movq $0x0, 0x28(%rdi)
xorl %eax, %eax
movb %al, 0x30(%rdi)
movb $0x1, 0x40(%rbx)
movb %al, 0x48(%rbx)
callq 0x29de4
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movl $0x10, %edi
callq 0xb300
movq %rax, %rbx
leaq 0xa0ae(%rip), %rsi      # 0x338a6
movq %rax, %rdi
callq 0xb270
movq 0x1d7e1(%rip), %rsi     # 0x46fe8
movq 0x1d73a(%rip), %rdx     # 0x46f48
movq %rbx, %rdi
callq 0xbb60
movq %rax, %r14
movq %rbx, %rdi
callq 0xb4b0
jmp 0x2982e
movq %rax, %r14
movq %rsp, %rdi
callq 0x19ad0
movq %r14, %rdi
callq 0xbbb0