// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libwebp/src/dec/vp8l_dec.c
// Function: ReadHuffmanCodeLengths
static int ReadHuffmanCodeLengths(
    VP8LDecoder* const dec, const int* const code_length_code_lengths,
    int num_symbols, int* const code_lengths) {
  int ok = 0;
  VP8LBitReader* const br = &dec->br_;
  int symbol;
  int max_symbol;
  int prev_code_len = DEFAULT_CODE_LENGTH;
  HuffmanTables tables;

  if (!VP8LHuffmanTablesAllocate(1 << LENGTHS_TABLE_BITS, &tables) ||
      !VP8LBuildHuffmanTable(&tables, LENGTHS_TABLE_BITS,
                             code_length_code_lengths, NUM_CODE_LENGTH_CODES)) {
    goto End;
  }

  if (VP8LReadBits(br, 1)) {    // use length
    const int length_nbits = 2 + 2 * VP8LReadBits(br, 3);
    max_symbol = 2 + VP8LReadBits(br, length_nbits);
    if (max_symbol > num_symbols) {
      goto End;
    }
  } else {
    max_symbol = num_symbols;
  }

  symbol = 0;
  while (symbol < num_symbols) {
    const HuffmanCode* p;
    int code_len;
    if (max_symbol-- == 0) break;
    VP8LFillBitWindow(br);
    p = &tables.curr_segment->start[VP8LPrefetchBits(br) & LENGTHS_TABLE_MASK];
    VP8LSetBitPos(br, br->bit_pos_ + p->bits);
    code_len = p->value;
    if (code_len < kCodeLengthLiterals) {
      code_lengths[symbol++] = code_len;
      if (code_len != 0) prev_code_len = code_len;
    } else {
      const int use_prev = (code_len == kCodeLengthRepeatCode);
      const int slot = code_len - kCodeLengthLiterals;
      const int extra_bits = kCodeLengthExtraBits[slot];
      const int repeat_offset = kCodeLengthRepeatOffsets[slot];
      int repeat = VP8LReadBits(br, extra_bits) + repeat_offset;
      if (symbol + repeat > num_symbols) {
        goto End;
      } else {
        const int length = use_prev ? prev_code_len : 0;
        while (repeat-- > 0) code_lengths[symbol++] = length;
      }
    }
  }
  ok = 1;

 End:
  VP8LHuffmanTablesDeallocate(&tables);
  if (!ok) return VP8LSetError(dec, VP8_STATUS_BITSTREAM_ERROR);
  return ok;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x38(%rbp)
movl $0x8, -0x44(%rbp)
movl $0x80, %edi
leaq -0x70(%rbp), %rsi
callq 0x1830c0
cmpl $0x0, %eax
je 0x1470c3
movq -0x18(%rbp), %rdx
leaq -0x70(%rbp), %rdi
movl $0x7, %esi
movl $0x13, %ecx
callq 0x182830
cmpl $0x0, %eax
jne 0x1470c8
jmp 0x1472c7
movq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x1824b0
cmpl $0x0, %eax
je 0x147112
movq -0x38(%rbp), %rdi
movl $0x3, %esi
callq 0x1824b0
shll %eax
addl $0x2, %eax
movl %eax, -0x74(%rbp)
movq -0x38(%rbp), %rdi
movl -0x74(%rbp), %esi
callq 0x1824b0
addl $0x2, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jle 0x147110
jmp 0x1472c7
jmp 0x147118
movl -0x1c(%rbp), %eax
movl %eax, -0x40(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x1472c0
movl -0x40(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x40(%rbp)
cmpl $0x0, %eax
jne 0x147140
jmp 0x1472c0
movq -0x38(%rbp), %rdi
callq 0x147300
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
movq -0x38(%rbp), %rdi
callq 0x147330
movl %eax, %ecx
movq -0xa8(%rbp), %rax
andl $0x7f, %ecx
movl %ecx, %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x38(%rbp), %rdi
movq -0x38(%rbp), %rax
movl 0x20(%rax), %esi
movq -0x80(%rbp), %rax
movzbl (%rax), %eax
addl %eax, %esi
callq 0x147350
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %eax
movl %eax, -0x84(%rbp)
cmpl $0x10, -0x84(%rbp)
jge 0x1471db
movl -0x84(%rbp), %edx
movq -0x28(%rbp), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x3c(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
cmpl $0x0, -0x84(%rbp)
je 0x1471d6
movl -0x84(%rbp), %eax
movl %eax, -0x44(%rbp)
jmp 0x1472bb
cmpl $0x10, -0x84(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x88(%rbp)
movl -0x84(%rbp), %eax
subl $0x10, %eax
movl %eax, -0x8c(%rbp)
movslq -0x8c(%rbp), %rcx
leaq 0x76246(%rip), %rax     # 0x1bd453
movzbl (%rax,%rcx), %eax
movl %eax, -0x90(%rbp)
movslq -0x8c(%rbp), %rcx
leaq 0x76231(%rip), %rax     # 0x1bd456
movzbl (%rax,%rcx), %eax
movl %eax, -0x94(%rbp)
movq -0x38(%rbp), %rdi
movl -0x90(%rbp), %esi
callq 0x1824b0
addl -0x94(%rbp), %eax
movl %eax, -0x98(%rbp)
movl -0x3c(%rbp), %eax
addl -0x98(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jle 0x14725a
jmp 0x1472c7
cmpl $0x0, -0x88(%rbp)
je 0x14726e
movl -0x44(%rbp), %eax
movl %eax, -0xac(%rbp)
jmp 0x147278
xorl %eax, %eax
movl %eax, -0xac(%rbp)
jmp 0x147278
movl -0xac(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0x98(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x98(%rbp)
cmpl $0x0, %eax
jle 0x1472b7
movl -0x9c(%rbp), %edx
movq -0x28(%rbp), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x3c(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x147284
jmp 0x1472b9
jmp 0x1472bb
jmp 0x14711f
movl $0x1, -0x2c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x183150
cmpl $0x0, -0x2c(%rbp)
jne 0x1472e9
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x144bc0
movl %eax, -0x4(%rbp)
jmp 0x1472ef
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax,%rax)