// File: kztomita[P]http-dump/hpack_decoder.cc
// Function: hpack::(anonymous namespace)::parse_string_literal_representation[abi:cxx11](buffer_view<unsigned char> const&, unsigned long)
std::pair<std::string, std::size_t>
parse_string_literal_representation(const buffer_view<unsigned char>& buffer, std::size_t offset) {
  unsigned int top_byte = buffer.at(offset);

  // String Length
  auto integer_len = parse_integer_representation(buffer, offset, 7);
  std::size_t len = integer_len.first;

  std::size_t representation_size = integer_len.second + len;

  auto string_data_buffer = buffer.subview(offset + integer_len.second, len);

  if (top_byte & 0x80) {
    auto decoded = decode_huffman(string_data_buffer.address(0), string_data_buffer.size());
    return std::pair(std::string(reinterpret_cast<const char*>(&decoded[0]),
                                 decoded.size()),
                     representation_size);
  } else {
    return std::pair(std::string(reinterpret_cast<const char*>(string_data_buffer.address(0)),
                                 string_data_buffer.size()),
                     representation_size);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0xd8(%rbp)
movq %rdi, %rax
movq %rax, -0xd0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x612f0
movzbl %al, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x7, %edx
callq 0x62590
movl %eax, -0x30(%rbp)
movq %rdx, -0x28(%rbp)
movslq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq -0x28(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x63010
movq %rax, -0x50(%rbp)
movq %rdx, -0x48(%rbp)
movl -0x1c(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x628ec
xorl %eax, %eax
movl %eax, %esi
movq %rsi, -0x100(%rbp)
leaq -0x50(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x630e0
movq -0x110(%rbp), %rdi
movq %rax, -0x108(%rbp)
callq 0x63170
movq -0x108(%rbp), %rsi
movq %rax, %rdx
leaq -0x68(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x66160
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdi
callq 0x5a460
movq -0xf8(%rbp), %rdi
movq %rax, -0xf0(%rbp)
callq 0x4e6b0
movq %rax, -0xe8(%rbp)
leaq -0x89(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0xddb0
movq -0xf0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
movq -0xe0(%rbp), %rcx
leaq -0x88(%rbp), %rdi
callq 0xe080
jmp 0x62861
movq -0xd8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x63190
jmp 0x6287a
leaq -0x88(%rbp), %rdi
callq 0xdac0
leaq -0x89(%rbp), %rdi
callq 0xe180
leaq -0x68(%rbp), %rdi
callq 0x18ac0
jmp 0x629c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x628d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0xdac0
leaq -0x89(%rbp), %rdi
callq 0xe180
leaq -0x68(%rbp), %rdi
callq 0x18ac0
jmp 0x629d3
xorl %eax, %eax
movl %eax, %esi
leaq -0x50(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x630e0
movq -0x130(%rbp), %rdi
movq %rax, -0x128(%rbp)
callq 0x63170
movq %rax, -0x120(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0xddb0
movq -0x128(%rbp), %rsi
movq -0x120(%rbp), %rdx
movq -0x118(%rbp), %rcx
leaq -0xc0(%rbp), %rdi
callq 0xe080
jmp 0x62950
movq -0xd8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x63190
jmp 0x62969
leaq -0xc0(%rbp), %rdi
callq 0xdac0
leaq -0xc1(%rbp), %rdi
callq 0xe180
jmp 0x629c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x629b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0xdac0
leaq -0xc1(%rbp), %rdi
callq 0xe180
jmp 0x629d3
movq -0xd0(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0x98(%rbp), %rdi
callq 0xd990
nop