// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libwebp/src/dec/vp8l_dec.c
// Function: ReadHuffmanCodesHelper
int ReadHuffmanCodesHelper(int color_cache_bits, int num_htree_groups,
                           int num_htree_groups_max, const int* const mapping,
                           VP8LDecoder* const dec,
                           HuffmanTables* const huffman_tables,
                           HTreeGroup** const htree_groups) {
  int i, j, ok = 0;
  const int max_alphabet_size =
      kAlphabetSize[0] + ((color_cache_bits > 0) ? 1 << color_cache_bits : 0);
  const int table_size = kTableSize[color_cache_bits];
  int* code_lengths = NULL;

  if ((mapping == NULL && num_htree_groups != num_htree_groups_max) ||
      num_htree_groups > num_htree_groups_max) {
    goto Error;
  }

  code_lengths =
      (int*)WebPSafeCalloc((uint64_t)max_alphabet_size, sizeof(*code_lengths));
  *htree_groups = VP8LHtreeGroupsNew(num_htree_groups);

  if (*htree_groups == NULL || code_lengths == NULL ||
      !VP8LHuffmanTablesAllocate(num_htree_groups * table_size,
                                 huffman_tables)) {
    VP8LSetError(dec, VP8_STATUS_OUT_OF_MEMORY);
    goto Error;
  }

  for (i = 0; i < num_htree_groups_max; ++i) {
    // If the index "i" is unused in the Huffman image, just make sure the
    // coefficients are valid but do not store them.
    if (mapping != NULL && mapping[i] == -1) {
      for (j = 0; j < HUFFMAN_CODES_PER_META_CODE; ++j) {
        int alphabet_size = kAlphabetSize[j];
        if (j == 0 && color_cache_bits > 0) {
          alphabet_size += (1 << color_cache_bits);
        }
        // Passing in NULL so that nothing gets filled.
        if (!ReadHuffmanCode(alphabet_size, dec, code_lengths, NULL)) {
          goto Error;
        }
      }
    } else {
      HTreeGroup* const htree_group =
          &(*htree_groups)[(mapping == NULL) ? i : mapping[i]];
      HuffmanCode** const htrees = htree_group->htrees;
      int size;
      int total_size = 0;
      int is_trivial_literal = 1;
      int max_bits = 0;
      for (j = 0; j < HUFFMAN_CODES_PER_META_CODE; ++j) {
        int alphabet_size = kAlphabetSize[j];
        if (j == 0 && color_cache_bits > 0) {
          alphabet_size += (1 << color_cache_bits);
        }
        size =
            ReadHuffmanCode(alphabet_size, dec, code_lengths, huffman_tables);
        htrees[j] = huffman_tables->curr_segment->curr_table;
        if (size == 0) {
          goto Error;
        }
        if (is_trivial_literal && kLiteralMap[j] == 1) {
          is_trivial_literal = (htrees[j]->bits == 0);
        }
        total_size += htrees[j]->bits;
        huffman_tables->curr_segment->curr_table += size;
        if (j <= ALPHA) {
          int local_max_bits = code_lengths[0];
          int k;
          for (k = 1; k < alphabet_size; ++k) {
            if (code_lengths[k] > local_max_bits) {
              local_max_bits = code_lengths[k];
            }
          }
          max_bits += local_max_bits;
        }
      }
      htree_group->is_trivial_literal = is_trivial_literal;
      htree_group->is_trivial_code = 0;
      if (is_trivial_literal) {
        const int red = htrees[RED][0].value;
        const int blue = htrees[BLUE][0].value;
        const int alpha = htrees[ALPHA][0].value;
        htree_group->literal_arb = ((uint32_t)alpha << 24) | (red << 16) | blue;
        if (total_size == 0 && htrees[GREEN][0].value < NUM_LITERAL_CODES) {
          htree_group->is_trivial_code = 1;
          htree_group->literal_arb |= htrees[GREEN][0].value << 8;
        }
      }
      htree_group->use_packed_table =
          !htree_group->is_trivial_code && (max_bits < HUFFMAN_PACKED_BITS);
      if (htree_group->use_packed_table) BuildPackedTable(htree_group);
    }
  }
  ok = 1;

 Error:
  WebPSafeFree(code_lengths);
  if (!ok) {
    VP8LHuffmanTablesDeallocate(huffman_tables);
    VP8LHtreeGroupsFree(*htree_groups);
    *htree_groups = NULL;
  }
  return ok;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq 0x10(%rbp), %rax
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movl $0x0, -0x34(%rbp)
movzwl 0x78cae(%rip), %eax     # 0x1bd410
movl %eax, -0x8c(%rbp)
cmpl $0x0, -0x4(%rbp)
jle 0x144780
movl -0x4(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x90(%rbp)
jmp 0x14478a
xorl %eax, %eax
movl %eax, -0x90(%rbp)
jmp 0x14478a
movl -0x8c(%rbp), %eax
movl -0x90(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x38(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x78c7a(%rip), %rax     # 0x1bd420
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x3c(%rbp)
movq $0x0, -0x48(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x1447c4
movl -0x8(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x1447cc
movl -0x8(%rbp), %eax
cmpl -0xc(%rbp), %eax
jle 0x1447d1
jmp 0x144b7b
movslq -0x38(%rbp), %rdi
movl $0x4, %esi
callq 0x5a9f0
movq %rax, -0x48(%rbp)
movl -0x8(%rbp), %edi
callq 0x182790
movq %rax, %rcx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movq 0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x14481b
cmpq $0x0, -0x48(%rbp)
je 0x14481b
movl -0x8(%rbp), %edi
imull -0x3c(%rbp), %edi
movq -0x28(%rbp), %rsi
callq 0x1830c0
cmpl $0x0, %eax
jne 0x14482e
movq -0x20(%rbp), %rdi
movl $0x1, %esi
callq 0x144bc0
jmp 0x144b7b
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x144b74
cmpq $0x0, -0x18(%rbp)
je 0x1448c1
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,4)
jne 0x1448c1
movl $0x0, -0x30(%rbp)
cmpl $0x5, -0x30(%rbp)
jge 0x1448bc
movslq -0x30(%rbp), %rcx
leaq 0x78ba2(%rip), %rax     # 0x1bd410
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x30(%rbp)
jne 0x144891
cmpl $0x0, -0x4(%rbp)
jle 0x144891
movl -0x4(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
addl -0x4c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %edi
movq -0x20(%rbp), %rsi
movq -0x48(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x144bf0
cmpl $0x0, %eax
jne 0x1448af
jmp 0x144b7b
jmp 0x1448b1
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x14485d
jmp 0x144b64
movq 0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x1448e1
movl -0x2c(%rbp), %eax
movl %eax, -0x9c(%rbp)
jmp 0x1448f2
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x9c(%rbp)
movq -0x98(%rbp), %rax
movl -0x9c(%rbp), %ecx
movslq %ecx, %rcx
imulq $0x238, %rcx, %rcx      # imm = 0x238
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x68(%rbp)
movl $0x1, -0x6c(%rbp)
movl $0x0, -0x70(%rbp)
movl $0x0, -0x30(%rbp)
cmpl $0x5, -0x30(%rbp)
jge 0x144a71
movslq -0x30(%rbp), %rcx
leaq 0x78ac7(%rip), %rax     # 0x1bd410
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x74(%rbp)
cmpl $0x0, -0x30(%rbp)
jne 0x14496c
cmpl $0x0, -0x4(%rbp)
jle 0x14496c
movl -0x4(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
addl -0x74(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %edi
movq -0x20(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x144bf0
movl %eax, -0x64(%rbp)
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rdx
movq -0x60(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
cmpl $0x0, -0x64(%rbp)
jne 0x1449a6
jmp 0x144b7b
cmpl $0x0, -0x6c(%rbp)
je 0x1449dd
movslq -0x30(%rbp), %rcx
leaq 0x78a81(%rip), %rax     # 0x1bd438
movzbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x1449dd
movq -0x60(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x6c(%rbp)
movq -0x60(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movzbl (%rax), %eax
addl -0x68(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x64(%rbp), %edx
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rcx
movslq %edx, %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
movq %rcx, 0x8(%rax)
cmpl $0x3, -0x30(%rbp)
jg 0x144a61
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x78(%rbp)
movl $0x1, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
cmpl -0x74(%rbp), %eax
jge 0x144a58
movq -0x48(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x78(%rbp), %eax
jle 0x144a4b
movq -0x48(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x78(%rbp)
jmp 0x144a4d
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x144a25
movl -0x78(%rbp), %eax
addl -0x70(%rbp), %eax
movl %eax, -0x70(%rbp)
jmp 0x144a63
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x144934
movl -0x6c(%rbp), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x58(%rbp), %rax
movl $0x0, 0x30(%rax)
cmpl $0x0, -0x6c(%rbp)
je 0x144b1e
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
movzwl 0x2(%rax), %eax
movl %eax, -0x80(%rbp)
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
movzwl 0x2(%rax), %eax
movl %eax, -0x84(%rbp)
movq -0x60(%rbp), %rax
movq 0x18(%rax), %rax
movzwl 0x2(%rax), %eax
movl %eax, -0x88(%rbp)
movl -0x88(%rbp), %ecx
shll $0x18, %ecx
movl -0x80(%rbp), %eax
shll $0x10, %eax
orl %eax, %ecx
orl -0x84(%rbp), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x2c(%rax)
cmpl $0x0, -0x68(%rbp)
jne 0x144b1c
movq -0x60(%rbp), %rax
movq (%rax), %rax
movzwl 0x2(%rax), %eax
cmpl $0x100, %eax            # imm = 0x100
jge 0x144b1c
movq -0x58(%rbp), %rax
movl $0x1, 0x30(%rax)
movq -0x60(%rbp), %rax
movq (%rax), %rax
movzwl 0x2(%rax), %ecx
shll $0x8, %ecx
movq -0x58(%rbp), %rax
orl 0x2c(%rax), %ecx
movl %ecx, 0x2c(%rax)
jmp 0x144b1e
movq -0x58(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x30(%rcx)
movb %al, -0x9d(%rbp)
jne 0x144b3d
cmpl $0x6, -0x70(%rbp)
setl %al
movb %al, -0x9d(%rbp)
movb -0x9d(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x34(%rax)
movq -0x58(%rbp), %rax
cmpl $0x0, 0x34(%rax)
je 0x144b62
movq -0x58(%rbp), %rdi
callq 0x144e10
jmp 0x144b64
jmp 0x144b66
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x144835
movl $0x1, -0x34(%rbp)
movq -0x48(%rbp), %rdi
callq 0x5b920
cmpl $0x0, -0x34(%rbp)
jne 0x144baa
movq -0x28(%rbp), %rdi
callq 0x183150
movq 0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x182800
movq 0x10(%rbp), %rax
movq $0x0, (%rax)
movl -0x34(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)