// File: mhe[P]raytracerframework_cpp/lodepng.cpp
// Function: isFullyOpaque(unsigned char const*, unsigned int, unsigned int, LodePNG_InfoColor const*)
static unsigned isFullyOpaque(const unsigned char* image, unsigned w, unsigned h, const LodePNG_InfoColor* info)
{
  /*TODO: When the user specified a color key for the input image, then this function must also check for pixels that are the same as the color key and treat those as transparent.*/

  unsigned i, numpixels = w * h;
  if(info->colorType == 6)
  {
    if(info->bitDepth == 8)
    {
      for(i = 0; i < numpixels; i++) if(image[i * 4 + 3] != 255) return 0;
    }
    else
    {
      for(i = 0; i < numpixels; i++) if(image[i * 8 + 6] != 255 || image[i * 8 + 7] != 255) return 0;
    }
    return 1; /*no single pixel with alpha channel other than 255 found*/
  }
  else if(info->colorType == 4)
  {
    if(info->bitDepth == 8)
    {
      for(i = 0; i < numpixels; i++) if(image[i * 2 + 1] != 255) return 0;
    }
    else
    {
      for(i = 0; i < numpixels; i++) if(image[i * 4 + 2] != 255 || image[i * 4 + 3] != 255) return 0;
    }
    return 1; /*no single pixel with alpha channel other than 255 found*/
  }
  else if(info->colorType == 3)
  {
    /*when there's a palette, we could check every pixel for translucency, but much quicker is to just check the palette*/
    return(isPaletteFullyOpaque(info->palette, info->palettesize));
  }

  return 0; /*color type that isn't supported by this function yet, so assume there is transparency to be safe*/
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl -0x14(%rbp), %eax
imull -0x18(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x6, (%rax)
jne 0x2a685
movq -0x20(%rbp), %rax
cmpl $0x8, 0x4(%rax)
jne 0x2a61b
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jae 0x2a619
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
shll $0x2, %ecx
addl $0x3, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
je 0x2a60c
movl $0x0, -0x4(%rbp)
jmp 0x2a771
jmp 0x2a60e
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2a5de
jmp 0x2a679
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jae 0x2a677
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
shll $0x3, %ecx
addl $0x6, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
jne 0x2a65e
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
shll $0x3, %ecx
addl $0x7, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
je 0x2a66a
movl $0x0, -0x4(%rbp)
jmp 0x2a771
jmp 0x2a66c
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2a622
jmp 0x2a679
movl $0x1, -0x4(%rbp)
jmp 0x2a771
movq -0x20(%rbp), %rax
cmpl $0x4, (%rax)
jne 0x2a743
movq -0x20(%rbp), %rax
cmpl $0x8, 0x4(%rax)
jne 0x2a6df
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jae 0x2a6dd
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
je 0x2a6d0
movl $0x0, -0x4(%rbp)
jmp 0x2a771
jmp 0x2a6d2
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2a6a3
jmp 0x2a73a
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jae 0x2a738
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
jne 0x2a722
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
shll $0x2, %ecx
addl $0x3, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
je 0x2a72b
movl $0x0, -0x4(%rbp)
jmp 0x2a771
jmp 0x2a72d
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2a6e6
jmp 0x2a73a
movl $0x1, -0x4(%rbp)
jmp 0x2a771
movq -0x20(%rbp), %rax
cmpl $0x3, (%rax)
jne 0x2a766
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x2ae40
movl %eax, -0x4(%rbp)
jmp 0x2a771
jmp 0x2a768
jmp 0x2a76a
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)