// File: /workspace/github_cpp_makefile_star2_O2/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
testq %r8, %r8
movq %rcx, %r14
movq %rdx, %rbx
sete %al
testq %rcx, %rcx
sete %cl
orb %al, %cl
je 0x7d9b
pushq $0x30
jmp 0x7da3
cmpq $0x21, %r8
jae 0x7db9
pushq $0x1b
popq %rax
movl %eax, 0x1a0(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb8(%rbx), %r13
movq %rdi, %r12
movq %rsi, %r15
movq %r13, %rdi
callq 0x6450
movq %r13, %rdi
callq 0x63e0
pushq $0x1c
popq %rax
cmpb $-0x77, (%r14)
jne 0x7da4
cmpb $0x50, 0x1(%r14)
jne 0x7da4
cmpb $0x4e, 0x2(%r14)
jne 0x7da4
cmpb $0x47, 0x3(%r14)
jne 0x7da4
cmpb $0xd, 0x4(%r14)
jne 0x7da4
cmpb $0xa, 0x5(%r14)
jne 0x7da4
cmpb $0x1a, 0x6(%r14)
jne 0x7da4
cmpb $0xa, 0x7(%r14)
jne 0x7da4
leaq 0x8(%r14), %r13
movq %r13, %rdi
callq 0x3ba8
cmpl $0xd, %eax
jne 0x7ee1
leaq 0x6f68(%rip), %rsi      # 0xed94
movq %r13, %rdi
callq 0x5c0f
testb %al, %al
je 0x7ee8
leaq 0x10(%r14), %rdi
callq 0x3ba8
leaq 0x14(%r14), %rdi
movl %eax, (%r12)
callq 0x3ba8
movl %eax, (%r15)
movzbl 0x18(%r14), %ecx
movl %ecx, 0xcc(%rbx)
movzbl 0x19(%r14), %edx
movl %edx, 0xc8(%rbx)
movzbl 0x1a(%r14), %ebp
movl %ebp, 0xb8(%rbx)
movzbl 0x1b(%r14), %r13d
movl %r13d, 0xbc(%rbx)
movzbl 0x1c(%r14), %esi
movl %esi, 0xc0(%rbx)
pushq $0x5d
popq %rax
cmpl $0x0, (%r12)
je 0x7da4
cmpl $0x0, (%r15)
je 0x7da4
cmpl $0x0, 0x28(%rbx)
movl %esi, %r12d
movl %edx, (%rsp)
movl %ecx, 0x4(%rsp)
jne 0x7ed5
leaq 0x1d(%r14), %rdi
callq 0x3ba8
movl %eax, %r15d
addq $0xc, %r14
pushq $0x11
popq %rsi
movq %r14, %rdi
callq 0x5bc6
cmpl %eax, %r15d
jne 0x7efb
testb %bpl, %bpl
je 0x7eef
pushq $0x20
jmp 0x7da3
pushq $0x5e
jmp 0x7da3
pushq $0x1d
jmp 0x7da3
testb %r13b, %r13b
je 0x7f02
pushq $0x21
jmp 0x7da3
pushq $0x39
jmp 0x7da3
cmpb $0x1, %r12b
jbe 0x7f0f
pushq $0x22
jmp 0x7da3
movl (%rsp), %edi
movl 0x4(%rsp), %esi
callq 0x7f20
jmp 0x7da4