// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movq %r8, 0x18(%rsp)
movq %rcx, %rbx
movl %edx, %r13d
movl %esi, %ebp
movq %rdi, 0x28(%rsp)
leaq 0x28(%rcx), %r15
leaq 0x98(%rcx), %rax
movq %rax, 0x40(%rsp)
testl %edx, %edx
movq %rbp, 0x20(%rsp)
je 0xd532a
leaq 0x118(%rbx), %rax
movq %rax, 0x38(%rsp)
movl %r13d, 0x14(%rsp)
movq %r15, %rdi
movl $0x1, %esi
callq 0xf0d7f
testl %eax, %eax
je 0xd532a
movslq 0x110(%rbx), %r14
movq %r15, %rdi
movl $0x2, %esi
callq 0xf0d7f
movl 0x178(%rbx), %edx
movl $0x1, %esi
movl %eax, %ecx
shll %cl, %esi
btl %eax, %edx
jae 0xd5154
movb $0x1, %cl
jmp 0xd531e
leaq (%r14,%r14,2), %rcx
movq 0x38(%rsp), %rdi
leaq (%rdi,%rcx,8), %r12
orl %esi, %edx
movl %edx, 0x178(%rbx)
movl %eax, (%r12)
movq 0x28(%rsp), %rcx
movl %ecx, 0x8(%r12)
movl %ebp, 0xc(%r12)
movq $0x0, 0x10(%r12)
movl 0x110(%rbx), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x110(%rbx)
cmpl $0x4, %ecx
jge 0xd5770
leaq 0x10(%r12), %r14
xorl %ecx, %ecx
cmpl $0x2, %eax
jb 0xd52bf
je 0xd531e
cmpl $0x3, %eax
jne 0xd578f
movq %r15, %rdi
movl $0x8, %esi
callq 0xf0d7f
movl %eax, %ebp
incl %ebp
xorl %ecx, %ecx
cmpl $0x10, %ebp
jg 0xd51e9
movl $0x1, %ecx
cmpl $0x4, %ebp
jg 0xd51e9
xorl %ecx, %ecx
cmpl $0x3, %ebp
setge %cl
xorl $0x3, %ecx
movl $0x1, %eax
shll %cl, %eax
movl 0x8(%r12), %edx
addl %edx, %eax
decl %eax
shrl %cl, %eax
movq %rax, 0x28(%rsp)
movl %ecx, 0x4(%r12)
movl %ebp, %edi
movl $0x1, %esi
xorl %edx, %edx
movq %rbx, %rcx
movq %r14, %r8
callq 0xd50c2
testl %eax, %eax
je 0xd5312
movb 0x4(%r12), %cl
movl $0x8, %r13d
shrq %cl, %r13
movl $0x1, %edi
movl %r13d, %ecx
shlq %cl, %rdi
movl $0x4, %esi
callq 0x56b20
testq %rax, %rax
je 0xd5301
movq %rax, %r12
movq (%r14), %rcx
movl (%rcx), %eax
movl %eax, (%r12)
movl $0x4, %eax
cmpl $0x2, %ebp
jl 0xd528a
shll $0x2, %ebp
cmpl $0x6, %ebp
movl $0x5, %eax
cmovll %eax, %ebp
movl $0x4, %eax
movb -0x4(%r12,%rax), %dl
addb (%rcx,%rax), %dl
movb %dl, (%r12,%rax)
incq %rax
cmpq %rax, %rbp
jne 0xd5276
movl $0x4, %edx
movl %r13d, %ecx
shll %cl, %edx
cmpl %edx, %eax
jae 0xd52ab
movl %eax, %edi
addq %r12, %rdi
notl %eax
addl %eax, %edx
incq %rdx
xorl %esi, %esi
callq 0x55f20
movq (%r14), %rdi
callq 0x57290
movq %r12, (%r14)
testq %r12, %r12
je 0xd5301
xorl %ecx, %ecx
jmp 0xd5314
movq %r15, %rdi
movl $0x3, %esi
callq 0xf0d7f
leal 0x2(%rax), %ecx
movl $0x1, %esi
shll %cl, %esi
movl %ecx, 0x4(%r12)
decl %esi
movl 0x8(%r12), %edi
addl %esi, %edi
shrl %cl, %edi
addl 0xc(%r12), %esi
shrl %cl, %esi
xorl %edx, %edx
movq %rbx, %rcx
movq %r14, %r8
callq 0xd50c2
testl %eax, %eax
sete %cl
jmp 0xd531e
movl (%rbx), %eax
cmpl $0x5, %eax
je 0xd530c
testl %eax, %eax
jne 0xd5312
movl $0x1, (%rbx)
movb $0x1, %cl
movl 0x14(%rsp), %r13d
movq 0x20(%rsp), %rbp
testb %cl, %cl
je 0xd5110
xorl %ebp, %ebp
jmp 0xd5363
movl $0x1, %ebp
movq %r15, %rdi
movl $0x1, %esi
callq 0xf0d7f
testl %eax, %eax
je 0xd5363
movq %r15, %rdi
movl $0x4, %esi
callq 0xf0d7f
movl %eax, %r14d
decl %eax
xorl %ebp, %ebp
cmpl $0xb, %eax
setb %bpl
jae 0xd562a
jmp 0xd5366
xorl %r14d, %r14d
testl %ebp, %ebp
je 0xd547d
xorl %eax, %eax
movq %rax, 0x30(%rsp)
movq %rax, 0x48(%rsp)
cmpq %rax, 0xe8(%rbx)
jne 0xd57ae
cmpq $0x0, 0x108(%rbx)
jne 0xd57cd
leaq 0xe8(%rbx), %rax
movq %rax, 0x50(%rsp)
testl %r13d, %r13d
movl %r14d, 0x38(%rsp)
movl $0x1, %ebp
je 0xd546f
movq %r15, %rdi
movl $0x1, %esi
callq 0xf0d7f
testl %eax, %eax
je 0xd546f
movl %r13d, 0x14(%rsp)
movq %r15, %rdi
movl $0x3, %esi
callq 0xf0d7f
movl %eax, %r12d
addl $0x2, %r12d
movl $0x1, %eax
movl %r12d, %ecx
shll %cl, %eax
movl $0x1, %ebp
movq 0x28(%rsp), %rcx
leal (%rcx,%rax), %r14d
decl %r14d
movl %r12d, %ecx
shrl %cl, %r14d
movq 0x20(%rsp), %rcx
leal (%rcx,%rax), %r13d
decl %r13d
movl %r12d, %ecx
shrl %cl, %r13d
xorl %r15d, %r15d
leaq 0x30(%rsp), %r8
movl %r14d, %edi
movl %r13d, %esi
xorl %edx, %edx
movq %rbx, %rcx
callq 0xd50c2
testl %eax, %eax
je 0xd5489
imull %r13d, %r14d
movl %r12d, 0xc4(%rbx)
testl %r14d, %r14d
jle 0xd5494
movq 0x30(%rsp), %rax
movl %r14d, %ecx
movl $0x1, %ebp
xorl %edx, %edx
movq 0x28(%rsp), %r8
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 0xd5455
jmp 0xd549e
xorl %r15d, %r15d
movl $0x1, %r14d
jmp 0xd554b
xorl %ebp, %ebp
movq 0x28(%rsp), %r15
jmp 0xd55e4
movl $0x1, %r14d
jmp 0xd553e
movl $0x1, %ebp
movq 0x28(%rsp), %r8
movb $0x1, %r13b
cmpl $0x3e8, %ebp            # imm = 0x3E8
jg 0xd54c0
movl %r8d, %eax
imull 0x20(%rsp), %eax
cmpl %eax, %ebp
jg 0xd54c0
xorl %r15d, %r15d
movl %ebp, %r14d
jmp 0xd5541
movl %ebp, %r12d
movl $0x4, %esi
movq %r12, %rdi
callq 0x56b20
testq %rax, %rax
je 0xd5524
movq %rax, %r15
shlq $0x2, %r12
movq %rax, %rdi
movl $0xff, %esi
movq %r12, %rdx
callq 0x55f20
testl %r14d, %r14d
jle 0xd5768
movq 0x30(%rsp), %rax
movl %r14d, %ecx
xorl %edx, %edx
xorl %r14d, %r14d
movl (%rax,%rdx,4), %esi
cmpl $-0x1, (%r15,%rsi,4)
jne 0xd5513
movl %r14d, (%r15,%rsi,4)
incl %r14d
movl (%r15,%rsi,4), %esi
movl %esi, (%rax,%rdx,4)
incq %rdx
cmpq %rdx, %rcx
jne 0xd5502
jmp 0xd5541
movl (%rbx), %eax
movl $0x1, %r14d
cmpl $0x5, %eax
je 0xd5535
testl %eax, %eax
jne 0xd553b
movl $0x1, (%rbx)
xorl %r15d, %r15d
xorl %r13d, %r13d
testb %r13b, %r13b
je 0xd55a5
movl 0x14(%rsp), %r13d
movb $0x1, %r12b
cmpl $0x0, 0x4c(%rbx)
je 0xd5558
xorl %ebp, %ebp
jmp 0xd55af
leaq 0x48(%rsp), %rax
movq %rax, (%rsp)
movl 0x38(%rsp), %edi
movl %r14d, %esi
movl %ebp, %edx
movq %r15, %rcx
movq %rbx, %r8
movq 0x50(%rsp), %r9
callq 0xd4678
testl %eax, %eax
je 0xd5554
movq 0x30(%rsp), %rax
movq %rax, 0xd0(%rbx)
movl %r14d, 0xd8(%rbx)
movq 0x48(%rsp), %rax
movq %rax, 0xe0(%rbx)
movb $0x1, %bpl
xorl %r12d, %r12d
jmp 0xd55af
movb $0x1, %r12b
xorl %ebp, %ebp
movl 0x14(%rsp), %r13d
movq %r15, %rdi
callq 0x57290
testb %r12b, %r12b
je 0xd55da
movq 0x30(%rsp), %rdi
callq 0x57290
movq 0x50(%rsp), %rdi
callq 0xf1647
movq 0x48(%rsp), %rdi
callq 0xf0f54
movq 0x28(%rsp), %r15
movl 0x38(%rsp), %r14d
movzbl %bpl, %ebp
testb %bpl, %bpl
je 0xd562a
testl %r14d, %r14d
jle 0xd563d
movl $0x1, %eax
movl %r14d, %ecx
shll %cl, %eax
movl %eax, 0x98(%rbx)
leaq 0xa0(%rbx), %rdi
movl %r14d, %esi
callq 0xf0de4
testl %eax, %eax
jne 0xd5648
movl (%rbx), %eax
cmpl $0x5, %eax
je 0xd5620
testl %eax, %eax
jne 0xd5626
movl $0x1, (%rbx)
xorl %ebp, %ebp
jmp 0xd5698
movl (%rbx), %eax
cmpl $0x5, %eax
je 0xd5635
testl %eax, %eax
jne 0xd5698
movl $0x3, (%rbx)
jmp 0xd5698
movq 0x40(%rsp), %rax
movl $0x0, (%rax)
movl 0xc4(%rbx), %ecx
movl $0x1, %eax
shll %cl, %eax
addl %r15d, %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 %r15d, 0x84(%rbx)
movq 0x20(%rsp), %rcx
movl %ecx, 0x88(%rbx)
movl %eax, 0xc8(%rbx)
movl %esi, 0xc0(%rbx)
testl %r13d, %r13d
je 0xd56fe
movl $0x1, 0x4(%rbx)
xorl %r14d, %r14d
movq 0x18(%rsp), %rax
testl %ebp, %ebp
je 0xd56bd
testq %rax, %rax
je 0xd56d1
movq %r14, (%rax)
movl $0x0, 0x90(%rbx)
testl %r13d, %r13d
jne 0xd56ed
jmp 0xd56c5
movq %r14, %rdi
callq 0x57290
movq 0x40(%rsp), %rdi
callq 0xd4ecb
jmp 0xd56ed
testq %r14, %r14
jne 0xd57ec
testl %r13d, %r13d
je 0xd580b
movl $0x0, 0x90(%rbx)
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq %r15d, %rax
movslq %ecx, %rdi
imulq %rax, %rdi
movl $0x4, %esi
callq 0x56b20
movq %rax, %r14
testq %rax, %rax
jne 0xd572d
movl (%rbx), %eax
xorl %ebp, %ebp
cmpl $0x5, %eax
je 0xd5727
testl %eax, %eax
jne 0xd572d
movl $0x1, (%rbx)
testq %r14, %r14
je 0xd569b
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
movq 0x20(%rsp), %rcx
movl %ecx, %r8d
xorl %r9d, %r9d
callq 0xd60a2
testl %eax, %eax
je 0xd569b
xorl %ebp, %ebp
cmpl $0x0, 0x4c(%rbx)
sete %bpl
jmp 0xd569b
xorl %r14d, %r14d
jmp 0xd5541
leaq 0x55256(%rip), %rdi     # 0x12a9cd
leaq 0x54f3b(%rip), %rsi     # 0x12a6b9
leaq 0x5526f(%rip), %rcx     # 0x12a9f4
movl $0x545, %edx            # imm = 0x545
callq 0x55710
leaq 0x57964(%rip), %rdi     # 0x12d0fa
leaq 0x54f1c(%rip), %rsi     # 0x12a6b9
leaq 0x55250(%rip), %rcx     # 0x12a9f4
movl $0x563, %edx            # imm = 0x563
callq 0x55710
leaq 0x5527e(%rip), %rdi     # 0x12aa33
leaq 0x54efd(%rip), %rsi     # 0x12a6b9
leaq 0x55293(%rip), %rcx     # 0x12aa56
movl $0x17b, %edx            # imm = 0x17B
callq 0x55710
leaq 0x552bf(%rip), %rdi     # 0x12aa93
leaq 0x54ede(%rip), %rsi     # 0x12a6b9
leaq 0x55274(%rip), %rcx     # 0x12aa56
movl $0x17c, %edx            # imm = 0x17C
callq 0x55710
leaq 0x55178(%rip), %rdi     # 0x12a96b
leaq 0x54ebf(%rip), %rsi     # 0x12a6b9
leaq 0x55177(%rip), %rcx     # 0x12a978
movl $0x5fd, %edx            # imm = 0x5FD
callq 0x55710
leaq 0x551b1(%rip), %rdi     # 0x12a9c3
leaq 0x54ea0(%rip), %rsi     # 0x12a6b9
leaq 0x55158(%rip), %rcx     # 0x12a978
movl $0x5fe, %edx            # imm = 0x5FE
callq 0x55710