// File: /workspace/github_c_makefile_star2_O3/enzo1982[P]smooth/libraries/libwebp/src/dec/vp8l_dec.c
// Function: ReadHuffmanCode
static int ReadHuffmanCode(int alphabet_size, VP8LDecoder* const dec,
                           int* const code_lengths,
                           HuffmanTables* const table) {
  int ok = 0;
  int size = 0;
  VP8LBitReader* const br = &dec->br_;
  const int simple_code = VP8LReadBits(br, 1);

  memset(code_lengths, 0, alphabet_size * sizeof(*code_lengths));

  if (simple_code) {  // Read symbols, codes & code lengths directly.
    const int num_symbols = VP8LReadBits(br, 1) + 1;
    const int first_symbol_len_code = VP8LReadBits(br, 1);
    // The first code is either 1 bit or 8 bit code.
    int symbol = VP8LReadBits(br, (first_symbol_len_code == 0) ? 1 : 8);
    code_lengths[symbol] = 1;
    // The second code (if present), is always 8 bits long.
    if (num_symbols == 2) {
      symbol = VP8LReadBits(br, 8);
      code_lengths[symbol] = 1;
    }
    ok = 1;
  } else {  // Decode Huffman-coded code lengths.
    int i;
    int code_length_code_lengths[NUM_CODE_LENGTH_CODES] = { 0 };
    const int num_codes = VP8LReadBits(br, 4) + 4;
    assert(num_codes <= NUM_CODE_LENGTH_CODES);

    for (i = 0; i < num_codes; ++i) {
      code_length_code_lengths[kCodeLengthCodeOrder[i]] = VP8LReadBits(br, 3);
    }
    ok = ReadHuffmanCodeLengths(dec, code_length_code_lengths, alphabet_size,
                                code_lengths);
  }

  ok = ok && !br->eos_;
  if (ok) {
    size = VP8LBuildHuffmanTable(table, HUFFMAN_TABLE_BITS,
                                 code_lengths, alphabet_size);
  }
  if (!ok || size == 0) {
    return VP8LSetError(dec, VP8_STATUS_BITSTREAM_ERROR);
  }
  return size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rcx, 0x10(%rsp)
movq %rdx, %r14
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x28(%rsi), %r12
movl $0x1, %r15d
movq %r12, %rdi
movl $0x1, %esi
callq 0xeffac
movl %eax, %r13d
movl %ebp, (%rsp)
movslq %ebp, %rdx
shlq $0x2, %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x55f20
testl %r13d, %r13d
je 0xd3c15
movq %r12, %rdi
movl $0x1, %esi
callq 0xeffac
movl %eax, %r13d
movq %r12, %rdi
movl $0x1, %esi
callq 0xeffac
testl %eax, %eax
movl $0x8, %esi
cmovel %r15d, %esi
movq %r12, %rdi
callq 0xeffac
cltq
movl $0x1, (%r14,%rax,4)
cmpl $0x1, %r13d
jne 0xd3e03
movq %r12, %rdi
movl $0x8, %esi
callq 0xeffac
cltq
movl $0x1, (%r14,%rax,4)
jmp 0xd3e03
movq %r14, 0x8(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x7c(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movq %r12, %rdi
movl $0x4, %esi
callq 0xeffac
addl $0x4, %eax
cmpl $0x13, %eax
jg 0xd3e49
testl %eax, %eax
jle 0xd3c7e
movl %eax, %r14d
xorl %r15d, %r15d
leaq 0x55be0(%rip), %r13     # 0x129840
movq %r12, %rdi
movl $0x3, %esi
callq 0xeffac
movzbl (%r15,%r13), %ecx
movl %eax, 0x40(%rsp,%rcx,4)
incq %r15
cmpq %r15, %r14
jne 0xd3c60
leaq 0x18(%rsp), %rsi
movl $0x80, %edi
callq 0xf0927
testl %eax, %eax
je 0xd3cec
leaq 0x18(%rsp), %rdi
leaq 0x40(%rsp), %rdx
movl $0x7, %esi
movl $0x13, %ecx
callq 0xf018f
testl %eax, %eax
je 0xd3cec
movq %r12, %rdi
movl $0x1, %esi
callq 0xeffac
movl (%rsp), %r13d
testl %eax, %eax
je 0xd3d10
movq %r12, %rdi
movl $0x3, %esi
callq 0xeffac
leal 0x2(,%rax,2), %esi
movq %r12, %rdi
callq 0xeffac
movl %eax, %r13d
addl $0x2, %r13d
cmpl (%rsp), %r13d
jle 0xd3d10
leaq 0x18(%rsp), %rdi
callq 0xf0967
movl (%rbx), %eax
cmpl $0x5, %eax
je 0xd3d05
testl %eax, %eax
jne 0xd3e09
movl $0x3, (%rbx)
jmp 0xd3e09
cmpl $0x0, (%rsp)
movq 0x8(%rsp), %r14
jle 0xd3df9
movl $0x8, 0x4(%rsp)
xorl %r15d, %r15d
subl $0x1, %r13d
jb 0xd3df9
movl 0x48(%rbx), %ecx
cmpl $0x20, %ecx
jl 0xd3d47
movq %r12, %rdi
callq 0xefeb1
movl 0x48(%rbx), %ecx
movq 0x28(%rbx), %rax
shrq %cl, %rax
movq 0x38(%rsp), %rdx
movq (%rdx), %rdx
andl $0x7f, %eax
movzbl (%rdx,%rax,4), %esi
addl %ecx, %esi
movl %esi, 0x48(%rbx)
movzwl 0x2(%rdx,%rax,4), %ebp
cmpl $0xf, %ebp
ja 0xd3d85
movslq %r15d, %rax
incl %r15d
movl %ebp, (%r14,%rax,4)
testl %ebp, %ebp
movl 0x4(%rsp), %eax
cmovnel %ebp, %eax
movl %eax, 0x4(%rsp)
jmp 0xd3def
leal -0x10(%rbp), %eax
leaq 0x55ac4(%rip), %rcx     # 0x129853
movzbl (%rax,%rcx), %esi
leaq 0x55abc(%rip), %rcx     # 0x129856
movzbl (%rax,%rcx), %r14d
movq %r12, %rdi
callq 0xeffac
leal (%rax,%r14), %esi
leal (%rsi,%r15), %ecx
cmpl (%rsp), %ecx
jg 0xd3cec
cmpl $0x10, %ebp
movl $0x0, %edx
cmovel 0x4(%rsp), %edx
testl %esi, %esi
jle 0xd3dea
movslq %r15d, %rsi
movq 0x8(%rsp), %rdi
leaq (%rdi,%rsi,4), %rsi
addl %r14d, %eax
incl %eax
movl %edx, (%rsi)
addq $0x4, %rsi
decl %eax
cmpl $0x1, %eax
ja 0xd3dda
movl %ecx, %r15d
movq 0x8(%rsp), %r14
cmpl (%rsp), %r15d
jl 0xd3d2a
leaq 0x18(%rsp), %rdi
callq 0xf0967
cmpl $0x0, 0x4c(%rbx)
je 0xd3e1e
movl (%rbx), %ecx
xorl %eax, %eax
cmpl $0x5, %ecx
je 0xd3e16
testl %ecx, %ecx
jne 0xd3e37
movl $0x3, (%rbx)
jmp 0xd3e37
movq 0x10(%rsp), %rdi
movl $0x8, %esi
movq %r14, %rdx
movl (%rsp), %ecx
callq 0xf018f
testl %eax, %eax
je 0xd3e09
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x55c48(%rip), %rdi     # 0x129a98
leaq 0x55a92(%rip), %rsi     # 0x1298e9
leaq 0x55c5d(%rip), %rcx     # 0x129abb
movl $0x159, %edx            # imm = 0x159
callq 0x55710