// File: /workspace/github_cpp_makefile_star2_O1/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 $0x20068, %rsp          # imm = 0x20068
movq %rdx, 0x40(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdi, %r15
xorl %eax, %eax
movl %eax, 0xc(%rsp)
movl %eax, 0x8(%rsp)
leaq 0x10(%rsp), %rbx
movq $0x0, (%rbx)
cmpl $0x6, %ecx
movl $0x5, %eax
cmovgel %ecx, %eax
movq %rax, 0x38(%rsp)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x24c18
movq (%rbx), %rax
movslq -0x4(%rax), %rcx
leal 0x1(%rcx), %edx
movl %edx, -0x4(%rax)
movb $0x78, (%rax,%rcx)
testq %rax, %rax
je 0x24454
movl -0x4(%rax), %ecx
incl %ecx
cmpl -0x8(%rax), %ecx
jl 0x24463
leaq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0x24c18
movq 0x10(%rsp), %rdi
movslq -0x4(%rdi), %rax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rdi)
movb $0x5e, (%rdi,%rax)
movl $0x1, %ebp
leaq 0xc(%rsp), %rbx
movl %ebp, (%rbx)
leaq 0x8(%rsp), %r12
movl %ebp, (%r12)
movq %rbx, %rsi
movq %r12, %rdx
callq 0x24c95
movl (%r12), %ecx
shll %cl, %ebp
orl %ebp, (%rbx)
movq %rax, 0x10(%rsp)
addl $0x2, %ecx
movl %ecx, (%r12)
movq %rax, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x24c95
movq %rax, 0x28(%rsp)
movq %rax, 0x10(%rsp)
leaq 0x60(%rsp), %rdi
xorl %r12d, %r12d
movl $0x20000, %edx          # imm = 0x20000
xorl %esi, %esi
callq 0x41d0
movq 0x18(%rsp), %rax
cmpl $0x4, %eax
jl 0x24970
addl $-0x3, %eax
movl %eax, 0x34(%rsp)
movq 0x38(%rsp), %rax
leal (%rax,%rax), %ecx
movl %ecx, 0x30(%rsp)
movl %eax, %eax
movq %rax, 0x50(%rsp)
leaq (,%rax,8), %rax
movq %rax, 0x48(%rsp)
xorl %esi, %esi
movslq %esi, %rdx
movzwl (%r15,%rdx), %eax
movzbl 0x2(%r15,%rdx), %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 0x60(%rsp,%rax,8), %r13
movl $0x0, %edi
testq %r13, %r13
je 0x2455d
movl -0x4(%r13), %edi
movq %rdx, 0x58(%rsp)
leaq (%r15,%rdx), %rbx
testl %edi, %edi
movq 0x18(%rsp), %rdx
movq %rsi, 0x20(%rsp)
jle 0x245e0
leal -0x8000(%rsi), %ecx
movslq %ecx, %rcx
subl %esi, %edx
leal -0x1(%rdx), %esi
movl $0x101, %r8d            # imm = 0x101
cmpl %r8d, %esi
cmovael %r8d, %esi
incl %esi
movl %edi, %edi
movl $0x3, %r12d
xorl %r8d, %r8d
xorl %r14d, %r14d
movq (%r13,%r8,8), %r9
movq %r9, %r10
subq %r15, %r10
cmpq %rcx, %r10
jle 0x245d6
xorl %r10d, %r10d
testl %edx, %edx
jle 0x245cb
movb (%r9,%r10), %r11b
cmpb (%rbx,%r10), %r11b
jne 0x245cb
incq %r10
cmpq %r10, %rsi
jne 0x245b6
movl %esi, %r10d
cmpl %r12d, %r10d
cmovgl %r10d, %r12d
cmovgeq %r9, %r14
incq %r8
cmpq %rdi, %r8
jne 0x2459f
jmp 0x245e9
movl $0x3, %r12d
xorl %r14d, %r14d
leaq (%rsp,%rax,8), %rbp
addq $0x60, %rbp
testq %r13, %r13
je 0x24637
movl 0x30(%rsp), %eax
cmpl %eax, -0x4(%r13)
jne 0x24626
movq 0x50(%rsp), %rax
leaq (,%rax,8), %rsi
addq %r13, %rsi
movq %r13, %rdi
movq 0x48(%rsp), %rdx
callq 0x4500
movq 0x38(%rsp), %rax
movl %eax, -0x4(%r13)
testq %r13, %r13
je 0x24637
movl -0x4(%r13), %eax
incl %eax
cmpl -0x8(%r13), %eax
jl 0x24644
movq %rbp, %rdi
movl $0x8, %esi
callq 0x24c18
movq (%rbp), %rax
movslq -0x4(%rax), %rcx
leal 0x1(%rcx), %edx
movl %edx, -0x4(%rax)
movq %rbx, (%rax,%rcx,8)
testq %r14, %r14
je 0x246a8
movzwl 0x1(%rbx), %eax
movzbl 0x3(%rbx), %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 0x60(%rsp,%rax,8), %rax
testq %rax, %rax
movl $0x0, %r13d
je 0x246b0
movl -0x4(%rax), %r8d
jmp 0x246b3
xorl %r14d, %r14d
jmp 0x24732
xorl %r8d, %r8d
testl %r8d, %r8d
jle 0x24732
movq 0x58(%rsp), %rcx
addq %r15, %rcx
incq %rcx
movq 0x20(%rsp), %rsi
leal -0x7fff(%rsi), %edi
notl %esi
movq 0x18(%rsp), %r9
leal (%rsi,%r9), %edx
decl %edx
addl %r9d, %esi
movl $0x101, %r9d            # imm = 0x101
cmpl %r9d, %edx
cmovael %r9d, %edx
movslq %edi, %rdi
incl %edx
movl %r8d, %r8d
xorl %r9d, %r9d
movq (%rax,%r9,8), %r10
movq %r10, %r11
subq %r15, %r11
cmpq %rdi, %r11
jle 0x2472a
xorl %r11d, %r11d
testl %esi, %esi
jle 0x24721
movb (%r10,%r11), %bpl
cmpb (%rcx,%r11), %bpl
jne 0x24721
incq %r11
cmpq %r11, %rdx
jne 0x2470c
movl %edx, %r11d
cmpl %r12d, %r11d
cmovgq %r13, %r14
jg 0x24732
incq %r9
cmpq %r8, %r9
jne 0x246f6
testq %r14, %r14
je 0x247a1
subl %r14d, %ebx
cmpl $0x7fff, %ebx           # imm = 0x7FFF
movq 0x28(%rsp), %rdi
leaq 0xc(%rsp), %r13
jg 0x24bf4
cmpl $0x102, %r12d           # imm = 0x102
jg 0x24bf4
xorl %eax, %eax
leaq 0x931a(%rip), %rdx      # 0x2da80
movzwl 0x2(%rdx,%rax,2), %ecx
incq %rax
cmpl %ecx, %r12d
jge 0x24766
leaq -0x1(%rax), %r14
cmpq $0x16, %r14
ja 0x247f1
xorl %edx, %edx
movl $0xfffffff9, %ecx       # imm = 0xFFFFFFF9
movl %eax, %esi
andl $0x1, %esi
leal (%rsi,%rdx,2), %edx
shrl %eax
incl %ecx
jne 0x24784
movl 0x8(%rsp), %ecx
shll %cl, %edx
orl %edx, 0xc(%rsp)
addl $0x7, %ecx
jmp 0x24818
movzbl (%rbx), %eax
cmpl $0x8f, %eax
movq 0x28(%rsp), %rdi
leaq 0xc(%rsp), %r13
ja 0x24910
addl $0x30, %eax
xorl %r8d, %r8d
movl $0xfffffff8, %ecx       # imm = 0xFFFFFFF8
leaq 0x8(%rsp), %rdx
movq 0x20(%rsp), %rbx
movl %eax, %esi
andl $0x1, %esi
leal (%rsi,%r8,2), %r8d
shrl %eax
incl %ecx
jne 0x247ce
movl 0x8(%rsp), %ecx
shll %cl, %r8d
orl %r8d, 0xc(%rsp)
addl $0x8, %ecx
jmp 0x24945
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 0x247fd
movl 0x8(%rsp), %ecx
shll %cl, %edx
orl %edx, 0xc(%rsp)
addl $0x8, %ecx
movl %ecx, 0x8(%rsp)
movq %r13, %rsi
leaq 0x8(%rsp), %rbp
movq %rbp, %rdx
callq 0x24c95
movl %r14d, %edx
leaq -0x1c(%rdx), %rcx
cmpq $-0x14, %rcx
jb 0x24872
leaq 0x9240(%rip), %rcx      # 0x2da80
movzwl (%rcx,%rdx,2), %ecx
movl %r12d, %esi
subl %ecx, %esi
movl 0x8(%rsp), %ecx
shll %cl, %esi
orl %esi, 0xc(%rsp)
leaq 0x9266(%rip), %rsi      # 0x2dac0
movzbl (%rdx,%rsi), %edx
addl %ecx, %edx
movl %edx, 0x8(%rsp)
movq %rax, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x24c95
leaq 0x9267(%rip), %rdx      # 0x2dae0
movq $-0x1, %r14
movzwl 0x4(%rdx,%r14,2), %ecx
incq %r14
cmpl %ebx, %ecx
jle 0x24880
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 0x24897
movl 0x8(%rsp), %ecx
shll %cl, %edx
orl %edx, 0xc(%rsp)
addl $0x5, %ecx
movl %ecx, 0x8(%rsp)
movq %rax, %rdi
movq %r13, %rsi
leaq 0x8(%rsp), %rdx
callq 0x24c95
movq %rax, %rdi
cmpq $0x4, %r14
jae 0x248d9
movq 0x20(%rsp), %rbx
jmp 0x2495a
movl %r14d, %eax
leaq 0x91fd(%rip), %rcx      # 0x2dae0
movzwl (%rcx,%rax,2), %ecx
subl %ecx, %ebx
movl 0x8(%rsp), %ecx
shll %cl, %ebx
orl %ebx, 0xc(%rsp)
leaq 0x9226(%rip), %rdx      # 0x2db20
movzbl (%rax,%rdx), %eax
addl %ecx, %eax
movl %eax, 0x8(%rsp)
leaq 0x8(%rsp), %rdx
movq 0x20(%rsp), %rbx
jmp 0x2494f
orl $0x100, %eax            # imm = 0x100
xorl %r8d, %r8d
movl $0xfffffff7, %ecx       # imm = 0xFFFFFFF7
leaq 0x8(%rsp), %rdx
movq 0x20(%rsp), %rbx
movl %eax, %esi
andl $0x1, %esi
leal (%rsi,%r8,2), %r8d
shrl %eax
incl %ecx
jne 0x24927
movl 0x8(%rsp), %ecx
shll %cl, %r8d
orl %r8d, 0xc(%rsp)
addl $0x9, %ecx
movl %ecx, 0x8(%rsp)
movl $0x1, %r12d
movq %r13, %rsi
callq 0x24c95
movq %rax, %rdi
movq %rdi, 0x28(%rsp)
addl %ebx, %r12d
movl %r12d, %esi
cmpl 0x34(%rsp), %r12d
jl 0x2450d
movq 0x28(%rsp), %rdi
movq %rdi, 0x10(%rsp)
cmpl 0x18(%rsp), %r12d
jge 0x24a0b
movslq %r12d, %r14
leaq 0xc(%rsp), %rbx
leaq 0x8(%rsp), %r13
movq 0x18(%rsp), %r12
movzbl (%r15,%r14), %eax
cmpl $0x8f, %eax
ja 0x249ca
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 0x249ad
movl 0x8(%rsp), %ecx
shll %cl, %edx
orl %edx, 0xc(%rsp)
addl $0x8, %ecx
jmp 0x249f1
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 0x249d6
movl 0x8(%rsp), %ecx
shll %cl, %edx
orl %edx, 0xc(%rsp)
addl $0x9, %ecx
movl %ecx, 0x8(%rsp)
movq %rbx, %rsi
movq %r13, %rdx
callq 0x24c95
movq %rax, %rdi
incq %r14
cmpl %r12d, %r14d
jne 0x24997
movq %rdi, 0x10(%rsp)
leaq 0x8(%rsp), %r13
addl $0x7, (%r13)
leaq 0xc(%rsp), %rsi
movq %r13, %rdx
callq 0x24c95
movq %rax, %r14
movl (%r13), %eax
testl %eax, %eax
je 0x24a5b
leaq 0xc(%rsp), %r12
leaq 0x8(%rsp), %r13
incl %eax
movl %eax, 0x8(%rsp)
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x24c95
movq %rax, %r14
movl 0x8(%rsp), %eax
testl %eax, %eax
jne 0x24a3c
movq %r14, 0x10(%rsp)
xorl %ebx, %ebx
movq 0x18(%rsp), %r12
movq 0x60(%rsp,%rbx,8), %rdi
testq %rdi, %rdi
je 0x24a7a
addq $-0x8, %rdi
callq 0x4390
incq %rbx
cmpq $0x4000, %rbx           # imm = 0x4000
jne 0x24a67
testl %r12d, %r12d
jle 0x24b04
movl %r12d, %eax
imulq $0x5e6ea9af, %rax, %rax # imm = 0x5E6EA9AF
shrq $0x2b, %rax
imull $0x15b0, %eax, %ecx     # imm = 0x15B0
movl %r12d, %eax
subl %ecx, %eax
movl $0x1, %ebp
xorl %ebx, %ebx
movl $0x80078071, %ecx       # imm = 0x80078071
xorl %edx, %edx
testl %eax, %eax
je 0x24af6
movl %edx, %esi
movl %eax, %edi
addq %r15, %rsi
xorl %r8d, %r8d
movzbl (%rsi,%r8), %r9d
addl %r9d, %ebp
addl %ebp, %ebx
incq %r8
cmpq %r8, %rdi
jne 0x24ac0
movl %ebp, %esi
imulq %rcx, %rsi
shrq $0x2f, %rsi
imull $0xfff1, %esi, %esi     # imm = 0xFFF1
subl %esi, %ebp
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 %r12d, %edx
jl 0x24ab2
jmp 0x24b0b
xorl %ebx, %ebx
movl $0x1, %ebp
testq %r14, %r14
je 0x24b1c
movl -0x4(%r14), %eax
incl %eax
cmpl -0x8(%r14), %eax
jl 0x24b2b
leaq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0x24c18
movq 0x10(%rsp), %rax
movslq -0x4(%rax), %rcx
leal 0x1(%rcx), %edx
movl %edx, -0x4(%rax)
movb %bh, (%rax,%rcx)
testq %rax, %rax
je 0x24b4c
movl -0x4(%rax), %ecx
incl %ecx
cmpl -0x8(%rax), %ecx
jl 0x24b5b
leaq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0x24c18
movq 0x10(%rsp), %rax
movslq -0x4(%rax), %rcx
leal 0x1(%rcx), %edx
movl %edx, -0x4(%rax)
movb %bl, (%rax,%rcx)
testq %rax, %rax
je 0x24b7c
movl -0x4(%rax), %ecx
incl %ecx
cmpl -0x8(%rax), %ecx
jl 0x24b8b
leaq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0x24c18
movq 0x10(%rsp), %rax
movslq -0x4(%rax), %rcx
leal 0x1(%rcx), %edx
movl %edx, -0x4(%rax)
movl %ebp, %ebx
movb %bh, (%rax,%rcx)
testq %rax, %rax
je 0x24bae
movl -0x4(%rax), %ecx
incl %ecx
cmpl -0x8(%rax), %ecx
jl 0x24bbd
leaq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0x24c18
movq 0x10(%rsp), %rsi
movslq -0x4(%rsi), %rax
leal 0x1(%rax), %ecx
movl %ecx, -0x4(%rsi)
movb %bl, (%rsi,%rax)
movslq -0x4(%rsi), %rdx
movq 0x40(%rsp), %rax
movl %edx, (%rax)
leaq -0x8(%rsi), %rdi
addq $0x20068, %rsp          # imm = 0x20068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4500
movq %rdi, 0x10(%rsp)
leaq 0x946c(%rip), %rdi      # 0x2e06c
leaq 0x93ab(%rip), %rsi      # 0x2dfb2
leaq 0x9478(%rip), %rcx      # 0x2e086
movl $0x314, %edx            # imm = 0x314
callq 0x4200