// File: /workspace/github_cpp_makefile_star2_O2/alan0201tw[P]RayTracer/include/stb_image_write.h
// Function: stbi_zlib_compress
STBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality)
{
#ifdef STBIW_ZLIB_COMPRESS
   // user provided a zlib compress implementation, use that
   return STBIW_ZLIB_COMPRESS(data, data_len, out_len, quality);
#else // use builtin
   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 = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(char**));
   if (hash_table == NULL)
      return NULL;
   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]);
   STBIW_FREE(hash_table);

   {
      // compute adler32 on input
      unsigned int s1=1, s2=0;
      int blocklen = (int) (data_len % 5552);
      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, STBIW_UCHAR(s2 >> 8));
      stbiw__sbpush(out, STBIW_UCHAR(s2));
      stbiw__sbpush(out, STBIW_UCHAR(s1 >> 8));
      stbiw__sbpush(out, STBIW_UCHAR(s1));
   }
   *out_len = stbiw__sbn(out);
   // make returned pointer freeable
   STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len);
   return (unsigned char *) stbiw__sbraw(out);
#endif // STBIW_ZLIB_COMPRESS
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %ecx, %ebx
movq %rdx, 0x68(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, 0x38(%rsp)
andq $0x0, 0x18(%rsp)
movl $0x20000, %edi          # imm = 0x20000
callq 0x6510
testq %rax, %rax
je 0x2283f
movq %rax, %r15
cmpl $0x6, %ebx
pushq $0x5
popq %rax
cmovgel %ebx, %eax
movq %rax, 0x60(%rsp)
leaq 0x18(%rsp), %rbx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x22872
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 0x221c0
leaq 0x18(%rsp), %rbx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x22872
movq (%rbx), %rdi
movl -0x4(%rdi), %eax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rdi)
cltq
movb $0x5e, (%rdi,%rax)
leaq 0x10(%rsp), %rbx
pushq $0x1
popq %rbp
movl %ebp, (%rbx)
leaq 0xc(%rsp), %r14
movl %ebp, (%r14)
movq %rbx, %rsi
movq %r14, %rdx
callq 0x228ea
movl (%r14), %ecx
movl %ebp, %edx
shll %cl, %edx
orl %edx, (%rbx)
addl $0x2, %ecx
movl %ecx, (%r14)
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x228ea
movq %rax, %rdi
movq %rax, 0x18(%rsp)
xorl %eax, %eax
cmpq $0x4000, %rax           # imm = 0x4000
je 0x2221f
andq $0x0, (%r15,%rax,8)
incq %rax
jmp 0x2220d
movq 0x28(%rsp), %rax
addl $-0x3, %eax
movl %eax, 0x5c(%rsp)
movq 0x60(%rsp), %rax
leal (%rax,%rax), %ecx
movl %ecx, 0x58(%rsp)
movl %eax, %eax
movq %rax, 0x78(%rsp)
leaq (,%rax,8), %rax
movq %rax, 0x70(%rsp)
xorl %r13d, %r13d
movq %r15, 0x30(%rsp)
cmpl 0x5c(%rsp), %r13d
jge 0x22603
movq %rdi, 0x48(%rsp)
movslq %r13d, %rdi
addq 0x38(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x22953
andl $0x3fff, %eax           # imm = 0x3FFF
movq (%r15,%rax,8), %rbx
testq %rbx, %rbx
je 0x22289
movslq -0x4(%rbx), %r14
jmp 0x2228c
xorl %r14d, %r14d
leaq (%r15,%rax,8), %rax
movq %rax, 0x80(%rsp)
leal -0x8000(%r13), %eax
movq 0x28(%rsp), %rcx
movl %ecx, %r12d
movq %r13, 0x50(%rsp)
subl %r13d, %r12d
testq %r14, %r14
movl $0x0, %ecx
cmovleq %rcx, %r14
movslq %eax, %r13
xorl %r15d, %r15d
pushq $0x3
popq %rax
movl %eax, 0x14(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x20(%rsp), %rdx
cmpq %r15, %r14
je 0x22321
movq (%rbx,%r15,8), %rbp
movq %rbp, %rax
subq 0x38(%rsp), %rax
cmpq %r13, %rax
jle 0x2231c
movq %rbp, %rdi
movq 0x20(%rsp), %rsi
movl %r12d, %edx
callq 0x2298c
movq 0x20(%rsp), %rdx
movl 0x14(%rsp), %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
movl %ecx, 0x14(%rsp)
movq 0x40(%rsp), %rax
cmovgeq %rbp, %rax
movq %rax, 0x40(%rsp)
incq %r15
jmp 0x222d6
testq %rbx, %rbx
je 0x2235a
movl -0x4(%rbx), %eax
cmpl 0x58(%rsp), %eax
jne 0x22352
movq 0x78(%rsp), %rax
leaq (%rbx,%rax,8), %rsi
movq %rbx, %rdi
movq 0x70(%rsp), %rdx
callq 0x6670
movq 0x20(%rsp), %rdx
movq 0x60(%rsp), %rax
movl %eax, -0x4(%rbx)
leal 0x1(%rax), %ecx
cmpl -0x8(%rbx), %ecx
jl 0x2237b
movq 0x80(%rsp), %rbx
movq %rbx, %rdi
pushq $0x8
popq %rsi
callq 0x22872
movq 0x20(%rsp), %rdx
movq (%rbx), %rbx
movl -0x4(%rbx), %eax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rbx)
cltq
movq %rdx, (%rbx,%rax,8)
cmpq $0x0, 0x40(%rsp)
je 0x22413
leaq 0x1(%rdx), %rbx
movq %rbx, %rdi
callq 0x22953
andl $0x3fff, %eax           # imm = 0x3FFF
movq 0x30(%rsp), %rcx
movq (%rcx,%rax,8), %r12
testq %r12, %r12
je 0x223b6
movl -0x4(%r12), %ebp
jmp 0x223b8
xorl %ebp, %ebp
movq 0x50(%rsp), %rax
movl %eax, %r14d
notl %r14d
addl 0x28(%rsp), %r14d
addl $0xffff8001, %eax       # imm = 0xFFFF8001
movslq %eax, %r15
testl %ebp, %ebp
movl $0x0, %eax
cmovlel %eax, %ebp
xorl %r13d, %r13d
movq 0x20(%rsp), %rdx
cmpq %r13, %rbp
je 0x22447
movq (%r12,%r13,8), %rdi
movq %rdi, %rax
subq 0x38(%rsp), %rax
cmpq %r15, %rax
jle 0x2240e
movq %rbx, %rsi
movl %r14d, %edx
callq 0x2298c
movq 0x20(%rsp), %rdx
cmpl 0x14(%rsp), %eax
jg 0x22413
incq %r13
jmp 0x223e2
movzbl (%rdx), %edi
movl 0xc(%rsp), %ebx
movl 0x10(%rsp), %ebp
cmpl $0x8f, %edi
ja 0x224af
addl $0x30, %edi
pushq $0x8
popq %rsi
callq 0x229ac
movl %ebx, %ecx
shll %cl, %eax
orl %eax, %ebp
movl %ebp, 0x10(%rsp)
addl $0x8, %ebx
jmp 0x224ca
subl 0x40(%rsp), %edx
cmpl $0x7fff, %edx           # imm = 0x7FFF
movl 0x14(%rsp), %esi
jg 0x22853
cmpl $0x102, %esi            # imm = 0x102
jg 0x22853
xorl %edi, %edi
movq 0x30(%rsp), %r15
leaq 0x10(%rsp), %r12
leaq 0xc(%rsp), %r13
leaq 0xf271(%rip), %rcx      # 0x316f0
movzwl 0x2(%rcx,%rdi,2), %eax
incq %rdi
cmpl %eax, %esi
jge 0x2247f
movq %rdx, %rbp
leaq -0x1(%rdi), %r14
cmpq $0x16, %r14
ja 0x224ea
pushq $0x7
popq %rsi
callq 0x229ac
movl 0xc(%rsp), %ecx
shll %cl, %eax
orl %eax, 0x10(%rsp)
addl $0x7, %ecx
jmp 0x22505
orl $0x100, %edi            # imm = 0x100
pushq $0x9
popq %rsi
callq 0x229ac
movl %ebx, %ecx
shll %cl, %eax
orl %eax, %ebp
movl %ebp, 0x10(%rsp)
addl $0x9, %ebx
movl %ebx, 0xc(%rsp)
pushq $0x1
popq %rbx
movq 0x30(%rsp), %r15
movq 0x48(%rsp), %rdi
leaq 0x10(%rsp), %r12
leaq 0xc(%rsp), %r13
jmp 0x225e9
addl $0xa8, %edi
pushq $0x8
popq %rsi
callq 0x229ac
movl 0xc(%rsp), %ecx
shll %cl, %eax
orl %eax, 0x10(%rsp)
addl $0x8, %ecx
movl %ecx, 0xc(%rsp)
movq 0x48(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x228ea
movq %rax, %rbx
movl %r14d, %eax
leaq -0x1c(%rax), %rcx
cmpq $-0x14, %rcx
jb 0x22566
leaq 0xf1c0(%rip), %rcx      # 0x316f0
movzwl (%rcx,%rax,2), %ecx
movl 0x14(%rsp), %edx
subl %ecx, %edx
movl 0xc(%rsp), %ecx
shll %cl, %edx
orl %edx, 0x10(%rsp)
leaq 0xf1e5(%rip), %rdx      # 0x31730
movzbl (%rax,%rdx), %eax
addl %ecx, %eax
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x228ea
movq %rax, %rbx
leaq 0xf1e3(%rip), %rcx      # 0x31750
movq %rbp, %rdx
pushq $-0x1
popq %r14
movzwl 0x4(%rcx,%r14,2), %eax
incq %r14
cmpl %edx, %eax
jle 0x22574
movl %r14d, %edi
pushq $0x5
popq %rsi
callq 0x229ac
movl 0xc(%rsp), %ecx
shll %cl, %eax
orl %eax, 0x10(%rsp)
addl $0x5, %ecx
movl %ecx, 0xc(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x228ea
movq %rax, %rdi
cmpq $0x4, %r14
jae 0x225ba
movl 0x14(%rsp), %ebx
jmp 0x225f7
movl %r14d, %eax
leaq 0xf18c(%rip), %rcx      # 0x31750
movzwl (%rcx,%rax,2), %ecx
subl %ecx, %ebp
movl 0xc(%rsp), %ecx
shll %cl, %ebp
orl %ebp, 0x10(%rsp)
leaq 0xf1b5(%rip), %rdx      # 0x31790
movzbl (%rax,%rdx), %eax
addl %ecx, %eax
movl %eax, 0xc(%rsp)
movl 0x14(%rsp), %ebx
movq %r12, %rsi
movq %r13, %rdx
callq 0x228ea
movq %rax, %rdi
addl 0x50(%rsp), %ebx
movl %ebx, %r13d
jmp 0x22253
movslq %r13d, %r15
movq %rdi, 0x18(%rsp)
movslq 0x28(%rsp), %r13
cmpq %r13, %r15
jge 0x22679
movq %rdi, %rbx
movq 0x38(%rsp), %rax
movzbl (%rax,%r15), %edi
movl 0xc(%rsp), %r12d
movl 0x10(%rsp), %ebp
cmpl $0x8f, %edi
ja 0x2263a
addl $0x30, %edi
pushq $0x8
jmp 0x22642
orl $0x100, %edi            # imm = 0x100
pushq $0x9
popq %r14
movl %r14d, %esi
callq 0x229ac
movl %r12d, %ecx
shll %cl, %eax
orl %eax, %ebp
movl %ebp, 0x10(%rsp)
addl %r12d, %r14d
movl %r14d, 0xc(%rsp)
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0x228ea
movq %rax, %rdi
incq %r15
jmp 0x22610
movq %rdi, 0x18(%rsp)
pushq $0x7
popq %rsi
movq %rdi, %rbx
xorl %edi, %edi
callq 0x229ac
movq %rbx, %rdi
leaq 0xc(%rsp), %rbx
movl (%rbx), %ecx
shll %cl, %eax
leaq 0x10(%rsp), %r14
orl %eax, (%r14)
addl $0x7, %ecx
movl %ecx, 0xc(%rsp)
movq %r14, %rsi
movq %rbx, %rdx
callq 0x228ea
movq %rax, %rdi
movl 0xc(%rsp), %eax
leal 0x1(%rax), %ecx
testl %eax, %eax
jne 0x226a2
movq %rdi, %r15
movq %rdi, 0x18(%rsp)
xorl %ebx, %ebx
movq 0x30(%rsp), %r14
cmpq $0x4000, %rbx           # imm = 0x4000
je 0x226ee
movq (%r14,%rbx,8), %rdi
testq %rdi, %rdi
je 0x226e9
addq $-0x8, %rdi
callq 0x64d0
incq %rbx
jmp 0x226ce
movq %r14, %rdi
callq 0x64d0
movl $0x15b0, %ecx           # imm = 0x15B0
movq 0x28(%rsp), %rax
cltd
idivl %ecx
movl %edx, %ecx
pushq $0x1
popq %rbp
xorl %esi, %esi
movl $0xfff1, %edi           # imm = 0xFFF1
xorl %ebx, %ebx
cmpl 0x28(%rsp), %esi
jge 0x22760
movslq %esi, %rax
testl %ecx, %ecx
movl $0x0, %edx
cmovgl %ecx, %edx
addq 0x38(%rsp), %rax
xorl %r8d, %r8d
cmpq %r8, %rdx
je 0x22747
movzbl (%rax,%r8), %r9d
movl %ebp, %r10d
addl %r9d, %r10d
movl %r10d, %ebp
addl %r10d, %ebx
incq %r8
jmp 0x2272c
movl %ebp, %eax
xorl %edx, %edx
divl %edi
movl %edx, %ebp
movl %ebx, %eax
xorl %edx, %edx
divl %edi
addl %ecx, %esi
movl $0x15b0, %ecx           # imm = 0x15B0
movl %edx, %ebx
jmp 0x22711
testq %r15, %r15
je 0x22775
movq %r15, %rdx
movl -0x4(%r15), %eax
leal 0x1(%rax), %ecx
cmpl -0x8(%r15), %ecx
jl 0x2278e
leaq 0x18(%rsp), %r14
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x22872
movq (%r14), %rdx
movl -0x4(%rdx), %eax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rdx)
cltq
movb %bh, (%rdx,%rax)
movl -0x4(%rdx), %eax
incl %eax
cmpl -0x8(%rdx), %eax
jl 0x227ad
leaq 0x18(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x22872
movq 0x18(%rsp), %rsi
movslq -0x4(%rsi), %rax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rsi)
movb %bl, (%rsi,%rax)
movl -0x4(%rsi), %eax
leal 0x1(%rax), %ecx
cmpl -0x8(%rsi), %ecx
jl 0x227e3
leaq 0x18(%rsp), %rbx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x22872
movq (%rbx), %rsi
movl -0x4(%rsi), %eax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rsi)
cltq
movl %ebp, %ecx
movb %ch, (%rsi,%rax)
movl -0x4(%rsi), %eax
leal 0x1(%rax), %ecx
cmpl -0x8(%rsi), %ecx
jl 0x22811
leaq 0x18(%rsp), %rbx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x22872
movq (%rbx), %rsi
movl -0x4(%rsi), %eax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rsi)
cltq
movb %bpl, (%rsi,%rax)
movslq -0x4(%rsi), %rdx
movq 0x68(%rsp), %rax
movl %edx, (%rax)
leaq -0x8(%rsi), %rdi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6670
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10d9d(%rip), %rdi     # 0x335f7
leaq 0x10db0(%rip), %rsi     # 0x33611
leaq 0x10dc3(%rip), %rcx     # 0x3362b
movl $0x39a, %edx            # imm = 0x39A
callq 0x6280