// File: /workspace/github_c_makefile_star2_O2/vlenhart[P]q3bsp/./stb_image_write.h
// Function: stbi_zlib_compress(unsigned char*, int, int*, int)
unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality)
{
   static unsigned short lengthc[] = { 3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258, 259 };
   static unsigned char  lengtheb[]= { 0,0,0,0,0,0,0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,  4,  5,  5,  5,  5,  0 };
   static unsigned short distc[]   = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577, 32768 };
   static unsigned char  disteb[]  = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13 };
   unsigned int bitbuf=0;
   int i,j, bitcount=0;
   unsigned char *out = NULL;
   unsigned char **hash_table[stbiw__ZHASH]; // 64KB on the stack!
   if (quality < 5) quality = 5;

   stbiw__sbpush(out, 0x78);   // DEFLATE 32K window
   stbiw__sbpush(out, 0x5e);   // FLEVEL = 1
   stbiw__zlib_add(1,1);  // BFINAL = 1
   stbiw__zlib_add(1,2);  // BTYPE = 1 -- fixed huffman

   for (i=0; i < stbiw__ZHASH; ++i)
      hash_table[i] = NULL;

   i=0;
   while (i < data_len-3) {
      // hash next 3 bytes of data to be compressed
      int h = stbiw__zhash(data+i)&(stbiw__ZHASH-1), best=3;
      unsigned char *bestloc = 0;
      unsigned char **hlist = hash_table[h];
      int n = stbiw__sbcount(hlist);
      for (j=0; j < n; ++j) {
         if (hlist[j]-data > i-32768) { // if entry lies within window
            int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i);
            if (d >= best) best=d,bestloc=hlist[j];
         }
      }
      // when hash table entry is too long, delete half the entries
      if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2*quality) {
         STBIW_MEMMOVE(hash_table[h], hash_table[h]+quality, sizeof(hash_table[h][0])*quality);
         stbiw__sbn(hash_table[h]) = quality;
      }
      stbiw__sbpush(hash_table[h],data+i);

      if (bestloc) {
         // "lazy matching" - check match at *next* byte, and if it's better, do cur byte as literal
         h = stbiw__zhash(data+i+1)&(stbiw__ZHASH-1);
         hlist = hash_table[h];
         n = stbiw__sbcount(hlist);
         for (j=0; j < n; ++j) {
            if (hlist[j]-data > i-32767) {
               int e = stbiw__zlib_countm(hlist[j], data+i+1, data_len-i-1);
               if (e > best) { // if next match is better, bail on current match
                  bestloc = NULL;
                  break;
               }
            }
         }
      }

      if (bestloc) {
         int d = (int) (data+i - bestloc); // distance back
         STBIW_ASSERT(d <= 32767 && best <= 258);
         for (j=0; best > lengthc[j+1]-1; ++j);
         stbiw__zlib_huff(j+257);
         if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]);
         for (j=0; d > distc[j+1]-1; ++j);
         stbiw__zlib_add(stbiw__zlib_bitrev(j,5),5);
         if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]);
         i += best;
      } else {
         stbiw__zlib_huffb(data[i]);
         ++i;
      }
   }
   // write out final bytes
   for (;i < data_len; ++i)
      stbiw__zlib_huffb(data[i]);
   stbiw__zlib_huff(256); // end of block
   // pad with 0 bits to byte boundary
   while (bitcount)
      stbiw__zlib_add(0,1);

   for (i=0; i < stbiw__ZHASH; ++i)
      (void) stbiw__sbfree(hash_table[i]);

   {
      // compute adler32 on input
      unsigned int i=0, s1=1, s2=0, blocklen = data_len % 5552;
      int j=0;
      while (j < data_len) {
         for (i=0; i < blocklen; ++i) s1 += data[j+i], s2 += s1;
         s1 %= 65521, s2 %= 65521;
         j += blocklen;
         blocklen = 5552;
      }
      stbiw__sbpush(out, (unsigned char) (s2 >> 8));
      stbiw__sbpush(out, (unsigned char) s2);
      stbiw__sbpush(out, (unsigned char) (s1 >> 8));
      stbiw__sbpush(out, (unsigned char) s1);
   }
   *out_len = stbiw__sbn(out);
   // make returned pointer freeable
   STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len);
   return (unsigned char *) stbiw__sbraw(out);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20088, %rsp          # imm = 0x20088
