// File: /workspace/github_cpp_makefile_star2_O3/lvandeve[P]lodepng/lodepng.cpp
// Function: lodepng_zlib_decompressv(ucvector*, unsigned char const*, unsigned long, LodePNGDecompressSettings const*)
static unsigned lodepng_zlib_decompressv(ucvector* out,
                                         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 = inflatev(out, in + 2, insize - 2, settings);
  if(error) return error;

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

  return 0; /*no error*/
}

// Assembly:
movl $0x35, %eax
cmpq $0x2, %rdx
jb 0x5194
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rcx, %r12
movq %rdx, %r14
movq %rsi, %r15
movzbl (%rsi), %edx
movl %edx, %eax
shll $0x8, %eax
movzbl 0x1(%rsi), %ecx
orl %ecx, %eax
imull $0x7bdf, %eax, %eax     # imm = 0x7BDF
movzwl %ax, %esi
movl $0x18, %eax
cmpl $0x842, %esi            # imm = 0x842
ja 0x518c
movl %edx, %eax
andl $0xf, %eax
cmpl $0x8, %eax
setne %al
testb %dl, %dl
sets %dl
orb %al, %dl
movl $0x19, %eax
jne 0x518c
movl $0x1a, %eax
testb $0x20, %cl
jne 0x518c
movq %rdi, %rbx
leaq 0x2(%r15), %rdx
leaq -0x2(%r14), %rcx
movq 0x18(%r12), %rax
testq %rax, %rax
je 0x50c3
leaq 0x8(%rbx), %rsi
movq %rbx, %rdi
movq %r12, %r8
callq *%rax
movq 0x8(%rbx), %rcx
movq %rcx, 0x10(%rbx)
testl %eax, %eax
je 0x50dc
movq 0x8(%r12), %rax
testq %rax, %rax
je 0x5175
cmpq %rcx, %rax
movl $0x6e, %eax
sbbl $0x0, %eax
jmp 0x518c
movq %rbx, %rdi
movq %rdx, %rsi
movq %rcx, %rdx
movq %r12, %rcx
callq 0x2eac
testl %eax, %eax
jne 0x518c
cmpl $0x0, (%r12)
jne 0x518a
movl -0x4(%r15,%r14), %ecx
bswapl %ecx
movl 0x8(%rbx), %eax
testl %eax, %eax
je 0x517c
movq (%rbx), %rdi
movl $0x1, %esi
xorl %edx, %edx
movl $0x15b0, %r8d           # imm = 0x15B0
movl $0x15b0, %r9d           # imm = 0x15B0
movl $0x80078071, %r10d      # imm = 0x80078071
cmpl %r8d, %eax
movl $0x15b0, %r11d          # imm = 0x15B0
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 0x512e
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 0x5115
shll $0x10, %edx
orl %esi, %edx
jmp 0x5181
movl $0x6e, %eax
jmp 0x518c
movl $0x1, %edx
movl $0x3a, %eax
cmpl %ecx, %edx
jne 0x518c
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq