// File: /workspace/github_cpp_makefile_star2_O1/phillip-h[P]fractal-gen/lodepng.cpp
// Function: lodepng_inspect(unsigned int*, unsigned int*, LodePNGState*, unsigned char const*, unsigned long)
unsigned lodepng_inspect(unsigned* w, unsigned* h, LodePNGState* state,
                         const unsigned char* in, size_t insize)
{
  LodePNGInfo* info = &state->info_png;
  if(insize == 0 || in == 0)
  {
    CERROR_RETURN_ERROR(state->error, 48); /*error: the given data is empty*/
  }
  if(insize < 33)
  {
    CERROR_RETURN_ERROR(state->error, 27); /*error: the data length is smaller than the length of a PNG header*/
  }

  /*when decoding a new PNG image, make sure all parameters created after previous decoding are reset*/
  lodepng_info_cleanup(info);
  lodepng_info_init(info);

  if(in[0] != 137 || in[1] != 80 || in[2] != 78 || in[3] != 71
     || in[4] != 13 || in[5] != 10 || in[6] != 26 || in[7] != 10)
  {
    CERROR_RETURN_ERROR(state->error, 28); /*error: the first 8 bytes are not the correct PNG signature*/
  }
  if(lodepng_chunk_length(in + 8) != 13)
  {
    CERROR_RETURN_ERROR(state->error, 94); /*error: header size must be 13 bytes*/
  }
  if(!lodepng_chunk_type_equals(in + 8, "IHDR"))
  {
    CERROR_RETURN_ERROR(state->error, 29); /*error: it doesn't start with a IHDR chunk!*/
  }

  /*read the values given in the header*/
  *w = lodepng_read32bitInt(&in[16]);
  *h = lodepng_read32bitInt(&in[20]);
  info->color.bitdepth = in[24];
  info->color.colortype = (LodePNGColorType)in[25];
  info->compression_method = in[26];
  info->filter_method = in[27];
  info->interlace_method = in[28];

  if(*w == 0 || *h == 0)
  {
    CERROR_RETURN_ERROR(state->error, 93);
  }

  if(!state->decoder.ignore_crc)
  {
    unsigned CRC = lodepng_read32bitInt(&in[29]);
    unsigned checksum = lodepng_crc32(&in[12], 17);
    if(CRC != checksum)
    {
      CERROR_RETURN_ERROR(state->error, 57); /*invalid CRC*/
    }
  }

  /*error: only compression method 0 is allowed in the specification*/
  if(info->compression_method != 0) CERROR_RETURN_ERROR(state->error, 32);
  /*error: only filter method 0 is allowed in the specification*/
  if(info->filter_method != 0) CERROR_RETURN_ERROR(state->error, 33);
  /*error: only interlace methods 0 and 1 exist in the specification*/
  if(info->interlace_method > 1) CERROR_RETURN_ERROR(state->error, 34);

  state->error = checkColorValidity(info->color.colortype, info->color.bitdepth);
  return state->error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rdx, %rbx
testq %r8, %r8
sete %al
testq %rcx, %rcx
sete %cl
orb %al, %cl
movl $0x30, %eax
jne 0x9add
movl $0x1b, %eax
cmpq $0x21, %r8
jb 0x9add
movq %rsi, %r15
movq %rdi, %r12
leaq 0xb8(%rbx), %rdi
callq 0x7cb4
movabsq $0x800000006, %rax      # imm = 0x800000006
movq %rax, 0xc8(%rbx)
vxorps %xmm0, %xmm0, %xmm0
vmovups %ymm0, 0xd0(%rbx)
xorl %eax, %eax
movl %eax, 0xc0(%rbx)
movq $0x0, 0xb8(%rbx)
movl %eax, 0x15c(%rbx)
vxorps %xmm1, %xmm1, %xmm1
vmovups %zmm1, 0xf0(%rbx)
vmovups %zmm1, 0x104(%rbx)
vmovups %ymm0, 0x170(%rbx)
vmovups %ymm0, 0x180(%rbx)
movl $0x1c, %eax
cmpb $-0x77, (%r14)
jne 0x9add
cmpb $0x50, 0x1(%r14)
jne 0x9add
cmpb $0x4e, 0x2(%r14)
jne 0x9add
cmpb $0x47, 0x3(%r14)
jne 0x9add
cmpb $0xd, 0x4(%r14)
jne 0x9add
cmpb $0xa, 0x5(%r14)
jne 0x9add
cmpb $0x1a, 0x6(%r14)
jne 0x9add
cmpb $0xa, 0x7(%r14)
jne 0x9add
movbel 0x8(%r14), %ecx
movl $0x5e, %eax
cmpl $0xd, %ecx
jne 0x9add
leaq 0x8(%r14), %rdi
leaq 0x88c7(%rip), %rsi      # 0x12308
vzeroupper
callq 0x72c9
testb %al, %al
je 0x9ad8
movl 0x10(%r14), %eax
movbel %eax, (%r12)
movl 0x14(%r14), %eax
movbel %eax, (%r15)
movzbl 0x18(%r14), %esi
movl %esi, 0xcc(%rbx)
movzbl 0x19(%r14), %edi
movl %edi, 0xc8(%rbx)
movzbl 0x1a(%r14), %r8d
movl %r8d, 0xb8(%rbx)
movzbl 0x1b(%r14), %edx
movl %edx, 0xbc(%rbx)
movzbl 0x1c(%r14), %ecx
movl %ecx, 0xc0(%rbx)
movl $0x5d, %eax
cmpl $0x0, (%r12)
je 0x9add
cmpl $0x0, (%r15)
je 0x9add
cmpl $0x0, 0x28(%rbx)
je 0x9af5
movl $0x20, %eax
testb %r8b, %r8b
jne 0x9add
movl $0x21, %eax
testb %dl, %dl
jne 0x9add
movl $0x22, %eax
cmpb $0x1, %cl
ja 0x9add
callq 0x9b5e
jmp 0x9add
movl $0x1d, %eax
movl %eax, 0x1a0(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq
movzbl 0x1d(%r14), %r9d
movzbl 0x1e(%r14), %eax
shll $0x10, %eax
movzbl 0x1f(%r14), %r11d
shll $0x8, %r11d
movzbl 0x20(%r14), %ebp
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
movl $0xc, %r15d
leaq 0x7ddd(%rip), %r12      # 0x11900
movb (%r14,%r15), %r13b
xorb %r10b, %r13b
movzbl %r13b, %r13d
shrl $0x8, %r10d
xorl (%r12,%r13,4), %r10d
incq %r15
cmpq $0x1d, %r15
jne 0x9b23
shll $0x18, %r9d
orl %r9d, %eax
orl %r11d, %eax
orl %ebp, %eax
xorl %eax, %r10d
movl $0x39, %eax
cmpl $-0x1, %r10d
jne 0x9add
jmp 0x9ab4