movq %rdx, -0x90(%rbp)
movq %rsi, -0x50(%rbp)
movq %rdi, -0x40(%rbp)
leaq -0x38(%rbp), %rbx
andq $0x0, (%rbx)
cmpl $0x6, %ecx
pushq $0x5
popq %rax
cmovgel %ecx, %eax
movq %rax, -0x88(%rbp)
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x488d
movq (%rbx), %rdi
movslq -0x4(%rdi), %rax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rdi)
movb $0x78, (%rdi,%rax)
movl -0x4(%rdi), %eax
leal 0x1(%rax), %ecx
cmpl -0x8(%rdi), %ecx
jl 0x4233
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x488d
movq (%rbx), %rdi
movl -0x4(%rdi), %eax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rdi)
cltq
movb $0x5e, (%rdi,%rax)
leaq -0x30(%rbp), %rbx
pushq $0x1
popq %r15
movl %r15d, (%rbx)
leaq -0x2c(%rbp), %r14
movl %r15d, (%r14)
movq %rbx, %rsi
movq %r14, %rdx
callq 0x490b
movl (%r14), %ecx
movl %r15d, %edx
shll %cl, %edx
orl %edx, (%rbx)
addl $0x2, %ecx
movl %ecx, (%r14)
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x490b
movq %rax, %rdi
movq %rax, -0x38(%rbp)
xorl %eax, %eax
movq -0x40(%rbp), %rcx
cmpq $0x4000, %rax           # imm = 0x4000
je 0x429a
andq $0x0, -0x200b0(%rbp,%rax,8)
incq %rax
jmp 0x4284
movq -0x50(%rbp), %rax
addl $-0x3, %eax
movl %eax, -0x80(%rbp)
movq -0x88(%rbp), %rax
leal (%rax,%rax), %edx
movl %edx, -0x7c(%rbp)
movl %eax, %eax
movq %rax, -0xa0(%rbp)
leaq (,%rax,8), %rax
movq %rax, -0x98(%rbp)
xorl %r14d, %r14d
cmpl -0x80(%rbp), %r14d
jge 0x4652
movq %rdi, -0x68(%rbp)
movslq %r14d, %rdi
addq %rcx, %rdi
movq %rdi, -0x58(%rbp)
callq 0x4981
andl $0x3fff, %eax           # imm = 0x3FFF
movq -0x200b0(%rbp,%rax,8), %rbx
testq %rbx, %rbx
je 0x4301
movslq -0x4(%rbx), %r13
jmp 0x4304
xorl %r13d, %r13d
leaq -0x200b0(,%rax,8), %rax
addq %rbp, %rax
movq %rax, -0xa8(%rbp)
leal -0x8000(%r14), %eax
movq -0x50(%rbp), %rcx
movq %r14, -0x70(%rbp)
subl %r14d, %ecx
movl %ecx, -0x78(%rbp)
testq %r13, %r13
movl $0x0, %ecx
cmovleq %rcx, %r13
movslq %eax, %r15
xorl %r14d, %r14d
pushq $0x3
popq %rax
movl %eax, -0x48(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x40(%rbp), %rcx
cmpq %r14, %r13
je 0x4392
movq (%rbx,%r14,8), %r12
movq %r12, %rax
subq %rcx, %rax
cmpq %r15, %rax
jle 0x438d
movq %r12, %rdi
movq -0x58(%rbp), %rsi
movl -0x78(%rbp), %edx
callq 0x49bf
movq -0x40(%rbp), %rcx
movl -0x48(%rbp), %edx
cmpl %edx, %eax
cmovgl %eax, %edx
movl %edx, -0x48(%rbp)
movq -0x60(%rbp), %rax
cmovgeq %r12, %rax
movq %rax, -0x60(%rbp)
incq %r14
jmp 0x434f
testq %rbx, %rbx
movq -0x58(%rbp), %r14
je 0x43cf
movl -0x4(%rbx), %eax
cmpl -0x7c(%rbp), %eax
jne 0x43c7
movq -0xa0(%rbp), %rax
leaq (%rbx,%rax,8), %rsi
movq %rbx, %rdi
movq -0x98(%rbp), %rdx
callq 0x23b0
movq -0x88(%rbp), %rax
movl %eax, -0x4(%rbx)
leal 0x1(%rax), %ecx
cmpl -0x8(%rbx), %ecx
jl 0x43ea
movq -0xa8(%rbp), %rbx
movq %rbx, %rdi
pushq $0x8
popq %rsi
callq 0x488d
movq (%rbx), %rbx
movl -0x4(%rbx), %eax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rbx)
cltq
movq %r14, (%rbx,%rax,8)
cmpq $0x0, -0x60(%rbp)
je 0x4481
movq -0x58(%rbp), %rax
leaq 0x1(%rax), %rdi
movq %rdi, -0x78(%rbp)
callq 0x4981
andl $0x3fff, %eax           # imm = 0x3FFF
movq -0x200b0(%rbp,%rax,8), %r12
testq %r12, %r12
je 0x4428
movl -0x4(%r12), %r13d
jmp 0x442b
xorl %r13d, %r13d
movq -0x70(%rbp), %rax
movl %eax, %r14d
notl %r14d
addl -0x50(%rbp), %r14d
addl $0xffff8001, %eax       # imm = 0xFFFF8001
movslq %eax, %r15
testl %r13d, %r13d
movl $0x0, %eax
cmovlel %eax, %r13d
xorl %ebx, %ebx
movq -0x40(%rbp), %rcx
cmpq %rbx, %r13
je 0x44b2
movq (%r12,%rbx,8), %rdi
movq %rdi, %rax
subq %rcx, %rax
cmpq %r15, %rax
jle 0x447c
movq -0x78(%rbp), %rsi
movl %r14d, %edx
callq 0x49bf
movq -0x40(%rbp), %rcx
cmpl -0x48(%rbp), %eax
jg 0x4481
incq %rbx
jmp 0x4453
movq -0x58(%rbp), %rax
movzbl (%rax), %edi
movl -0x2c(%rbp), %ebx
movl -0x30(%rbp), %r14d
cmpl $0x8f, %edi
ja 0x4512
addl $0x30, %edi
pushq $0x8
popq %rsi
callq 0x49e4
movl %ebx, %ecx
shll %cl, %eax
orl %eax, %r14d
movl %r14d, -0x30(%rbp)
addl $0x8, %ebx
jmp 0x452e
movq -0x58(%rbp), %r13
subl -0x60(%rbp), %r13d
cmpl $0x7fff, %r13d          # imm = 0x7FFF
movl -0x48(%rbp), %edx
jg 0x486e
cmpl $0x102, %edx            # imm = 0x102
jg 0x486e
xorl %edi, %edi
leaq -0x30(%rbp), %r15
leaq -0x2c(%rbp), %r12
leaq 0xbbd9(%rip), %rcx      # 0x100c0
movzwl 0x2(%rcx,%rdi,2), %eax
incq %rdi
cmpl %eax, %edx
jge 0x44e7
leaq -0x1(%rdi), %r14
cmpq $0x16, %r14
ja 0x4545
pushq $0x7
popq %rsi
callq 0x49e4
movl -0x2c(%rbp), %ecx
shll %cl, %eax
orl %eax, -0x30(%rbp)
addl $0x7, %ecx
jmp 0x455e
orl $0x100, %edi            # imm = 0x100
pushq $0x9
popq %rsi
callq 0x49e4
movl %ebx, %ecx
shll %cl, %eax
orl %eax, %r14d
movl %r14d, -0x30(%rbp)
addl $0x9, %ebx
movl %ebx, -0x2c(%rbp)
pushq $0x1
popq %rbx
movq -0x68(%rbp), %rdi
leaq -0x30(%rbp), %r15
leaq -0x2c(%rbp), %r12
jmp 0x4635
addl $0xa8, %edi
pushq $0x8
popq %rsi
callq 0x49e4
movl -0x2c(%rbp), %ecx
shll %cl, %eax
orl %eax, -0x30(%rbp)
addl $0x8, %ecx
movl %ecx, -0x2c(%rbp)
movq -0x68(%rbp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x490b
movq %rax, %rbx
movl %r14d, %eax
leaq -0x1c(%rax), %rcx
cmpq $-0x14, %rcx
jb 0x45b9
leaq 0xbb39(%rip), %rcx      # 0x100c0
movzwl (%rcx,%rax,2), %ecx
movl -0x48(%rbp), %edx
subl %ecx, %edx
movl -0x2c(%rbp), %ecx
shll %cl, %edx
orl %edx, -0x30(%rbp)
leaq 0xbb61(%rip), %rdx      # 0x10100
movzbl (%rax,%rdx), %eax
addl %ecx, %eax
movl %eax, -0x2c(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x490b
movq %rax, %rbx
leaq 0xbb60(%rip), %rcx      # 0x10120
pushq $-0x1
popq %r14
movzwl 0x4(%rcx,%r14,2), %eax
incq %r14
cmpl %r13d, %eax
jle 0x45c4
movl %r14d, %edi
pushq $0x5
popq %rsi
callq 0x49e4
movl -0x2c(%rbp), %ecx
shll %cl, %eax
orl %eax, -0x30(%rbp)
addl $0x5, %ecx
movl %ecx, -0x2c(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x490b
movq %rax, %rdi
cmpq $0x4, %r14
jae 0x4607
movl -0x48(%rbp), %ebx
jmp 0x4643
movl %r14d, %eax
leaq 0xbb0f(%rip), %rcx      # 0x10120
movzwl (%rcx,%rax,2), %ecx
subl %ecx, %r13d
movl -0x2c(%rbp), %ecx
shll %cl, %r13d
orl %r13d, -0x30(%rbp)
leaq 0xbb37(%rip), %rdx      # 0x10160
movzbl (%rax,%rdx), %eax
addl %ecx, %eax
movl %eax, -0x2c(%rbp)
movl -0x48(%rbp), %ebx
movq %r15, %rsi
movq %r12, %rdx
callq 0x490b
movq %rax, %rdi
addl -0x70(%rbp), %ebx
movl %ebx, %r14d
movq -0x40(%rbp), %rcx
jmp 0x42cc
movslq %r14d, %r15
movq %rdi, -0x38(%rbp)
movslq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq -0x48(%rbp), %r15
jge 0x46c4
movq %rdi, %r12
movzbl (%rcx,%r15), %edi
movl -0x2c(%rbp), %r14d
movl -0x30(%rbp), %ebx
cmpl $0x8f, %edi
ja 0x4685
addl $0x30, %edi
pushq $0x8
jmp 0x468d
orl $0x100, %edi            # imm = 0x100
pushq $0x9
popq %r13
movl %r13d, %esi
callq 0x49e4
movl %r14d, %ecx
shll %cl, %eax
orl %eax, %ebx
movl %ebx, -0x30(%rbp)
addl %r14d, %r13d
movl %r13d, -0x2c(%rbp)
movq %r12, %rdi
leaq -0x30(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
callq 0x490b
movq %rax, %rdi
incq %r15
movq -0x40(%rbp), %rcx
jmp 0x4661
movq %rdi, -0x38(%rbp)
pushq $0x7
popq %rsi
movq %rdi, %rbx
xorl %edi, %edi
callq 0x49e4
movq %rbx, %rdi
leaq -0x2c(%rbp), %rbx
movl (%rbx), %ecx
shll %cl, %eax
leaq -0x30(%rbp), %r14
orl %eax, (%r14)
addl $0x7, %ecx
movl %ecx, -0x2c(%rbp)
movq %r14, %rsi
movq %rbx, %rdx
callq 0x490b
movq %rax, %rdi
movl -0x2c(%rbp), %eax
leal 0x1(%rax), %ecx
testl %eax, %eax
jne 0x46ea
movq %rdi, %r14
movq %rdi, -0x38(%rbp)
xorl %ebx, %ebx
movq -0x40(%rbp), %r9
cmpq $0x4000, %rbx           # imm = 0x4000
je 0x473a
movq -0x200b0(%rbp,%rbx,8), %rdi
testq %rdi, %rdi
je 0x4735
addq $-0x8, %rdi
callq 0x22b0
movq -0x40(%rbp), %r9
incq %rbx
jmp 0x4712
movl $0x15b0, %ecx           # imm = 0x15B0
movq -0x50(%rbp), %rax
cltd
idivl %ecx
movl %edx, %edi
xorl %r15d, %r15d
pushq $0x1
popq %rbx
movl $0xfff1, %esi           # imm = 0xFFF1
xorl %ecx, %ecx
cmpl -0x50(%rbp), %ecx
jge 0x4791
movl %edi, %eax
movl %ecx, %edx
subq $0x1, %rax
jb 0x4776
movl %edx, %r8d
movzbl (%r9,%r8), %r8d
addl %r8d, %ebx
addl %ebx, %r15d
incl %edx
jmp 0x475e
movl %ebx, %eax
xorl %edx, %edx
divl %esi
movl %edx, %ebx
movl %r15d, %eax
xorl %edx, %edx
divl %esi
addl %edi, %ecx
movl $0x15b0, %edi           # imm = 0x15B0
movl %edx, %r15d
jmp 0x4755
testq %r14, %r14
je 0x47a6
movq %r14, %rdx
movl -0x4(%r14), %eax
leal 0x1(%rax), %ecx
cmpl -0x8(%r14), %ecx
jl 0x47be
leaq -0x38(%rbp), %r14
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x488d
movq (%r14), %rdx
movl -0x4(%rdx), %eax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rdx)
cltq
movl %r15d, %ecx
movb %ch, (%rdx,%rax)
movl -0x4(%rdx), %eax
incl %eax
cmpl -0x8(%rdx), %eax
jl 0x47df
leaq -0x38(%rbp), %rdi
pushq $0x1
popq %rsi
callq 0x488d
movq -0x38(%rbp), %rsi
movslq -0x4(%rsi), %rax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rsi)
movb %r15b, (%rsi,%rax)
movl -0x4(%rsi), %eax
leal 0x1(%rax), %ecx
cmpl -0x8(%rsi), %ecx
jl 0x4814
leaq -0x38(%rbp), %r14
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x488d
movq (%r14), %rsi
movl -0x4(%rsi), %eax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rsi)
cltq
movb %bh, (%rsi,%rax)
movl -0x4(%rsi), %eax
leal 0x1(%rax), %ecx
cmpl -0x8(%rsi), %ecx
jl 0x483f
leaq -0x38(%rbp), %r14
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x488d
movq (%r14), %rsi
movl -0x4(%rsi), %eax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rsi)
cltq
movb %bl, (%rsi,%rax)
movslq -0x4(%rsi), %rdx
movq -0x90(%rbp), %rax
movl %edx, (%rax)
leaq -0x8(%rsi), %rdi
addq $0x20088, %rsp          # imm = 0x20088
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x23b0
leaq 0xbac5(%rip), %rdi      # 0x1033a
leaq 0xb9b5(%rip), %rsi      # 0x10231
leaq 0xbad1(%rip), %rcx      # 0x10354
movl $0x20f, %edx            # imm = 0x20F
callq 0x2180