// File: /workspace/github_cpp_makefile_star2_O3/phillip-h[P]fractal-gen/lodepng.cpp
// Function: lodepng_zlib_decompress(unsigned char**, unsigned long*, unsigned char const*, unsigned long, LodePNGDecompressSettings const*)
unsigned lodepng_zlib_decompress(unsigned char** out, size_t* outsize, const unsigned char* in,
                                 size_t insize, const LodePNGDecompressSettings* settings)
{
  unsigned error = 0;
  unsigned CM, CINFO, FDICT;

  if(insize < 2) return 53; /*error, size of zlib data too small*/
  /*read information from zlib header*/
  if((in[0] * 256 + in[1]) % 31 != 0)
  {
    /*error: 256 * in[0] + in[1] must be a multiple of 31, the FCHECK value is supposed to be made that way*/
    return 24;
  }

  CM = in[0] & 15;
  CINFO = (in[0] >> 4) & 15;
  /*FCHECK = in[1] & 31;*/ /*FCHECK is already tested above*/
  FDICT = (in[1] >> 5) & 1;
  /*FLEVEL = (in[1] >> 6) & 3;*/ /*FLEVEL is not used here*/

  if(CM != 8 || CINFO > 7)
  {
    /*error: only compression method 8: inflate with sliding window of 32k is supported by the PNG spec*/
    return 25;
  }
  if(FDICT != 0)
  {
    /*error: the specification of PNG says about the zlib stream:
      "The additional flags shall not specify a preset dictionary."*/
    return 26;
  }

  error = inflate(out, outsize, in + 2, insize - 2, settings);
  if(error) return error;

  if(!settings->ignore_adler32)
  {
    unsigned ADLER32 = lodepng_read32bitInt(&in[insize - 4]);
    unsigned checksum = adler32(*out, (unsigned)(*outsize));
    if(checksum != ADLER32) return 58; /*error, adler checksum not correct, data must be corrupted*/
  }

  return 0; /*no error*/
}

// Assembly:
movl $0x35, %eax
cmpq $0x2, %rcx
jb 0x6f8a
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movzbl (%rdx), %edx
movq %rcx, %r14
movzbl 0x1(%r12), %ecx
movq %rsi, %r15
movl %edx, %eax
shll $0x8, %eax
orl %ecx, %eax
imull $0x7bdf, %eax, %esi     # imm = 0x7BDF
movl $0x18, %eax
cmpw $0x842, %si             # imm = 0x842
ja 0x6f7c
movl %edx, %eax
andl $0xf, %eax
cmpl $0x8, %eax
setne %al
testb %dl, %dl
sets %dl
orb %al, %dl
movl $0x19, %eax
jne 0x6f7c
movl $0x1a, %eax
testb $0x20, %cl
jne 0x6f7c
movq 0x10(%r8), %rax
leaq 0x2(%r12), %rdx
leaq -0x2(%r14), %rcx
movq %r8, %r13
movq %rdi, %rbx
movq %r15, %rsi
testq %rax, %rax
je 0x6eca
movq %r13, %r8
callq *%rax
jmp 0x6ecf
callq 0x4896
testl %eax, %eax
jne 0x6f7c
cmpl $0x0, (%r13)
jne 0x6f7a
movbel -0x4(%r12,%r14), %ecx
movl (%r15), %eax
testl %eax, %eax
je 0x6f6c
movq (%rbx), %rdi
movl $0x1, %esi
movl $0x15ae, %r8d           # imm = 0x15AE
movl $0x15ae, %r9d           # imm = 0x15AE
movl $0x80078071, %r10d      # imm = 0x80078071
xorl %edx, %edx
cmpl %r8d, %eax
movl $0x15ae, %r11d          # imm = 0x15AE
movl %eax, %ebx
cmovbl %eax, %r11d
cmpq %r9, %rbx
cmovaeq %r9, %rbx
xorl %r14d, %r14d
movzbl (%rdi,%r14), %ebp
incq %r14
addl %ebp, %esi
addl %esi, %edx
cmpl %r14d, %ebx
jne 0x6f25
movl %r11d, %ebx
addq %rbx, %rdi
movl %esi, %ebx
imulq %r10, %rbx
shrq $0x2f, %rbx
imull $0xfff1, %ebx, %ebx     # imm = 0xFFF1
subl %ebx, %esi
movl %edx, %ebx
imulq %r10, %rbx
shrq $0x2f, %rbx
imull $0xfff1, %ebx, %ebx     # imm = 0xFFF1
subl %ebx, %edx
subl %r11d, %eax
jne 0x6f0c
shll $0x10, %edx
orl %esi, %edx
jmp 0x6f71
movl $0x1, %edx
movl $0x3a, %eax
cmpl %ecx, %edx
jne 0x6f7c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq