// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movl $0x1, -0x24(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
addq $0x98, %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x1453b0
jmp 0x14536d
xorl %eax, %eax
cmpl $0x0, -0x24(%rbp)
movb %al, -0x59(%rbp)
je 0x14538f
movq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x1824b0
cmpl $0x0, %eax
setne %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x145398
jmp 0x1453ae
movq -0x18(%rbp), %rdx
leaq -0x28(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x147430
movl %eax, -0x24(%rbp)
jmp 0x14536d
jmp 0x1453b0
cmpl $0x0, -0x24(%rbp)
je 0x145415
movq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x1824b0
cmpl $0x0, %eax
je 0x145415
movq -0x38(%rbp), %rdi
movl $0x4, %esi
callq 0x1824b0
movl %eax, -0x4c(%rbp)
xorl %eax, %eax
cmpl $0x1, -0x4c(%rbp)
movb %al, -0x5a(%rbp)
jl 0x1453ef
cmpl $0xb, -0x4c(%rbp)
setle %al
movb %al, -0x5a(%rbp)
movb -0x5a(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x145413
movq -0x18(%rbp), %rdi
movl $0x3, %esi
callq 0x144bc0
jmp 0x145558
jmp 0x145415
xorl %eax, %eax
cmpl $0x0, -0x24(%rbp)
movb %al, -0x5b(%rbp)
je 0x14543f
movq -0x18(%rbp), %rdi
movl -0x28(%rbp), %esi
movl -0x2c(%rbp), %edx
movl -0x4c(%rbp), %ecx
movl -0xc(%rbp), %r8d
callq 0x1476c0
cmpl $0x0, %eax
setne %al
movb %al, -0x5b(%rbp)
movb -0x5b(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x145463
movq -0x18(%rbp), %rdi
movl $0x3, %esi
callq 0x144bc0
jmp 0x145558
cmpl $0x0, -0x4c(%rbp)
jle 0x1454a8
movl -0x4c(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
movq -0x40(%rbp), %rdi
addq $0x8, %rdi
movl -0x4c(%rbp), %esi
callq 0x1825e0
cmpl $0x0, %eax
jne 0x1454a6
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x144bc0
movl %eax, -0x24(%rbp)
jmp 0x145558
jmp 0x1454b2
movq -0x40(%rbp), %rax
movl $0x0, (%rax)
movq -0x18(%rbp), %rdi
movl -0x28(%rbp), %esi
movl -0x2c(%rbp), %edx
callq 0x1479c0
cmpl $0x0, -0xc(%rbp)
je 0x1454d7
movq -0x18(%rbp), %rax
movl $0x1, 0x4(%rax)
jmp 0x145558
movslq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
movl $0x4, %esi
callq 0x5b060
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x145513
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x144bc0
movl %eax, -0x24(%rbp)
jmp 0x145558
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl -0x28(%rbp), %edx
movl -0x2c(%rbp), %ecx
movl -0x2c(%rbp), %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0x145d80
movl %eax, -0x24(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x24(%rbp)
movb %al, -0x5c(%rbp)
je 0x14554d
movq -0x38(%rbp), %rax
cmpl $0x0, 0x24(%rax)
setne %al
xorb $-0x1, %al
movb %al, -0x5c(%rbp)
movb -0x5c(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x145575
movq -0x48(%rbp), %rdi
callq 0x5b920
movq -0x40(%rbp), %rdi
callq 0x145070
jmp 0x1455f9
cmpq $0x0, -0x20(%rbp)
je 0x145589
movq -0x48(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1455da
cmpq $0x0, -0x48(%rbp)
jne 0x145592
jmp 0x1455b1
leaq 0x7821d(%rip), %rdi     # 0x1bd7b6
leaq 0x77f49(%rip), %rsi     # 0x1bd4e9
movl $0x5fd, %edx            # imm = 0x5FD
leaq 0x78217(%rip), %rcx     # 0x1bd7c3
callq 0x598a0
cmpl $0x0, -0xc(%rbp)
je 0x1455b9
jmp 0x1455d8
leaq 0x7824e(%rip), %rdi     # 0x1bd80e
leaq 0x77f22(%rip), %rsi     # 0x1bd4e9
movl $0x5fe, %edx            # imm = 0x5FE
leaq 0x781f0(%rip), %rcx     # 0x1bd7c3
callq 0x598a0
jmp 0x1455da
movq -0x18(%rbp), %rax
movl $0x0, 0x90(%rax)
cmpl $0x0, -0xc(%rbp)
jne 0x1455f7
movq -0x40(%rbp), %rdi
callq 0x145070
jmp 0x1455f9
movl -0x24(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)