// File: /workspace/github_c_makefile_star2_O3/tditlu[P]shadetabler/src/lodepng/lodepng.c
// Function: lodepng_zlib_compress
unsigned lodepng_zlib_compress(unsigned char** out, size_t* outsize, const unsigned char* in,
                               size_t insize, const LodePNGCompressSettings* settings) {
  size_t i;
  unsigned error;
  unsigned char* deflatedata = 0;
  size_t deflatesize = 0;

  error = deflate(&deflatedata, &deflatesize, in, insize, settings);

  *out = NULL;
  *outsize = 0;
  if(!error) {
    *outsize = deflatesize + 6;
    *out = (unsigned char*)lodepng_malloc(*outsize);
    if(!*out) error = 83; /*alloc fail*/
  }

  if(!error) {
    unsigned ADLER32 = adler32(in, (unsigned)insize);
    /*zlib data: 1 byte CMF (CM+CINFO), 1 byte FLG, deflate data, 4 byte ADLER32 checksum of the Decompressed data*/
    unsigned CMF = 120; /*0b01111000: CM 8, CINFO 7. With CINFO 7, any window size up to 32768 can be used.*/
    unsigned FLEVEL = 0;
    unsigned FDICT = 0;
    unsigned CMFFLG = 256 * CMF + FDICT * 32 + FLEVEL * 64;
    unsigned FCHECK = 31 - CMFFLG % 31;
    CMFFLG += FCHECK;

    (*out)[0] = (unsigned char)(CMFFLG >> 8);
    (*out)[1] = (unsigned char)(CMFFLG & 255);
    for(i = 0; i != deflatesize; ++i) (*out)[i + 2] = deflatedata[i];
    lodepng_set32bitInt(&(*out)[*outsize - 4], ADLER32);
  }

  lodepng_free(deflatedata);
  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movq 0x20(%r8), %rax
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
testq %rax, %rax
je 0x5414
callq *%rax
jmp 0x5419
callq 0x3e2a
movl %eax, %ebp
xorl %eax, %eax
movq %rax, (%r14)
movq %rax, (%rbx)
testl %ebp, %ebp
jne 0x5515
movq 0x8(%rsp), %r13
leaq 0x6(%r13), %rdi
movq %rdi, (%rbx)
callq 0x1140
movq %rax, (%r14)
testq %rax, %rax
je 0x54cf
testl %r15d, %r15d
je 0x54d6
movl $0x1, %edx
xorl %ecx, %ecx
movl $0x15b0, %esi           # imm = 0x15B0
movl $0x15b0, %edi           # imm = 0x15B0
movl $0x80078071, %r8d       # imm = 0x80078071
cmpl %esi, %r15d
movl $0x15b0, %r9d           # imm = 0x15B0
cmovbl %r15d, %r9d
movl %r15d, %r10d
cmpq %rdi, %r10
cmovaeq %rdi, %r10
xorl %r11d, %r11d
movzbl (%r12,%r11), %ebp
addl %ebp, %edx
addl %edx, %ecx
incq %r11
cmpl %r11d, %r10d
jne 0x5482
movl %r9d, %r10d
addq %r10, %r12
movl %edx, %r10d
imulq %r8, %r10
shrq $0x2f, %r10
imull $0xfff1, %r10d, %r10d   # imm = 0xFFF1
subl %r10d, %edx
movl %ecx, %r10d
imulq %r8, %r10
shrq $0x2f, %r10
imull $0xfff1, %r10d, %r10d   # imm = 0xFFF1
subl %r10d, %ecx
subl %r9d, %r15d
jne 0x5468
shll $0x10, %ecx
orl %edx, %ecx
jmp 0x54db
movl $0x53, %ebp
jmp 0x5515
movl $0x1, %ecx
movw $0x178, (%rax)          # imm = 0x178
testq %r13, %r13
je 0x5508
xorl %eax, %eax
movq 0x10(%rsp), %rdx
movb (%rdx,%rax), %dl
movq (%r14), %rsi
movb %dl, 0x2(%rsi,%rax)
incq %rax
cmpq 0x8(%rsp), %rax
jne 0x54e7
movq (%r14), %rax
movq (%rbx), %rdx
jmp 0x550d
movl $0x6, %edx
bswapl %ecx
movl %ecx, -0x4(%rax,%rdx)
xorl %ebp, %ebp
movq 0x10(%rsp), %rdi
callq 0x1030
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq