// File: /workspace/github_c_makefile_star2_O1/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 $0xa8, %rsp
movq %rcx, 0x20(%rsp)
movq %rdx, %r15
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x28(%rsi), %r12
movq %r12, %rdi
movl $0x1, %esi
callq 0xf0d7f
movl %eax, %r13d
movslq %ebp, %rdx
shlq $0x2, %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x55f20
testl %r13d, %r13d
movl %ebp, 0x1c(%rsp)
je 0xd4b6c
movl $0x1, %r14d
movq %r12, %rdi
movl $0x1, %esi
callq 0xf0d7f
movl %eax, %r13d
movq %r12, %rdi
movl $0x1, %esi
callq 0xf0d7f
testl %eax, %eax
movl $0x8, %esi
cmovel %r14d, %esi
movq %r12, %rdi
callq 0xf0d7f
cltq
movl $0x1, (%r15,%rax,4)
cmpl $0x1, %r13d
jne 0xd4b5f
movq %r12, %rdi
movl $0x8, %esi
callq 0xf0d7f
cltq
movl $0x1, (%r15,%rax,4)
cmpl $0x0, 0x4c(%rbx)
sete %bpl
jmp 0xd4d88
movq %r15, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x8c(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movq %r12, %rdi
movl $0x4, %esi
callq 0xf0d7f
addl $0x4, %eax
cmpl $0x13, %eax
jg 0xd4de8
testl %eax, %eax
jle 0xd4bdb
movl %eax, %r14d
xorl %r15d, %r15d
leaq 0x55a53(%rip), %r13     # 0x12a610
movq %r12, %rdi
movl $0x3, %esi
callq 0xf0d7f
movzbl (%r15,%r13), %ecx
movl %eax, 0x50(%rsp,%rcx,4)
incq %r15
cmpq %r15, %r14
jne 0xd4bbd
leaq 0x28(%rsp), %rsi
movl $0x80, %edi
callq 0xf1607
testl %eax, %eax
je 0xd4d66
leaq 0x28(%rsp), %rdi
leaq 0x50(%rsp), %rdx
movl $0x7, %esi
movl $0x13, %ecx
callq 0xf0f5e
testl %eax, %eax
je 0xd4d66
movq %r12, %rdi
movl $0x1, %esi
callq 0xf0d7f
movl %ebp, %r13d
testl %eax, %eax
je 0xd4c53
movq %r12, %rdi
movl $0x3, %esi
callq 0xf0d7f
leal 0x2(,%rax,2), %esi
movq %r12, %rdi
callq 0xf0d7f
movl %eax, %r13d
addl $0x2, %r13d
cmpl %ebp, %r13d
jg 0xd4d66
xorl %r15d, %r15d
movl $0x8, 0x8(%rsp)
cmpl %ebp, %r15d
jge 0xd4dd4
movl $0x4, %ecx
subl $0x1, %r13d
jb 0xd4d59
cmpl $0x20, 0x48(%rbx)
jl 0xd4c84
movq %r12, %rdi
callq 0xf0c80
movq 0x28(%rbx), %rax
movl 0x48(%rbx), %ecx
shrq %cl, %rax
movq 0x48(%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), %r14d
cmpl $0xf, %r14d
ja 0xd4cd3
movslq %r15d, %rax
incl %r15d
movq 0x10(%rsp), %rcx
movl %r14d, (%rcx,%rax,4)
testl %r14d, %r14d
movl 0x8(%rsp), %eax
cmovnel %r14d, %eax
movl %eax, 0x8(%rsp)
xorl %ecx, %ecx
jmp 0xd4d59
movl %r13d, 0xc(%rsp)
leal -0x10(%r14), %eax
leaq 0x55940(%rip), %rcx     # 0x12a623
movzbl (%rax,%rcx), %esi
leaq 0x55938(%rip), %rcx     # 0x12a626
movzbl (%rax,%rcx), %r13d
movq %r12, %rdi
callq 0xf0d7f
leal (%rax,%r13), %edi
leal (%rdi,%r15), %edx
movl $0x2, %ecx
movl %ebp, %r9d
cmpl %ebp, %edx
jle 0xd4d19
movl %r9d, %ebp
movl 0xc(%rsp), %r13d
jmp 0xd4d59
movq %r13, %r10
xorl %ecx, %ecx
cmpl $0x10, %r14d
movl $0x0, %esi
cmovel 0x8(%rsp), %esi
testl %edi, %edi
movl 0xc(%rsp), %r13d
jle 0xd4d56
movslq %r15d, %rdi
movq 0x10(%rsp), %r8
leaq (%r8,%rdi,4), %rdi
addl %r10d, %eax
incl %eax
movl %esi, (%rdi)
addq $0x4, %rdi
decl %eax
cmpl $0x1, %eax
jg 0xd4d46
movl %edx, %r15d
movl %r9d, %ebp
testl %ecx, %ecx
je 0xd4c5e
cmpl $0x2, %ecx
jne 0xd4dd4
leaq 0x28(%rsp), %rdi
callq 0xf1647
movl (%rbx), %eax
cmpl $0x5, %eax
je 0xd4d7b
testl %eax, %eax
jne 0xd4d81
movl $0x3, (%rbx)
xorl %ebp, %ebp
movq 0x10(%rsp), %r15
xorl %eax, %eax
testb %bpl, %bpl
je 0xd4da5
movq 0x20(%rsp), %rdi
movl $0x8, %esi
movq %r15, %rdx
movl 0x1c(%rsp), %ecx
callq 0xf0f5e
testl %eax, %eax
setne %cl
testb %cl, %bpl
jne 0xd4dc2
movl (%rbx), %ecx
xorl %eax, %eax
cmpl $0x5, %ecx
je 0xd4dbc
testl %ecx, %ecx
jne 0xd4dc2
movl $0x3, (%rbx)
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x28(%rsp), %rdi
callq 0xf1647
movq 0x10(%rsp), %r15
jmp 0xd4b5f
leaq 0x55a79(%rip), %rdi     # 0x12a868
leaq 0x558c3(%rip), %rsi     # 0x12a6b9
leaq 0x55a8e(%rip), %rcx     # 0x12a88b
movl $0x159, %edx            # imm = 0x159
callq 0x55710