// File: /workspace/github_c_makefile_star2_O3/enzo1982[P]smooth/libraries/libwebp/src/dec/vp8l_dec.c
// Function: DecodeImageStream
static int DecodeImageStream(int xsize, int ysize,
                             int is_level0,
                             VP8LDecoder* const dec,
                             uint32_t** const decoded_data) {
  int ok = 1;
  int transform_xsize = xsize;
  int transform_ysize = ysize;
  VP8LBitReader* const br = &dec->br_;
  VP8LMetadata* const hdr = &dec->hdr_;
  uint32_t* data = NULL;
  int color_cache_bits = 0;

  // Read the transforms (may recurse).
  if (is_level0) {
    while (ok && VP8LReadBits(br, 1)) {
      ok = ReadTransform(&transform_xsize, &transform_ysize, dec);
    }
  }

  // Color cache
  if (ok && VP8LReadBits(br, 1)) {
    color_cache_bits = VP8LReadBits(br, 4);
    ok = (color_cache_bits >= 1 && color_cache_bits <= MAX_CACHE_BITS);
    if (!ok) {
      VP8LSetError(dec, VP8_STATUS_BITSTREAM_ERROR);
      goto End;
    }
  }

  // Read the Huffman codes (may recurse).
  ok = ok && ReadHuffmanCodes(dec, transform_xsize, transform_ysize,
                              color_cache_bits, is_level0);
  if (!ok) {
    VP8LSetError(dec, VP8_STATUS_BITSTREAM_ERROR);
    goto End;
  }

  // Finish setting up the color-cache
  if (color_cache_bits > 0) {
    hdr->color_cache_size_ = 1 << color_cache_bits;
    if (!VP8LColorCacheInit(&hdr->color_cache_, color_cache_bits)) {
      ok = VP8LSetError(dec, VP8_STATUS_OUT_OF_MEMORY);
      goto End;
    }
  } else {
    hdr->color_cache_size_ = 0;
  }
  UpdateDecoder(dec, transform_xsize, transform_ysize);

  if (is_level0) {   // level 0 complete
    dec->state_ = READ_HDR;
    goto End;
  }

  {
    const uint64_t total_size = (uint64_t)transform_xsize * transform_ysize;
    data = (uint32_t*)WebPSafeMalloc(total_size, sizeof(*data));
    if (data == NULL) {
      ok = VP8LSetError(dec, VP8_STATUS_OUT_OF_MEMORY);
      goto End;
    }
  }

  // Use the Huffman trees to decode the LZ77 encoded data.
  ok = DecodeImageData(dec, data, transform_xsize, transform_ysize,
                       transform_ysize, NULL);
  ok = ok && !br->eos_;

 End:
  if (!ok) {
    WebPSafeFree(data);
    ClearMetadata(hdr);
  } else {
    if (decoded_data != NULL) {
      *decoded_data = data;
    } else {
      // We allocate image data in this function only for transforms. At level 0
      // (that is: not the transforms), we shouldn't have allocated anything.
      assert(data == NULL);
      assert(is_level0);
    }
    dec->last_pixel_ = 0;  // Reset for future DECODE_DATA_FUNC() calls.
    if (!is_level0) ClearMetadata(hdr);  // Clean up temporary data behind.
  }
  return ok;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, 0x40(%rsp)
movq %rcx, %r14
movl %edx, %ebx
movq %rsi, 0x20(%rsp)
movl %edi, %r13d
leaq 0x28(%rcx), %r15
leaq 0x98(%rcx), %rbp
testl %edx, %edx
movq %rbp, 0x18(%rsp)
movl %edx, 0x14(%rsp)
je 0xd4389
movq %r15, %rdi
movl $0x1, %esi
callq 0xeffac
testl %eax, %eax
je 0xd4389
leaq 0x118(%r14), %r12
movslq 0x110(%r14), %rbx
movq %r15, %rdi
movl $0x2, %esi
callq 0xeffac
movl 0x178(%r14), %edx
movl $0x1, %esi
movl %eax, %ecx
shll %cl, %esi
btl %eax, %edx
jb 0xd4510
leaq (%rbx,%rbx,2), %rcx
leaq (%r12,%rcx,8), %rbp
orl %esi, %edx
movl %edx, 0x178(%r14)
movl %eax, (%rbp)
movl %r13d, 0x8(%rbp)
movq 0x20(%rsp), %rcx
movl %ecx, 0xc(%rbp)
movq $0x0, 0x10(%rbp)
movl 0x110(%r14), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x110(%r14)
cmpl $0x4, %ecx
jge 0xd4797
leaq 0x10(%rbp), %rbx
cmpl $0x2, %eax
jae 0xd422d
movq %r15, %rdi
movl $0x3, %esi
callq 0xeffac
leal 0x2(%rax), %ecx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
shll %cl, %esi
movl %ecx, 0x4(%rbp)
notl %esi
movl 0x8(%rbp), %edi
addl %esi, %edi
shrl %cl, %edi
addl 0xc(%rbp), %esi
shrl %cl, %esi
xorl %edx, %edx
movq %r14, %rcx
movq %rbx, %r8
callq 0xd411f
testl %eax, %eax
jne 0xd422f
jmp 0xd4510
jne 0xd4249
movq %r15, %rdi
movl $0x1, %esi
callq 0xeffac
testl %eax, %eax
jne 0xd4177
jmp 0xd4380
cmpl $0x3, %eax
jne 0xd47b6
movq %r15, %rdi
movl $0x8, %esi
callq 0xeffac
movl %eax, %r13d
incl %r13d
xorl %ecx, %ecx
cmpl $0x10, %r13d
jg 0xd4284
movl $0x1, %ecx
cmpl $0x4, %r13d
jg 0xd4284
xorl %ecx, %ecx
cmpl $0x3, %r13d
setge %cl
xorl $0x3, %ecx
movl $0x1, %eax
shll %cl, %eax
movl 0x8(%rbp), %edx
addl %edx, %eax
decl %eax
shrl %cl, %eax
movq %rax, 0x30(%rsp)
movl %ecx, 0x4(%rbp)
movl %r13d, %edi
movl $0x1, %esi
xorl %edx, %edx
movq %r14, %rcx
movq %rbx, %r8
callq 0xd411f
testl %eax, %eax
je 0xd4510
movb 0x4(%rbp), %cl
movl $0x8, %eax
shrq %cl, %rax
movl $0x1, %edi
movq %rax, 0x8(%rsp)
movl %eax, %ecx
shlq %cl, %rdi
movl $0x4, %esi
callq 0x56b20
testq %rax, %rax
je 0xd4774
movq %rax, %rbp
movq (%rbx), %rcx
movl (%rcx), %eax
movl %eax, (%rbp)
movl $0x4, %eax
cmpl $0x2, %r13d
jl 0xd432a
shll $0x2, %r13d
cmpl $0x6, %r13d
movl %r13d, %eax
movl $0x5, %edx
cmovll %edx, %eax
movl $0x4, %edx
movb -0x4(%rbp,%rdx), %sil
addb (%rcx,%rdx), %sil
movb %sil, (%rbp,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0xd4314
movl $0x4, %edx
movq 0x8(%rsp), %rcx
shll %cl, %edx
cmpl %edx, %eax
jae 0xd4350
movl %eax, %ecx
movq %rbp, %rdi
addq %rcx, %rdi
notl %eax
addl %eax, %edx
incq %rdx
xorl %esi, %esi
callq 0x55f20
movq (%rbx), %rdi
callq 0x57290
movq %rbp, (%rbx)
movq %r15, %rdi
movl $0x1, %esi
callq 0xeffac
testl %eax, %eax
movq 0x18(%rsp), %rbp
movl 0x14(%rsp), %ebx
movq 0x30(%rsp), %r13
jne 0xd4177
jmp 0xd4389
movq 0x18(%rsp), %rbp
movl 0x14(%rsp), %ebx
movq %r15, %rdi
movl $0x1, %esi
callq 0xeffac
testl %eax, %eax
je 0xd43b9
movq %r15, %rdi
movl $0x4, %esi
callq 0xeffac
movl %eax, %r12d
decl %eax
cmpl $0xb, %eax
jb 0xd43bc
movl (%r14), %eax
jmp 0xd4518
xorl %r12d, %r12d
xorl %eax, %eax
movq %rax, 0x28(%rsp)
movq %rax, 0x38(%rsp)
cmpq %rax, 0xe8(%r14)
jne 0xd47d5
cmpq $0x0, 0x108(%r14)
jne 0xd47f4
leaq 0xe8(%r14), %rax
movq %rax, 0x8(%rsp)
movl $0x1, %ebp
testl %ebx, %ebx
je 0xd44d8
movq %r15, %rdi
movl $0x1, %esi
callq 0xeffac
testl %eax, %eax
je 0xd44d8
movl %r12d, 0x10(%rsp)
movq %r15, %rdi
movl $0x3, %esi
callq 0xeffac
movl %eax, %r12d
addl $0x2, %r12d
movl $0x1, %eax
movl %r12d, %ecx
shll %cl, %eax
movl $0x1, %ebp
movq %r13, 0x30(%rsp)
leal (%rax,%r13), %ebx
decl %ebx
shrl %cl, %ebx
movq 0x20(%rsp), %rcx
leal (%rcx,%rax), %r13d
decl %r13d
movl %r12d, %ecx
shrl %cl, %r13d
xorl %r15d, %r15d
leaq 0x28(%rsp), %r8
movl %ebx, %edi
movl %r13d, %esi
xorl %edx, %edx
movq %r14, %rcx
callq 0xd411f
testl %eax, %eax
je 0xd44e7
imull %r13d, %ebx
movl %r12d, 0xc4(%r14)
testl %ebx, %ebx
jle 0xd44a8
movq 0x28(%rsp), %rax
movl %ebx, %ecx
movl $0x1, %ebp
xorl %edx, %edx
movzwl 0x1(%rax,%rdx,4), %esi
movl %esi, (%rax,%rdx,4)
leal 0x1(%rsi), %edi
cmpl %ebp, %esi
cmovgel %edi, %ebp
incq %rdx
cmpq %rdx, %rcx
jne 0xd4490
cmpl $0x3e8, %ebp            # imm = 0x3E8
movq 0x20(%rsp), %rcx
movq 0x30(%rsp), %r13
jg 0xd45e6
movl %r13d, %eax
imull %ecx, %eax
cmpl %eax, %ebp
jg 0xd45e6
xorl %r15d, %r15d
movl %ebp, %ebx
movl 0x10(%rsp), %r12d
jmp 0xd44e0
xorl %r15d, %r15d
movl $0x1, %ebx
cmpl $0x0, 0x4c(%r14)
je 0xd454c
movq 0x8(%rsp), %rbp
movq %r15, %rdi
callq 0x57290
movq 0x28(%rsp), %rdi
callq 0x57290
movq %rbp, %rdi
callq 0xf0967
movq 0x38(%rsp), %rdi
callq 0xf0185
movl (%r14), %eax
movq 0x18(%rsp), %rbp
movl $0x3, %ebx
testl %eax, %eax
je 0xd4526
cmpl $0x5, %eax
jne 0xd4529
movl %ebx, (%r14)
xorl %ebx, %ebx
movq %rbx, %rdi
callq 0x57290
movq %rbp, %rdi
callq 0xd3f28
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x38(%rsp), %rax
movq %rax, (%rsp)
movl %r12d, %edi
movl %ebx, %esi
movl %ebp, %edx
movq %r15, %rcx
movq %r14, %r8
movq 0x8(%rsp), %rbp
movq %rbp, %r9
callq 0xd3734
testl %eax, %eax
je 0xd44ec
movq 0x28(%rsp), %rax
movq %rax, 0xd0(%r14)
movl %ebx, 0xd8(%r14)
movq 0x38(%rsp), %rax
movq %rax, 0xe0(%r14)
movq %r15, %rdi
callq 0x57290
testl %r12d, %r12d
movq 0x18(%rsp), %rbp
jle 0xd4655
movl $0x1, %eax
movl %r12d, %ecx
shll %cl, %eax
movl $0x1, %ebx
movl %eax, 0x98(%r14)
leaq 0xa0(%r14), %rdi
movl %r12d, %esi
callq 0xf0010
testl %eax, %eax
movq 0x20(%rsp), %r15
jne 0xd4661
movl (%r14), %eax
jmp 0xd451d
movl %ebp, %r12d
movl $0x4, %esi
movq %r12, %rdi
callq 0x56b20
testq %rax, %rax
je 0xd4745
movq %rax, %r15
shlq $0x2, %r12
movq %rax, %rdi
movl $0xff, %esi
movq %r12, %rdx
callq 0x55f20
testl %ebx, %ebx
jle 0xd4760
movq 0x28(%rsp), %rax
movl %ebx, %ecx
xorl %edx, %edx
xorl %ebx, %ebx
movl 0x10(%rsp), %r12d
movl (%rax,%rdx,4), %edi
movl (%r15,%rdi,4), %esi
cmpl $-0x1, %esi
jne 0xd4645
movl %ebx, (%r15,%rdi,4)
movl %ebx, %esi
leal 0x1(%rbx), %edi
movl %edi, %ebx
movl %esi, (%rax,%rdx,4)
incq %rdx
cmpq %rdx, %rcx
jne 0xd462e
jmp 0xd44e0
movl $0x0, (%rbp)
movq 0x20(%rsp), %r15
movl 0xc4(%r14), %ecx
movl $0x1, %eax
shll %cl, %eax
addl %r13d, %eax
decl %eax
shrl %cl, %eax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
shll %cl, %edx
notl %edx
xorl %esi, %esi
cmpl $0x1, %ecx
sbbl %esi, %esi
orl %edx, %esi
movl %r13d, 0x84(%r14)
movl %r15d, 0x88(%r14)
movl %eax, 0xc8(%r14)
movl %esi, 0xc0(%r14)
cmpl $0x0, 0x14(%rsp)
je 0xd46d9
movl $0x1, 0x4(%r14)
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0xd46c4
movq $0x0, (%rax)
movl $0x0, 0x90(%r14)
movl $0x1, %eax
jmp 0xd453d
movslq %r13d, %rax
movslq %r15d, %rdi
imulq %rax, %rdi
movl $0x4, %esi
callq 0x56b20
testq %rax, %rax
je 0xd4767
movq %rax, %rbx
movq %r14, %rdi
movq %rax, %rsi
movl %r13d, %edx
movl %r15d, %ecx
movl %r15d, %r8d
xorl %r9d, %r9d
callq 0xd5158
testl %eax, %eax
je 0xd452b
cmpl $0x0, 0x4c(%r14)
jne 0xd452b
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0xd4813
movq %rbx, (%rax)
movl $0x0, 0x90(%r14)
movq %rbp, %rdi
callq 0xd3f28
jmp 0xd46cf
movl (%r14), %eax
cmpl $0x5, %eax
je 0xd4751
testl %eax, %eax
jne 0xd4758
movl $0x1, (%r14)
xorl %r15d, %r15d
jmp 0xd44e7
xorl %ebx, %ebx
jmp 0xd44d1
movl (%r14), %eax
movl $0x1, %ebx
jmp 0xd451d
movl (%r14), %eax
movl $0x1, %ebx
testl %eax, %eax
movq 0x18(%rsp), %rbp
je 0xd4526
cmpl $0x5, %eax
je 0xd4526
jmp 0xd4518
leaq 0x55455(%rip), %rdi     # 0x129bf3
leaq 0x55144(%rip), %rsi     # 0x1298e9
leaq 0x5546e(%rip), %rcx     # 0x129c1a
movl $0x545, %edx            # imm = 0x545
callq 0x55710
leaq 0x57b8d(%rip), %rdi     # 0x12c34a
leaq 0x55125(%rip), %rsi     # 0x1298e9
leaq 0x5544f(%rip), %rcx     # 0x129c1a
movl $0x563, %edx            # imm = 0x563
callq 0x55710
leaq 0x5547d(%rip), %rdi     # 0x129c59
leaq 0x55106(%rip), %rsi     # 0x1298e9
leaq 0x55492(%rip), %rcx     # 0x129c7c
movl $0x17b, %edx            # imm = 0x17B
callq 0x55710
leaq 0x554be(%rip), %rdi     # 0x129cb9
leaq 0x550e7(%rip), %rsi     # 0x1298e9
leaq 0x55473(%rip), %rcx     # 0x129c7c
movl $0x17c, %edx            # imm = 0x17C
callq 0x55710
leaq 0x55381(%rip), %rdi     # 0x129b9b
leaq 0x550c8(%rip), %rsi     # 0x1298e9
leaq 0x55380(%rip), %rcx     # 0x129ba8
movl $0x5fd, %edx            # imm = 0x5FD
callq 0x55710