// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xa0, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x1824b0
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x8(%rbp), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x5a200
cmpl $0x0, -0x34(%rbp)
je 0x144cd7
movq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x1824b0
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x1824b0
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rdi
movl -0x3c(%rbp), %ecx
movl $0x8, %esi
movl $0x1, %eax
cmpl $0x0, %ecx
cmovel %eax, %esi
callq 0x1824b0
movl %eax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
cmpl $0x2, -0x38(%rbp)
jne 0x144ccb
movq -0x30(%rbp), %rdi
movl $0x8, %esi
callq 0x1824b0
movl %eax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movl $0x1, -0x24(%rbp)
jmp 0x144d88
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x4c, %edx
callq 0x5a200
movq -0x30(%rbp), %rdi
movl $0x4, %esi
callq 0x1824b0
addl $0x4, %eax
movl %eax, -0x94(%rbp)
cmpl $0x13, -0x94(%rbp)
jg 0x144d0c
jmp 0x144d2b
leaq 0x78985(%rip), %rdi     # 0x1bd698
leaq 0x787cf(%rip), %rsi     # 0x1bd4e9
movl $0x159, %edx            # imm = 0x159
leaq 0x78995(%rip), %rcx     # 0x1bd6bb
callq 0x598a0
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0x144d6e
movq -0x30(%rbp), %rdi
movl $0x3, %esi
callq 0x1824b0
movl %eax, %ecx
movslq -0x44(%rbp), %rdx
leaq 0x786e8(%rip), %rax     # 0x1bd440
movzbl (%rax,%rdx), %eax
movl %ecx, -0x90(%rbp,%rax,4)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x144d32
movq -0x10(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movl -0x8(%rbp), %edx
movq -0x18(%rbp), %rcx
callq 0x147060
movl %eax, -0x24(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x24(%rbp)
movb %al, -0x95(%rbp)
je 0x144da9
movq -0x30(%rbp), %rax
cmpl $0x0, 0x24(%rax)
setne %al
xorb $-0x1, %al
movb %al, -0x95(%rbp)
movb -0x95(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x144dd5
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl -0x8(%rbp), %ecx
movl $0x8, %esi
callq 0x182830
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x144de1
cmpl $0x0, -0x28(%rbp)
jne 0x144df4
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x144bc0
movl %eax, -0x4(%rbp)
jmp 0x144dfa
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)