// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libwebp/src/dec/vp8l_dec.c
// Function: DecodeImageData
static int DecodeImageData(VP8LDecoder* const dec, uint32_t* const data,
                           int width, int height, int last_row,
                           ProcessRowsFunc process_func) {
  int row = dec->last_pixel_ / width;
  int col = dec->last_pixel_ % width;
  VP8LBitReader* const br = &dec->br_;
  VP8LMetadata* const hdr = &dec->hdr_;
  uint32_t* src = data + dec->last_pixel_;
  uint32_t* last_cached = src;
  uint32_t* const src_end = data + width * height;     // End of data
  uint32_t* const src_last = data + width * last_row;  // Last pixel to decode
  const int len_code_limit = NUM_LITERAL_CODES + NUM_LENGTH_CODES;
  const int color_cache_limit = len_code_limit + hdr->color_cache_size_;
  int next_sync_row = dec->incremental_ ? row : 1 << 24;
  VP8LColorCache* const color_cache =
      (hdr->color_cache_size_ > 0) ? &hdr->color_cache_ : NULL;
  const int mask = hdr->huffman_mask_;
  const HTreeGroup* htree_group =
      (src < src_last) ? GetHtreeGroupForPos(hdr, col, row) : NULL;
  assert(dec->last_row_ < last_row);
  assert(src_last <= src_end);

  while (src < src_last) {
    int code;
    if (row >= next_sync_row) {
      SaveState(dec, (int)(src - data));
      next_sync_row = row + SYNC_EVERY_N_ROWS;
    }
    // Only update when changing tile. Note we could use this test:
    // if "((((prev_col ^ col) | prev_row ^ row)) > mask)" -> tile changed
    // but that's actually slower and needs storing the previous col/row.
    if ((col & mask) == 0) {
      htree_group = GetHtreeGroupForPos(hdr, col, row);
    }
    assert(htree_group != NULL);
    if (htree_group->is_trivial_code) {
      *src = htree_group->literal_arb;
      goto AdvanceByOne;
    }
    VP8LFillBitWindow(br);
    if (htree_group->use_packed_table) {
      code = ReadPackedSymbols(htree_group, br, src);
      if (VP8LIsEndOfStream(br)) break;
      if (code == PACKED_NON_LITERAL_CODE) goto AdvanceByOne;
    } else {
      code = ReadSymbol(htree_group->htrees[GREEN], br);
    }
    if (VP8LIsEndOfStream(br)) break;
    if (code < NUM_LITERAL_CODES) {  // Literal
      if (htree_group->is_trivial_literal) {
        *src = htree_group->literal_arb | (code << 8);
      } else {
        int red, blue, alpha;
        red = ReadSymbol(htree_group->htrees[RED], br);
        VP8LFillBitWindow(br);
        blue = ReadSymbol(htree_group->htrees[BLUE], br);
        alpha = ReadSymbol(htree_group->htrees[ALPHA], br);
        if (VP8LIsEndOfStream(br)) break;
        *src = ((uint32_t)alpha << 24) | (red << 16) | (code << 8) | blue;
      }
    AdvanceByOne:
      ++src;
      ++col;
      if (col >= width) {
        col = 0;
        ++row;
        if (process_func != NULL) {
          if (row <= last_row && (row % NUM_ARGB_CACHE_ROWS == 0)) {
            process_func(dec, row);
          }
        }
        if (color_cache != NULL) {
          while (last_cached < src) {
            VP8LColorCacheInsert(color_cache, *last_cached++);
          }
        }
      }
    } else if (code < len_code_limit) {  // Backward reference
      int dist_code, dist;
      const int length_sym = code - NUM_LITERAL_CODES;
      const int length = GetCopyLength(length_sym, br);
      const int dist_symbol = ReadSymbol(htree_group->htrees[DIST], br);
      VP8LFillBitWindow(br);
      dist_code = GetCopyDistance(dist_symbol, br);
      dist = PlaneCodeToDistance(width, dist_code);

      if (VP8LIsEndOfStream(br)) break;
      if (src - data < (ptrdiff_t)dist || src_end - src < (ptrdiff_t)length) {
        goto Error;
      } else {
        CopyBlock32b(src, dist, length);
      }
      src += length;
      col += length;
      while (col >= width) {
        col -= width;
        ++row;
        if (process_func != NULL) {
          if (row <= last_row && (row % NUM_ARGB_CACHE_ROWS == 0)) {
            process_func(dec, row);
          }
        }
      }
      // Because of the check done above (before 'src' was incremented by
      // 'length'), the following holds true.
      assert(src <= src_end);
      if (col & mask) htree_group = GetHtreeGroupForPos(hdr, col, row);
      if (color_cache != NULL) {
        while (last_cached < src) {
          VP8LColorCacheInsert(color_cache, *last_cached++);
        }
      }
    } else if (code < color_cache_limit) {  // Color cache
      const int key = code - len_code_limit;
      assert(color_cache != NULL);
      while (last_cached < src) {
        VP8LColorCacheInsert(color_cache, *last_cached++);
      }
      *src = VP8LColorCacheLookup(color_cache, key);
      goto AdvanceByOne;
    } else {  // Not reached
      goto Error;
    }
  }

  br->eos_ = VP8LIsEndOfStream(br);
  // In incremental decoding:
  // br->eos_ && src < src_last: if 'br' reached the end of the buffer and
  // 'src_last' has not been reached yet, there is not enough data. 'dec' has to
  // be reset until there is more data.
  // !br->eos_ && src < src_last: this cannot happen as either the buffer is
  // fully read, either enough has been read to reach 'src_last'.
  // src >= src_last: 'src_last' is reached, all is fine. 'src' can actually go
  // beyond 'src_last' in case the image is cropped and an LZ77 goes further.
  // The buffer might have been enough or there is some left. 'br->eos_' does
  // not matter.
  assert(!dec->incremental_ || (br->eos_ && src < src_last) || src >= src_last);
  if (dec->incremental_ && br->eos_ && src < src_last) {
    RestoreState(dec);
  } else if ((dec->incremental_ && src >= src_last) || !br->eos_) {
    // Process the remaining rows corresponding to last row-block.
    if (process_func != NULL) {
      process_func(dec, row > last_row ? last_row : row);
    }
    dec->status_ = VP8_STATUS_OK;
    dec->last_pixel_ = (int)(src - data);  // end-of-scan marker
  } else {
    // if not incremental, and we are past the end of buffer (eos_=1), then this
    // is a real bitstream error.
    goto Error;
  }
  return 1;

 Error:
  return VP8LSetError(dec, VP8_STATUS_BITSTREAM_ERROR);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x90(%rax), %eax
cltd
idivl -0x1c(%rbp)
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movl 0x90(%rax), %eax
cltd
idivl -0x1c(%rbp)
movl %edx, -0x38(%rbp)
movq -0x10(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
addq $0x98, %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq 0x90(%rcx), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
imull -0x20(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
imull -0x24(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movl $0x118, -0x6c(%rbp)     # imm = 0x118
movq -0x48(%rbp), %rax
movl (%rax), %eax
addl $0x118, %eax            # imm = 0x118
movl %eax, -0x70(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x145e5b
movl -0x34(%rbp), %eax
movl %eax, -0xbc(%rbp)
jmp 0x145e68
movl $0x1000000, %eax        # imm = 0x1000000
movl %eax, -0xbc(%rbp)
jmp 0x145e68
movl -0xbc(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x48(%rbp), %rax
cmpl $0x0, (%rax)
jle 0x145e8b
movq -0x48(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xc8(%rbp)
jmp 0x145e96
xorl %eax, %eax
movq %rax, -0xc8(%rbp)
jmp 0x145e96
movq -0xc8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x48(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x84(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x68(%rbp), %rax
jae 0x145ed0
movq -0x48(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x34(%rbp), %edx
callq 0x147ba0
movq %rax, -0xd0(%rbp)
jmp 0x145edb
xorl %eax, %eax
movq %rax, -0xd0(%rbp)
jmp 0x145edb
movq -0xd0(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rax
movl 0x8c(%rax), %eax
cmpl -0x24(%rbp), %eax
jge 0x145efa
jmp 0x145f19
leaq 0x77d01(%rip), %rdi     # 0x1bdc02
leaq 0x775e1(%rip), %rsi     # 0x1bd4e9
movl $0x485, %edx            # imm = 0x485
leaq 0x77d08(%rip), %rcx     # 0x1bdc1c
callq 0x598a0
movq -0x68(%rbp), %rax
cmpq -0x60(%rbp), %rax
ja 0x145f25
jmp 0x145f44
leaq 0x77d49(%rip), %rdi     # 0x1bdc75
leaq 0x775b6(%rip), %rsi     # 0x1bd4e9
movl $0x486, %edx            # imm = 0x486
leaq 0x77cdd(%rip), %rcx     # 0x1bdc1c
callq 0x598a0
jmp 0x145f46
movq -0x50(%rbp), %rax
cmpq -0x68(%rbp), %rax
jae 0x146444
movl -0x34(%rbp), %eax
cmpl -0x74(%rbp), %eax
jl 0x145f7f
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
sarq $0x2, %rax
movl %eax, %esi
callq 0x1483a0
movl -0x34(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x74(%rbp)
movl -0x38(%rbp), %eax
andl -0x84(%rbp), %eax
cmpl $0x0, %eax
jne 0x145fa3
movq -0x48(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x34(%rbp), %edx
callq 0x147ba0
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0x145faf
jmp 0x145fce
leaq 0x77a1a(%rip), %rdi     # 0x1bd9d0
leaq 0x7752c(%rip), %rsi     # 0x1bd4e9
movl $0x494, %edx            # imm = 0x494
leaq 0x77c53(%rip), %rcx     # 0x1bdc1c
callq 0x598a0
movq -0x90(%rbp), %rax
cmpl $0x0, 0x30(%rax)
je 0x145ff0
movq -0x90(%rbp), %rax
movl 0x2c(%rax), %ecx
movq -0x50(%rbp), %rax
movl %ecx, (%rax)
jmp 0x146143
movq -0x40(%rbp), %rdi
callq 0x147300
movq -0x90(%rbp), %rax
cmpl $0x0, 0x34(%rax)
je 0x146043
movq -0x90(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x148440
movl %eax, -0x94(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1480e0
cmpl $0x0, %eax
je 0x146033
jmp 0x146444
cmpl $0x0, -0x94(%rbp)
jne 0x146041
jmp 0x146143
jmp 0x14605c
movq -0x90(%rbp), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rsi
callq 0x147c20
movl %eax, -0x94(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1480e0
cmpl $0x0, %eax
je 0x14606f
jmp 0x146444
cmpl $0x100, -0x94(%rbp)     # imm = 0x100
jge 0x1461d6
movq -0x90(%rbp), %rax
cmpl $0x0, 0x28(%rax)
je 0x1460ac
movq -0x90(%rbp), %rax
movl 0x2c(%rax), %ecx
movl -0x94(%rbp), %eax
shll $0x8, %eax
orl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, (%rax)
jmp 0x146141
movq -0x90(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x40(%rbp), %rsi
callq 0x147c20
movl %eax, -0x98(%rbp)
movq -0x40(%rbp), %rdi
callq 0x147300
movq -0x90(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x40(%rbp), %rsi
callq 0x147c20
movl %eax, -0x9c(%rbp)
movq -0x90(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x40(%rbp), %rsi
callq 0x147c20
movl %eax, -0xa0(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1480e0
cmpl $0x0, %eax
je 0x146116
jmp 0x146444
movl -0xa0(%rbp), %ecx
shll $0x18, %ecx
movl -0x98(%rbp), %eax
shll $0x10, %eax
orl %eax, %ecx
movl -0x94(%rbp), %eax
shll $0x8, %eax
orl %eax, %ecx
orl -0x9c(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, (%rax)
jmp 0x146143
movq -0x50(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x1461d1
movl $0x0, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x14619e
movl -0x34(%rbp), %eax
cmpl -0x24(%rbp), %eax
jg 0x14619c
movl -0x34(%rbp), %eax
movl $0x10, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x14619c
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
callq *%rax
jmp 0x14619e
cmpq $0x0, -0x80(%rbp)
je 0x1461cf
jmp 0x1461a7
movq -0x58(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x1461cd
movq -0x80(%rbp), %rdi
movq -0x58(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x58(%rbp)
movl (%rax), %esi
callq 0x148520
jmp 0x1461a7
jmp 0x1461cf
jmp 0x1461d1
jmp 0x14643f
cmpl $0x118, -0x94(%rbp)     # imm = 0x118
jge 0x1463b0
movl -0x94(%rbp), %eax
subl $0x100, %eax            # imm = 0x100
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %edi
movq -0x40(%rbp), %rsi
callq 0x147ec0
movl %eax, -0xb0(%rbp)
movq -0x90(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x40(%rbp), %rsi
callq 0x147c20
movl %eax, -0xb4(%rbp)
movq -0x40(%rbp), %rdi
callq 0x147300
movl -0xb4(%rbp), %edi
movq -0x40(%rbp), %rsi
callq 0x147ef0
movl %eax, -0xa4(%rbp)
movl -0x1c(%rbp), %edi
movl -0xa4(%rbp), %esi
callq 0x147f60
movl %eax, -0xa8(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1480e0
cmpl $0x0, %eax
je 0x14626b
jmp 0x146444
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
sarq $0x2, %rax
movslq -0xa8(%rbp), %rcx
cmpq %rcx, %rax
jl 0x1462a1
movq -0x60(%rbp), %rax
movq -0x50(%rbp), %rcx
subq %rcx, %rax
sarq $0x2, %rax
movslq -0xb0(%rbp), %rcx
cmpq %rcx, %rax
jge 0x1462a6
jmp 0x14656c
movq -0x50(%rbp), %rdi
movl -0xa8(%rbp), %esi
movl -0xb0(%rbp), %edx
callq 0x148560
movl -0xb0(%rbp), %ecx
movq -0x50(%rbp), %rax
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movl -0xb0(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x14632b
movl -0x1c(%rbp), %ecx
movl -0x38(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x146329
movl -0x34(%rbp), %eax
cmpl -0x24(%rbp), %eax
jg 0x146327
movl -0x34(%rbp), %eax
movl $0x10, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x146327
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
callq *%rax
jmp 0x146329
jmp 0x1462df
movq -0x50(%rbp), %rax
cmpq -0x60(%rbp), %rax
ja 0x146337
jmp 0x146356
leaq 0x7794b(%rip), %rdi     # 0x1bdc89
leaq 0x771a4(%rip), %rsi     # 0x1bd4e9
movl $0x4db, %edx            # imm = 0x4DB
leaq 0x778cb(%rip), %rcx     # 0x1bdc1c
callq 0x598a0
movl -0x38(%rbp), %eax
andl -0x84(%rbp), %eax
cmpl $0x0, %eax
je 0x14637a
movq -0x48(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x34(%rbp), %edx
callq 0x147ba0
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0x1463ab
jmp 0x146383
movq -0x58(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x1463a9
movq -0x80(%rbp), %rdi
movq -0x58(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x58(%rbp)
movl (%rax), %esi
callq 0x148520
jmp 0x146383
jmp 0x1463ab
jmp 0x14643d
movl -0x94(%rbp), %eax
cmpl -0x70(%rbp), %eax
jge 0x146438
movl -0x94(%rbp), %eax
subl $0x118, %eax            # imm = 0x118
movl %eax, -0xb8(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0x1463d5
jmp 0x1463f4
leaq 0x778bc(%rip), %rdi     # 0x1bdc98
leaq 0x77106(%rip), %rsi     # 0x1bd4e9
movl $0x4e4, %edx            # imm = 0x4E4
leaq 0x7782d(%rip), %rcx     # 0x1bdc1c
callq 0x598a0
jmp 0x1463f6
movq -0x58(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x14641c
movq -0x80(%rbp), %rdi
movq -0x58(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x58(%rbp)
movl (%rax), %esi
callq 0x148520
jmp 0x1463f6
movq -0x80(%rbp), %rdi
movl -0xb8(%rbp), %esi
callq 0x148640
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, (%rax)
jmp 0x146143
jmp 0x14656c
jmp 0x14643f
jmp 0x145f46
movq -0x40(%rbp), %rdi
callq 0x1480e0
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x14647e
movq -0x40(%rbp), %rax
cmpl $0x0, 0x24(%rax)
je 0x146474
movq -0x50(%rbp), %rax
cmpq -0x68(%rbp), %rax
jb 0x14647e
movq -0x50(%rbp), %rax
cmpq -0x68(%rbp), %rax
jb 0x146480
jmp 0x14649f
leaq 0x77825(%rip), %rdi     # 0x1bdcac
leaq 0x7705b(%rip), %rsi     # 0x1bd4e9
movl $0x4fa, %edx            # imm = 0x4FA
leaq 0x77782(%rip), %rcx     # 0x1bdc1c
callq 0x598a0
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x1464cb
movq -0x40(%rbp), %rax
cmpl $0x0, 0x24(%rax)
je 0x1464cb
movq -0x50(%rbp), %rax
cmpq -0x68(%rbp), %rax
jae 0x1464cb
movq -0x10(%rbp), %rdi
callq 0x1486a0
jmp 0x146563
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x1464df
movq -0x50(%rbp), %rax
cmpq -0x68(%rbp), %rax
jae 0x1464e9
movq -0x40(%rbp), %rax
cmpl $0x0, 0x24(%rax)
jne 0x14655f
cmpq $0x0, -0x30(%rbp)
je 0x146538
movq -0x30(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x24(%rbp), %eax
jle 0x146519
movl -0x24(%rbp), %eax
movl %eax, -0xe4(%rbp)
jmp 0x146522
movl -0x34(%rbp), %eax
movl %eax, -0xe4(%rbp)
movq -0xe0(%rbp), %rax
movq -0xd8(%rbp), %rdi
movl -0xe4(%rbp), %esi
callq *%rax
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
sarq $0x2, %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x90(%rax)
jmp 0x146561
jmp 0x14656c
jmp 0x146563
movl $0x1, -0x4(%rbp)
jmp 0x14657d
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x144bc0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax)