// File: /workspace/github_c_makefile_star2_O3/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: lodepng_zlib_decompress
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 0x44b7
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r14
movzbl (%rdx), %edx
movl %edx, %eax
shll $0x8, %eax
movzbl 0x1(%r12), %ecx
orl %ecx, %eax
imull $0x7bdf, %eax, %eax     # imm = 0x7BDF
movzwl %ax, %esi
movl $0x18, %eax
cmpl $0x842, %esi            # imm = 0x842
ja 0x44a9
movl %edx, %eax
andl $0xf, %eax
cmpl $0x8, %eax
setne %al
testb %dl, %dl
sets %dl
orb %al, %dl
movl $0x19, %eax
jne 0x44a9
movl $0x1a, %eax
testb $0x20, %cl
jne 0x44a9
movq %r8, %r13
movq %rdi, %rbx
leaq 0x2(%r12), %rdx
leaq -0x2(%r15), %rcx
movq 0x10(%r8), %rax
movq %r14, %rsi
testq %rax, %rax
je 0x43f7
movq %r13, %r8
callq *%rax
jmp 0x43fc
callq 0x1aff
testl %eax, %eax
jne 0x44a9
cmpl $0x0, (%r13)
jne 0x44a7
movl -0x4(%r12,%r15), %ecx
bswapl %ecx
movl (%r14), %eax
testl %eax, %eax
je 0x4499
movq (%rbx), %rdi
movl $0x1, %esi
xorl %edx, %edx
movl $0x15ae, %r8d           # imm = 0x15AE
movl $0x15ae, %r9d           # imm = 0x15AE
movl $0x80078071, %r10d      # imm = 0x80078071
cmpl %r8d, %eax
movl $0x15ae, %r11d          # imm = 0x15AE
cmovbl %eax, %r11d
movl %eax, %ebx
cmpq %r9, %rbx
cmovaeq %r9, %rbx
xorl %r14d, %r14d
movzbl (%rdi,%r14), %ebp
addl %ebp, %esi
addl %esi, %edx
incq %r14
cmpl %r14d, %ebx
jne 0x4452
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 0x4439
shll $0x10, %edx
orl %esi, %edx
jmp 0x449e
movl $0x1, %edx
movl $0x3a, %eax
cmpl %ecx, %edx
jne 0x44a9
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq