// File: /workspace/github_c_makefile_star2_O3/Joy-Division[P]tools-mgs/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)
{
  /*initially, *out must be NULL and outsize 0, if you just give some random *out
  that's pointing to a non allocated buffer, this'll crash*/
  ucvector outv;
  size_t i;
  unsigned error;
  unsigned char* deflatedata = 0;
  size_t deflatesize = 0;

  /*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;

  /*ucvector-controlled version of the output buffer, for dynamic array*/
  ucvector_init_buffer(&outv, *out, *outsize);

  ucvector_push_back(&outv, (unsigned char)(CMFFLG >> 8));
  ucvector_push_back(&outv, (unsigned char)(CMFFLG & 255));

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

  if(!error)
  {
    unsigned ADLER32 = adler32(in, (unsigned)insize);
    for(i = 0; i != deflatesize; ++i) ucvector_push_back(&outv, deflatedata[i]);
    lodepng_free(deflatedata);
    lodepng_add32bitInt(&outv, ADLER32);
  }

  *out = outv.data;
  *outsize = outv.size;

  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, %r15
movq %rdx, %r12
xorl %eax, %eax
movq %rax, 0x20(%rsp)
movq %rax, 0x18(%rsp)
movq %rdi, 0x48(%rsp)
movq (%rdi), %rbp
movq %rsi, 0x50(%rsp)
movq (%rsi), %r14
movq %rbp, 0x28(%rsp)
movq %r14, 0x30(%rsp)
movq %r14, 0x38(%rsp)
movq %r14, %r13
movq $-0x1, %rbx
incq %r13
je 0x454a
movq %r8, 0x10(%rsp)
leaq (%r14,%r14), %rax
leaq (,%r13,2), %rbx
addq %r13, %rbx
shrq %rbx
cmpq %r13, %rax
cmovbq %r13, %rbx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x1130
testq %rax, %rax
je 0x465f
movq %rbx, 0x38(%rsp)
movq %rax, 0x28(%rsp)
movq %rax, %rbp
movq 0x10(%rsp), %r8
movq %r13, 0x30(%rsp)
movb $0x78, -0x1(%rbp,%r13)
addq $0x2, %r14
movq %r14, %r13
movq %rbx, %r14
cmpq %r13, %r14
jae 0x459f
addq %r14, %r14
leaq (,%r13,2), %rbx
addq %r13, %rbx
shrq %rbx
cmpq %r13, %r14
cmovbq %r13, %rbx
movq %rbp, %rdi
movq %rbx, %rsi
movq %r8, %r14
callq 0x1130
movq %r14, %r8
testq %rax, %rax
je 0x45aa
movq %rax, %rbp
movq %rbx, 0x38(%rsp)
movq %rax, 0x28(%rsp)
movq %r13, 0x30(%rsp)
movb $0x1, -0x1(%rbp,%r13)
movq 0x20(%r8), %rax
leaq 0x20(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movq %r12, %rdx
movq %r15, %rcx
testq %rax, %rax
je 0x45c7
callq *%rax
jmp 0x45cc
callq 0x2925
testl %eax, %eax
jne 0x471d
testl %r15d, %r15d
je 0x4669
movl $0x1, %r11d
xorl %r13d, %r13d
movl $0x15ae, %ecx           # imm = 0x15AE
movl $0x15ae, %edx           # imm = 0x15AE
movl $0x80078071, %esi       # imm = 0x80078071
cmpl %ecx, %r15d
movl $0x15ae, %edi           # imm = 0x15AE
cmovbl %r15d, %edi
movl %r15d, %r8d
cmpq %rdx, %r8
cmovaeq %rdx, %r8
xorl %r9d, %r9d
movzbl (%r12,%r9), %r10d
addl %r10d, %r11d
addl %r11d, %r13d
incq %r9
cmpl %r9d, %r8d
jne 0x460e
movl %edi, %r8d
addq %r8, %r12
movl %r11d, %r8d
imulq %rsi, %r8
shrq $0x2f, %r8
imull $0xfff1, %r8d, %r8d     # imm = 0xFFF1
subl %r8d, %r11d
movl %r13d, %r8d
imulq %rsi, %r8
shrq $0x2f, %r8
imull $0xfff1, %r8d, %r8d     # imm = 0xFFF1
subl %r8d, %r13d
subl %edi, %r15d
jne 0x45f5
shll $0x10, %r13d
orl %r11d, %r13d
jmp 0x466f
movq 0x10(%rsp), %r8
jmp 0x455f
movl $0x1, %r13d
movq 0x28(%rsp), %r14
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %r15
cmpq $0x0, 0x18(%rsp)
movl %eax, 0x44(%rsp)
je 0x46f4
xorl %ebp, %ebp
movq 0x20(%rsp), %rax
movb (%rax,%rbp), %dil
leaq 0x1(%rsi), %r12
cmpq %r12, %r15
jae 0x46d6
leaq (%r15,%r15), %rax
leaq (%r12,%r12,2), %rbx
shrq %rbx
cmpq %r12, %rax
cmovbq %r12, %rbx
movb %dil, 0xf(%rsp)
movq %r14, %rdi
movq %rsi, 0x10(%rsp)
movq %rbx, %rsi
callq 0x1130
movb 0xf(%rsp), %dil
movq 0x10(%rsp), %rsi
testq %rax, %rax
jne 0x46dc
jmp 0x46ea
movq %r14, %rax
movq %r15, %rbx
movb %dil, -0x1(%rax,%r12)
movq %rax, %r14
movq %rbx, %r15
movq %r12, %rsi
incq %rbp
cmpq 0x18(%rsp), %rbp
jne 0x468c
leaq 0x28(%rsp), %rbx
movq %rsi, 0x8(%rbx)
movq %r15, 0x10(%rbx)
movq %r14, (%rbx)
movq 0x20(%rsp), %rdi
callq 0x1030
movq %rbx, %rdi
movl %r13d, %esi
callq 0x4746
movl 0x44(%rsp), %eax
movq 0x28(%rsp), %rdx
movq 0x48(%rsp), %rcx
movq %rdx, (%rcx)
movq 0x30(%rsp), %rdx
movq 0x50(%rsp), %rcx
movq %rdx, (%rcx)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq