// File: /workspace/github_cpp_makefile_star2_O3/srajangarg[P]raytracer/src/core/stb_image_write.hpp
// 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 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);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20058, %rsp          # imm = 0x20058
movq %rdx, 0x38(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, %r15
leaq 0x8(%rsp), %rbx
movq $0x0, (%rbx)
cmpl $0x6, %ecx
movl $0x5, %eax
cmovgel %ecx, %eax
movq %rax, 0x28(%rsp)
movl $0x1, %ebp
movq %rbx, %rdi
movl $0x1, %esi
callq 0x25186
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 0x24a47
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x25186
movq (%rbx), %rdi
movl -0x4(%rdi), %eax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rdi)
cltq
movb $0x5e, (%rdi,%rax)
leaq 0x4(%rsp), %rbx
movl %ebp, (%rbx)
movq %rsp, %r12
movl %ebp, (%r12)
movq %rbx, %rsi
movq %r12, %rdx
callq 0x25203
movl (%r12), %ecx
shll %cl, %ebp
orl %ebp, (%rbx)
addl $0x2, %ecx
movl %ecx, (%r12)
movq %rax, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x25203
movq %rax, %rbp
movq %rax, 0x8(%rsp)
leaq 0x50(%rsp), %rdi
xorl %ebx, %ebx
movl $0x20000, %edx          # imm = 0x20000
xorl %esi, %esi
callq 0x41c0
movq 0x10(%rsp), %r12
cmpl $0x4, %r12d
jl 0x24ef9
leal -0x3(%r12), %eax
movl %eax, 0x24(%rsp)
movq 0x28(%rsp), %rax
leal (%rax,%rax), %ecx
movl %ecx, 0x20(%rsp)
movl %eax, %eax
movq %rax, 0x48(%rsp)
leaq (,%rax,8), %rax
movq %rax, 0x40(%rsp)
xorl %esi, %esi
movslq %esi, %rax
leaq (%r15,%rax), %r12
movzwl (%r15,%rax), %ecx
movzbl 0x2(%r15,%rax), %eax
shll $0x10, %eax
orl %ecx, %eax
leal (,%rax,8), %ecx
xorl %eax, %ecx
movl %ecx, %eax
shrl $0x5, %eax
addl %ecx, %eax
movl %eax, %ecx
shll $0x4, %ecx
xorl %eax, %ecx
movl %ecx, %eax
shrl $0x11, %eax
addl %ecx, %eax
movl %eax, %r14d
shrl $0x6, %r14d
addl %eax, %r14d
andl $0x3fff, %r14d          # imm = 0x3FFF
movq 0x50(%rsp,%r14,8), %r13
testq %r13, %r13
movq %rbp, 0x18(%rsp)
movq %rsi, 0x30(%rsp)
je 0x24bac
movslq -0x4(%r13), %rax
testq %rax, %rax
jle 0x24bb5
leal -0x8000(%rsi), %ecx
movslq %ecx, %rcx
movq 0x10(%rsp), %rdx
subl %esi, %edx
leal -0x1(%rdx), %esi
movl $0x101, %edi            # imm = 0x101
cmpl %edi, %esi
cmovael %edi, %esi
incl %esi
movl $0x3, %ebx
xorl %edi, %edi
xorl %ebp, %ebp
movq (%r13,%rdi,8), %r8
movq %r8, %r9
subq %r15, %r9
cmpq %rcx, %r9
jle 0x24b9d
xorl %r9d, %r9d
testl %edx, %edx
jle 0x24b92
movb (%r8,%r9), %r10b
cmpb (%r12,%r9), %r10b
jne 0x24b92
incq %r9
cmpq %r9, %rsi
jne 0x24b7d
movl %esi, %r9d
cmpl %ebx, %r9d
cmovgl %r9d, %ebx
cmovgeq %r8, %rbp
incq %rdi
cmpq %rax, %rdi
jne 0x24b66
testq %r13, %r13
jne 0x24bbc
jmp 0x24bf5
movl $0x3, %ebx
xorl %ebp, %ebp
jmp 0x24bf5
movl $0x3, %ebx
xorl %ebp, %ebp
movl -0x4(%r13), %eax
cmpl 0x20(%rsp), %eax
jne 0x24bec
movq 0x48(%rsp), %rax
leaq (,%rax,8), %rsi
addq %r13, %rsi
movq %r13, %rdi
movq 0x40(%rsp), %rdx
callq 0x44f0
movq 0x28(%rsp), %rax
movl %eax, -0x4(%r13)
leal 0x1(%rax), %ecx
cmpl -0x8(%r13), %ecx
jl 0x24c15
leaq (%rsp,%r14,8), %r13
addq $0x50, %r13
movq %r13, %rdi
movl $0x8, %esi
callq 0x25186
movq (%r13), %r13
movl -0x4(%r13), %eax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%r13)
cltq
movq %r12, (%r13,%rax,8)
testq %rbp, %rbp
leaq 0x4(%rsp), %r13
je 0x24d52
movzwl 0x1(%r12), %eax
movzbl 0x3(%r12), %ecx
shll $0x10, %ecx
orl %eax, %ecx
leal (,%rcx,8), %eax
xorl %ecx, %eax
movl %eax, %ecx
shrl $0x5, %ecx
addl %eax, %ecx
movl %ecx, %eax
shll $0x4, %eax
xorl %ecx, %eax
movl %eax, %ecx
shrl $0x11, %ecx
addl %eax, %ecx
movl %ecx, %eax
shrl $0x6, %eax
addl %ecx, %eax
andl $0x3fff, %eax           # imm = 0x3FFF
movq 0x50(%rsp,%rax,8), %rax
testq %rax, %rax
je 0x24cec
movslq -0x4(%rax), %rcx
testq %rcx, %rcx
jle 0x24cec
leaq 0x1(%r12), %rdx
movq 0x30(%rsp), %r8
leal -0x7fff(%r8), %esi
movslq %esi, %rsi
notl %r8d
movq 0x10(%rsp), %r9
leal (%r8,%r9), %edi
decl %edi
addl %r9d, %r8d
movl $0x101, %r9d            # imm = 0x101
cmpl %r9d, %edi
cmovael %r9d, %edi
incl %edi
xorl %r9d, %r9d
movq (%rax,%r9,8), %r10
movq %r10, %r11
subq %r15, %r11
cmpq %rsi, %r11
jle 0x24ce4
xorl %r11d, %r11d
testl %r8d, %r8d
jle 0x24cdf
movb (%r10,%r11), %r14b
cmpb (%rdx,%r11), %r14b
jne 0x24cdf
incq %r11
cmpq %r11, %rdi
jne 0x24cca
movl %edi, %r11d
cmpl %ebx, %r11d
jg 0x24d52
incq %r9
cmpq %rcx, %r9
jne 0x24cb3
subl %ebp, %r12d
cmpl $0x7fff, %r12d          # imm = 0x7FFF
jg 0x25167
cmpl $0x102, %ebx            # imm = 0x102
jg 0x25167
xorl %eax, %eax
movq 0x18(%rsp), %rdi
movq %rsp, %rbp
leaq 0x7e27(%rip), %rdx      # 0x2cb40
movzwl 0x2(%rdx,%rax,2), %ecx
incq %rax
cmpl %ecx, %ebx
jge 0x24d19
leaq -0x1(%rax), %r14
cmpq $0x16, %r14
ja 0x24d95
xorl %edx, %edx
movl $0xfffffff9, %ecx       # imm = 0xFFFFFFF9
movl %eax, %esi
andl $0x1, %esi
leal (%rsi,%rdx,2), %edx
shrl %eax
incl %ecx
jne 0x24d36
movl (%rsp), %ecx
shll %cl, %edx
orl %edx, 0x4(%rsp)
addl $0x7, %ecx
jmp 0x24dbb
movzbl (%r12), %eax
cmpl $0x8f, %eax
ja 0x24ea0
addl $0x30, %eax
xorl %edx, %edx
movl $0xfffffff8, %ecx       # imm = 0xFFFFFFF8
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %rbp
movl %eax, %esi
andl $0x1, %esi
leal (%rsi,%rdx,2), %edx
shrl %eax
incl %ecx
jne 0x24d76
movl (%rsp), %ecx
shll %cl, %edx
orl %edx, 0x4(%rsp)
addl $0x8, %ecx
jmp 0x24ed0
addl $0xa8, %eax
xorl %edx, %edx
movl $0xfffffff8, %ecx       # imm = 0xFFFFFFF8
movl %eax, %esi
andl $0x1, %esi
leal (%rsi,%rdx,2), %edx
shrl %eax
incl %ecx
jne 0x24da1
movl (%rsp), %ecx
shll %cl, %edx
orl %edx, 0x4(%rsp)
addl $0x8, %ecx
movl %ecx, (%rsp)
movq %r13, %rsi
movq %rbp, %rdx
callq 0x25203
movl %r14d, %edx
leaq -0x1c(%rdx), %rcx
cmpq $-0x14, %rcx
jb 0x24e0c
leaq 0x7d63(%rip), %rcx      # 0x2cb40
movzwl (%rcx,%rdx,2), %ecx
movl %ebx, %esi
subl %ecx, %esi
movl (%rsp), %ecx
shll %cl, %esi
orl %esi, 0x4(%rsp)
leaq 0x7d8b(%rip), %rsi      # 0x2cb80
movzbl (%rdx,%rsi), %edx
addl %ecx, %edx
movl %edx, (%rsp)
movq %rax, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x25203
leaq 0x7d8d(%rip), %rdx      # 0x2cba0
movq $-0x1, %r14
movzwl 0x4(%rdx,%r14,2), %ecx
incq %r14
cmpl %r12d, %ecx
jle 0x24e1a
xorl %edx, %edx
movl $0xfffffffb, %ecx       # imm = 0xFFFFFFFB
movl %r14d, %esi
movl %esi, %edi
andl $0x1, %edi
leal (%rdi,%rdx,2), %edx
shrl %esi
incl %ecx
jne 0x24e32
movl (%rsp), %ecx
shll %cl, %edx
orl %edx, 0x4(%rsp)
addl $0x5, %ecx
movl %ecx, (%rsp)
movq %rax, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x25203
movq %rax, %rbp
cmpq $0x4, %r14
jae 0x24e6d
movq 0x10(%rsp), %r12
jmp 0x24ee9
movl %r14d, %eax
leaq 0x7d29(%rip), %rcx      # 0x2cba0
movzwl (%rcx,%rax,2), %ecx
subl %ecx, %r12d
movl (%rsp), %ecx
shll %cl, %r12d
orl %r12d, 0x4(%rsp)
leaq 0x7d50(%rip), %rdx      # 0x2cbe0
movzbl (%rax,%rdx), %eax
addl %ecx, %eax
movl %eax, (%rsp)
movq 0x10(%rsp), %r12
jmp 0x24ed8
orl $0x100, %eax            # imm = 0x100
xorl %edx, %edx
movl $0xfffffff7, %ecx       # imm = 0xFFFFFFF7
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %rbp
movl %eax, %esi
andl $0x1, %esi
leal (%rsi,%rdx,2), %edx
shrl %eax
incl %ecx
jne 0x24eb6
movl (%rsp), %ecx
shll %cl, %edx
orl %edx, 0x4(%rsp)
addl $0x9, %ecx
movl %ecx, (%rsp)
movl $0x1, %ebx
movq %rbp, %rdi
movq %r13, %rsi
movq %rsp, %rdx
callq 0x25203
movq %rax, %rbp
addl 0x30(%rsp), %ebx
movl %ebx, %esi
cmpl 0x24(%rsp), %ebx
jl 0x24adb
movq %rbp, 0x8(%rsp)
cmpl %r12d, %ebx
jge 0x24f82
movslq %ebx, %r14
leaq 0x4(%rsp), %rbx
movq %rsp, %r13
movzbl (%r15,%r14), %eax
cmpl $0x8f, %eax
ja 0x24f40
addl $0x30, %eax
xorl %edx, %edx
movl $0xfffffff8, %ecx       # imm = 0xFFFFFFF8
movl %eax, %esi
andl $0x1, %esi
leal (%rsi,%rdx,2), %edx
shrl %eax
incl %ecx
jne 0x24f24
movl (%rsp), %ecx
shll %cl, %edx
orl %edx, 0x4(%rsp)
addl $0x8, %ecx
jmp 0x24f66
orl $0x100, %eax            # imm = 0x100
xorl %edx, %edx
movl $0xfffffff7, %ecx       # imm = 0xFFFFFFF7
movl %eax, %esi
andl $0x1, %esi
leal (%rsi,%rdx,2), %edx
shrl %eax
incl %ecx
jne 0x24f4c
movl (%rsp), %ecx
shll %cl, %edx
orl %edx, 0x4(%rsp)
addl $0x9, %ecx
movl %ecx, (%rsp)
movq %rbp, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x25203
movq %rax, %rbp
incq %r14
cmpl %r12d, %r14d
jne 0x24f0e
movq %rbp, 0x8(%rsp)
movq %rsp, %r13
addl $0x7, (%r13)
leaq 0x4(%rsp), %rsi
movq %rbp, %rdi
movq %r13, %rdx
callq 0x25203
movq %rax, %rbp
movl (%r13), %eax
testl %eax, %eax
je 0x24fcf
leaq 0x4(%rsp), %r12
movq %rsp, %r13
incl %eax
movl %eax, (%rsp)
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x25203
movq %rax, %rbp
movl (%rsp), %eax
testl %eax, %eax
jne 0x24fb2
movq %rbp, 0x8(%rsp)
xorl %ebx, %ebx
movq 0x10(%rsp), %r14
movq 0x50(%rsp,%rbx,8), %rdi
testq %rdi, %rdi
je 0x24fee
addq $-0x8, %rdi
callq 0x4380
incq %rbx
cmpq $0x4000, %rbx           # imm = 0x4000
jne 0x24fdb
testl %r14d, %r14d
jle 0x2507c
movl %r14d, %eax
imulq $0x5e6ea9af, %rax, %rax # imm = 0x5E6EA9AF
shrq $0x2b, %rax
imull $0x15b0, %eax, %ecx     # imm = 0x15B0
movl %r14d, %eax
subl %ecx, %eax
movl $0x1, %r12d
xorl %ebx, %ebx
movl $0x80078071, %ecx       # imm = 0x80078071
xorl %edx, %edx
testl %eax, %eax
je 0x2506e
movl %edx, %esi
movl %eax, %edi
addq %r15, %rsi
xorl %r8d, %r8d
movzbl (%rsi,%r8), %r9d
addl %r9d, %r12d
addl %r12d, %ebx
incq %r8
cmpq %r8, %rdi
jne 0x25035
movl %r12d, %esi
imulq %rcx, %rsi
shrq $0x2f, %rsi
imull $0xfff1, %esi, %esi     # imm = 0xFFF1
subl %esi, %r12d
movl %ebx, %esi
imulq %rcx, %rsi
shrq $0x2f, %rsi
imull $0xfff1, %esi, %esi     # imm = 0xFFF1
subl %esi, %ebx
addl %eax, %edx
movl $0x15b0, %eax           # imm = 0x15B0
cmpl %r14d, %edx
jl 0x25027
jmp 0x25084
xorl %ebx, %ebx
movl $0x1, %r12d
testq %rbp, %rbp
je 0x25094
movl -0x4(%rbp), %eax
leal 0x1(%rax), %ecx
cmpl -0x8(%rbp), %ecx
jl 0x250af
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movl $0x1, %esi
callq 0x25186
movq (%r14), %rbp
movl -0x4(%rbp), %eax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rbp)
cltq
movb %bh, (%rbp,%rax)
movl -0x4(%rbp), %eax
incl %eax
cmpl -0x8(%rbp), %eax
jl 0x250d1
leaq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0x25186
movq 0x8(%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 0x25109
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movl $0x1, %esi
callq 0x25186
movq (%r14), %rsi
movl -0x4(%rsi), %eax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rsi)
cltq
movl %r12d, %ebx
movb %bh, (%rsi,%rax)
movl -0x4(%rsi), %eax
leal 0x1(%rax), %ecx
cmpl -0x8(%rsi), %ecx
jl 0x2513a
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movl $0x1, %esi
callq 0x25186
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 0x38(%rsp), %rax
movl %edx, (%rax)
leaq -0x8(%rsi), %rdi
addq $0x20058, %rsp          # imm = 0x20058
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x44f0
leaq 0x7fbe(%rip), %rdi      # 0x2d12c
leaq 0x7efd(%rip), %rsi      # 0x2d072
leaq 0x7fca(%rip), %rcx      # 0x2d146
movl $0x314, %edx            # imm = 0x314
callq 0x41f0