// File: /workspace/github_cpp_makefile_star2_O3/attractivechaos[P]udb2/stb/./stb.h
// Function: stb_compress_chunk
static int stb_compress_chunk(stb_uchar *history,
                              stb_uchar *start,
                              stb_uchar *end,
                              int length,
                              int *pending_literals,
                              stb_uchar **chash,
                              stb_uint mask)
{
   int window = stb__window;
   stb_uint match_max;
   stb_uchar *lit_start = start - *pending_literals;
   stb_uchar *q = start;

   #define STB__SCRAMBLE(h)   (((h) + ((h) >> 16)) & mask)

   // stop short of the end so we don't scan off the end doing
   // the hashing; this means we won't compress the last few bytes
   // unless they were part of something longer
   while (q < start+length && q+12 < end) {
      int m;
      stb_uint h1,h2,h3,h4, h;
      stb_uchar *t;
      int best = 2, dist=0;

      if (q+65536 > end)
         match_max = end-q;
      else
         match_max = 65536;

      #define stb__nc(b,d)  ((d) <= window && ((b) > 9 || stb_not_crap(b,d)))

      #define STB__TRY(t,p)  /* avoid retrying a match we already tried */ \
                      if (p ? dist != q-t : 1)                             \
                      if ((m = stb_matchlen(t, q, match_max)) > best)     \
                      if (stb__nc(m,q-(t)))                                \
                          best = m, dist = q - (t)

      // rather than search for all matches, only try 4 candidate locations,
      // chosen based on 4 different hash functions of different lengths.
      // this strategy is inspired by LZO; hashing is unrolled here using the
      // 'hc' macro
      h = stb__hc3(q,0, 1, 2); h1 = STB__SCRAMBLE(h);
                                      t = chash[h1]; if (t) STB__TRY(t,0);
      h = stb__hc2(q,h, 3, 4); h2 = STB__SCRAMBLE(h);
      h = stb__hc2(q,h, 5, 6);        t = chash[h2]; if (t) STB__TRY(t,1);
      h = stb__hc2(q,h, 7, 8); h3 = STB__SCRAMBLE(h);
      h = stb__hc2(q,h, 9,10);        t = chash[h3]; if (t) STB__TRY(t,1);
      h = stb__hc2(q,h,11,12); h4 = STB__SCRAMBLE(h);
                                      t = chash[h4]; if (t) STB__TRY(t,1);

      // because we use a shared hash table, can only update it
      // _after_ we've probed all of them
      chash[h1] = chash[h2] = chash[h3] = chash[h4] = q;

      if (best > 2)
         assert(dist > 0);

      // see if our best match qualifies
      if (best < 3) { // fast path literals
         ++q;
      } else if (best > 2  &&  best <= 0x80    &&  dist <= 0x100) {
         outliterals(lit_start, q-lit_start); lit_start = (q += best);
         stb_out(0x80 + best-1);
         stb_out(dist-1);
      } else if (best > 5  &&  best <= 0x100   &&  dist <= 0x4000) {
         outliterals(lit_start, q-lit_start); lit_start = (q += best);
         stb_out2(0x4000 + dist-1);       
         stb_out(best-1);
      } else if (best > 7  &&  best <= 0x100   &&  dist <= 0x80000) {
         outliterals(lit_start, q-lit_start); lit_start = (q += best);
         stb_out3(0x180000 + dist-1);     
         stb_out(best-1);
      } else if (best > 8  &&  best <= 0x10000 &&  dist <= 0x80000) {
         outliterals(lit_start, q-lit_start); lit_start = (q += best);
         stb_out3(0x100000 + dist-1);     
         stb_out2(best-1);
      } else if (best > 9                      &&  dist <= 0x1000000) {
         if (best > 65536) best = 65536;
         outliterals(lit_start, q-lit_start); lit_start = (q += best);
         if (best <= 0x100) {
            stb_out(0x06);
            stb_out3(dist-1);
            stb_out(best-1);
         } else {
            stb_out(0x04);
            stb_out3(dist-1);
            stb_out2(best-1);
         }
      } else {  // fallback literals if no match was a balanced tradeoff
         ++q;
      }
   }

   // if we didn't get all the way, add the rest to literals
   if (q-start < length)
      q = start+length;

   // the literals are everything from lit_start to q
   *pending_literals = (q - lit_start);

   stb__running_adler = stb_adler32(stb__running_adler, start, q - start);
   return q - start;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq %rcx, 0x38(%rsp)
movslq (%rcx), %rax
movq %rdi, %rcx
subq %rax, %rcx
movq %rcx, 0x8(%rsp)
movslq %edx, %rdx
leaq (%rdi,%rdx), %rax
movq %rax, 0x28(%rsp)
testl %edx, %edx
setg %al
addq $0xc, %rdi
cmpq %rsi, %rdi
setb %cl
andb %al, %cl
cmpb $0x1, %cl
movq %rbx, 0x40(%rsp)
movq %rdx, 0x30(%rsp)
jne 0xfa86
movl %r9d, %ebp
movq %r8, %r15
movq %rsi, %r14
movslq 0xae5a(%rip), %rax      # 0x1a230
movq %rax, 0x20(%rsp)
movq %r8, 0x18(%rsp)
movl %r9d, 0x4(%rsp)
movq %rsi, 0x10(%rsp)
leaq 0x10000(%rbx), %rax
movl %r14d, %ecx
subl %ebx, %ecx
cmpq %r14, %rax
movl $0x10000, %eax          # imm = 0x10000
cmovbel %eax, %ecx
movzbl (%rbx), %eax
shll $0xe, %eax
movzbl 0x1(%rbx), %r8d
shll $0x7, %r8d
addl %eax, %r8d
movzbl 0x2(%rbx), %esi
addl %r8d, %esi
movl %esi, %eax
shrl $0x10, %eax
addl %esi, %eax
andl %ebp, %eax
movq (%r15,%rax,8), %r10
movl $0x2, %r9d
movl $0x0, %r13d
testq %r10, %r10
je 0xf4c7
testl %ecx, %ecx
je 0xf4c7
xorl %r8d, %r8d
movb (%r10,%r8), %r9b
cmpb (%rbx,%r8), %r9b
jne 0xf45c
incq %r8
cmpq %r8, %rcx
jne 0xf447
movl %ecx, %r8d
movl $0x2, %r9d
movl $0x0, %r13d
cmpl $0x3, %r8d
jl 0xf4c7
movq %rbx, %r11
subq %r10, %r11
cmpq 0x20(%rsp), %r11
jg 0xf4c7
cmpl $0x9, %r8d
ja 0xf4c1
cmpl $0x101, %r11d           # imm = 0x101
jl 0xf4c1
cmpl $0x4000, %r11d          # imm = 0x4000
ja 0xf499
cmpl $0x5, %r8d
ja 0xf4c1
cmpl $0x8, %r8d
setb %r9b
cmpl $0x80001, %r11d         # imm = 0x80001
setae %r10b
orb %r9b, %r10b
movl $0x2, %edx
cmovnel %edx, %r8d
movl $0x0, %edx
cmovnel %edx, %r11d
movl %r8d, %r9d
movl %r11d, %r13d
roll $0xe, %esi
movzbl 0x3(%rbx), %r10d
shll $0x7, %r10d
movzbl 0x4(%rbx), %r8d
addl %r10d, %r8d
addl %esi, %r8d
movl %r8d, %esi
shrl $0x10, %esi
addl %r8d, %esi
andl %ebp, %esi
movzbl 0x5(%rbx), %r10d
movzbl 0x6(%rbx), %r11d
movq (%r15,%rsi,8), %rbp
testq %rbp, %rbp
je 0xf56a
movslq %r13d, %r15
movq %rbx, %r14
subq %rbp, %r14
cmpq %r15, %r14
je 0xf570
testl %ecx, %ecx
je 0xf570
xorl %r12d, %r12d
movb (%rbp,%r12), %r15b
cmpb (%rbx,%r12), %r15b
jne 0xf527
incq %r12
cmpq %r12, %rcx
jne 0xf511
movl %ecx, %r12d
movq 0x18(%rsp), %r15
cmpl %r9d, %r12d
movl 0x4(%rsp), %ebp
jle 0xf579
cmpq 0x20(%rsp), %r14
jg 0xf579
cmpl $0x9, %r12d
jg 0xf562
cmpl $0x101, %r14d           # imm = 0x101
jl 0xf562
cmpl $0x4000, %r14d          # imm = 0x4000
ja 0xf8c3
cmpl $0x5, %r12d
jle 0xf8c3
movl %r12d, %r9d
movl %r14d, %r13d
jmp 0xf579
movl 0x4(%rsp), %ebp
jmp 0xf579
movl 0x4(%rsp), %ebp
movq 0x18(%rsp), %r15
roll $0xe, %r8d
shll $0x7, %r10d
addl %r11d, %r10d
addl %r8d, %r10d
roll $0xe, %r10d
movzbl 0x7(%rbx), %r8d
shll $0x7, %r8d
movzbl 0x8(%rbx), %r11d
addl %r10d, %r11d
addl %r8d, %r11d
movl %r11d, %r8d
shrl $0x10, %r8d
addl %r11d, %r8d
andl %ebp, %r8d
movzbl 0x9(%rbx), %r14d
movzbl 0xa(%rbx), %r12d
movq (%r15,%r8,8), %r15
testq %r15, %r15
je 0xf5d6
movslq %r13d, %r10
movq %rbx, %rbp
subq %r15, %rbp
cmpq %r10, %rbp
jne 0xf5e0
movl %r9d, %r10d
movl 0x4(%rsp), %ebp
jmp 0xf5d9
movl %r9d, %r10d
movq 0x18(%rsp), %r15
jmp 0xf654
testq %rcx, %rcx
je 0xf616
xorl %r10d, %r10d
movb (%r15,%r10), %dl
cmpb (%rbx,%r10), %dl
jne 0xf5fd
incq %r10
cmpq %r10, %rcx
jne 0xf5e8
movl %ecx, %r10d
cmpl %r9d, %r10d
movq 0x18(%rsp), %r15
jle 0xf64d
cmpq 0x20(%rsp), %rbp
jg 0xf64d
cmpl $0xa, %r10d
jl 0xf62a
jmp 0xf648
testl %r9d, %r9d
jns 0xf5cd
xorl %r10d, %r10d
cmpq 0x20(%rsp), %rbp
movq 0x18(%rsp), %r15
jg 0xf64d
cmpl $0x101, %ebp            # imm = 0x101
jl 0xf648
cmpl $0x4000, %ebp           # imm = 0x4000
ja 0xf992
cmpl $0x5, %r10d
jle 0xf992
movl %ebp, %r13d
jmp 0xf650
movl %r9d, %r10d
movl 0x4(%rsp), %ebp
roll $0xe, %r11d
shll $0x7, %r14d
addl %r12d, %r14d
addl %r11d, %r14d
roll $0xe, %r14d
movzbl 0xb(%rbx), %edx
shll $0x7, %edx
movzbl (%rdi), %edi
addl %r14d, %edi
addl %edx, %edi
movl %edi, %edx
shrl $0x10, %edx
addl %edi, %edx
andl %ebp, %edx
movq (%r15,%rdx,8), %r11
testq %r11, %r11
je 0xf695
movslq %r13d, %rdi
movq %rbx, %r9
subq %r11, %r9
cmpq %rdi, %r9
jne 0xf70e
movl %r10d, %r14d
movq %rbx, (%r15,%rdx,8)
movq %rbx, (%r15,%r8,8)
movq %rbx, (%r15,%rsi,8)
movq %rbx, (%r15,%rax,8)
cmpl $0x3, %r14d
jl 0xf6b7
testl %r13d, %r13d
jle 0xfad6
leaq 0x1(%rbx), %r12
cmpl $0x3, %r14d
jl 0xf90d
cmpl $0x80, %r14d
ja 0xf752
cmpl $0x100, %r13d           # imm = 0x100
jg 0xf752
movl %ebx, %esi
movq 0x8(%rsp), %rdi
subl %edi, %esi
callq 0xfaf5
movl %r14d, %r12d
addq %rbx, %r12
movq 0x10762(%rip), %rax     # 0x1fe58
testq %rax, %rax
je 0xf82f
addb $0x7f, %r14b
movb %r14b, (%rax)
incq %rax
jmp 0xf858
testq %rcx, %rcx
je 0xf7f0
xorl %r14d, %r14d
movb (%r11,%r14), %dil
cmpb (%rbx,%r14), %dil
jne 0xf72f
incq %r14
cmpq %r14, %rcx
jne 0xf71a
movl %ecx, %r14d
cmpl %r10d, %r14d
jle 0xf695
cmpq 0x20(%rsp), %r9
jg 0xf695
cmpl $0xa, %r14d
jl 0xf807
jmp 0xf827
leal -0x6(%r14), %eax
cmpl $0xfa, %eax
ja 0xf78b
cmpl $0x4000, %r13d          # imm = 0x4000
jg 0xf78b
movl %ebx, %esi
movq 0x8(%rsp), %rdi
subl %edi, %esi
callq 0xfaf5
movl %r14d, %r12d
addq %rbx, %r12
addl $0x3fff, %r13d          # imm = 0x3FFF
movl %r13d, %edi
callq 0x113a3
jmp 0xf7ca
leal -0x8(%r14), %eax
cmpl $0xf8, %eax
ja 0xf877
cmpl $0x80000, %r13d         # imm = 0x80000
jg 0xf877
movl %ebx, %esi
movq 0x8(%rsp), %rdi
subl %edi, %esi
callq 0xfaf5
movl %r14d, %r12d
addq %rbx, %r12
addl $0x17ffff, %r13d        # imm = 0x17FFFF
movl %r13d, %edi
callq 0x114b9
movq 0x10687(%rip), %rax     # 0x1fe58
testq %rax, %rax
je 0xf86e
decb %r14b
leaq 0x1(%rax), %rcx
movq %rcx, 0x10670(%rip)     # 0x1fe58
movb %r14b, (%rax)
jmp 0xf908
testl %r10d, %r10d
jns 0xf695
xorl %r14d, %r14d
cmpq 0x20(%rsp), %r9
jg 0xf695
cmpl $0x101, %r9d            # imm = 0x101
jl 0xf827
cmpl $0x4000, %r9d           # imm = 0x4000
ja 0xf9b8
cmpl $0x5, %r14d
jle 0xf9b8
movl %r9d, %r13d
jmp 0xf698
addl $0x7f, %r14d
movq 0x10626(%rip), %rsi     # 0x1fe60
movl %r14d, %edi
callq 0x21b0
incl 0x10620(%rip)           # 0x1fe68
movq 0x10609(%rip), %rax     # 0x1fe58
testq %rax, %rax
je 0xf8ef
decb %r13b
leaq 0x1(%rax), %rcx
movq %rcx, 0x105f2(%rip)     # 0x1fe58
movb %r13b, (%rax)
jmp 0xf908
decl %r14d
movzbl %r14b, %edi
jmp 0xf8f6
leal -0x9(%r14), %eax
cmpl $0xfff7, %eax           # imm = 0xFFF7
ja 0xf933
cmpl $0x80000, %r13d         # imm = 0x80000
jg 0xf933
movl %ebx, %esi
movq 0x8(%rsp), %rdi
subl %edi, %esi
callq 0xfaf5
movl %r14d, %r12d
addq %rbx, %r12
addl $0xfffff, %r13d         # imm = 0xFFFFF
movl %r13d, %edi
callq 0x114b9
decl %r14d
movl %r14d, %edi
callq 0x113a3
jmp 0xf908
cmpl $0x8, %r12d
setl %bpl
cmpl $0x80001, %r14d         # imm = 0x80001
setae %r15b
orb %bpl, %r15b
movq 0x18(%rsp), %r15
movl 0x4(%rsp), %ebp
cmovel %r12d, %r9d
cmovel %r14d, %r13d
jmp 0xf579
decl %r13d
movzbl %r13b, %edi
movq 0x10563(%rip), %rsi     # 0x1fe60
callq 0x21b0
incl 0x10560(%rip)           # 0x1fe68
movq %r12, 0x8(%rsp)
movq 0x10(%rsp), %r14
cmpq 0x28(%rsp), %r12
jae 0xfa89
leaq 0xc(%r12), %rdi
movq %r12, %rbx
cmpq %r14, %rdi
jb 0xf3ea
jmp 0xfa89
cmpl $0xa, %r14d
jb 0xf90d
cmpl $0x1000000, %r13d       # imm = 0x1000000
jg 0xf90d
movl $0x10000, %eax          # imm = 0x10000
cmpl %eax, %r14d
movl $0x10000, %eax          # imm = 0x10000
cmovbl %r14d, %eax
movq %rax, %r12
movl %ebx, %esi
movq 0x8(%rsp), %rdi
subl %edi, %esi
callq 0xfaf5
movq %r12, %rax
addq %rbx, %r12
movq %rax, %rbx
movq 0x104e4(%rip), %rax     # 0x1fe58
cmpl $0x100, %r14d           # imm = 0x100
ja 0xf9da
testq %rax, %rax
je 0xf9ef
leaq 0x1(%rax), %rcx
movq %rcx, 0x104cb(%rip)     # 0x1fe58
movb $0x6, (%rax)
jmp 0xfa06
cmpl $0x8, %r10d
setl %dl
cmpl $0x80001, %ebp          # imm = 0x80001
setae %r15b
orb %dl, %r15b
movq 0x18(%rsp), %r15
cmovnel %r9d, %r10d
cmovel %ebp, %r13d
jmp 0xf650
cmpl $0x8, %r14d
setl %cl
cmpl $0x80001, %r9d          # imm = 0x80001
setae %dil
orb %cl, %dil
cmovel %r14d, %r10d
cmovel %r9d, %r13d
jmp 0xf695
testq %rax, %rax
je 0xfa33
leaq 0x1(%rax), %rcx
movq %rcx, 0x1046e(%rip)     # 0x1fe58
movb $0x4, (%rax)
jmp 0xfa4a
movq 0x1046a(%rip), %rsi     # 0x1fe60
movl $0x6, %edi
callq 0x21b0
incl 0x10462(%rip)           # 0x1fe68
movq 0x10(%rsp), %r14
decl %r13d
movl %r13d, %edi
callq 0x114b9
movq 0x1043b(%rip), %rax     # 0x1fe58
testq %rax, %rax
je 0xfa65
decb %bl
leaq 0x1(%rax), %rcx
movq %rcx, 0x10429(%rip)     # 0x1fe58
movb %bl, (%rax)
jmp 0xfa7c
movq 0x10426(%rip), %rsi     # 0x1fe60
movl $0x4, %edi
callq 0x21b0
incl 0x1041e(%rip)           # 0x1fe68
movq 0x10(%rsp), %r14
decl %r13d
movl %r13d, %edi
callq 0x114b9
decl %ebx
movl %ebx, %edi
callq 0x113a3
jmp 0xfa7c
decl %ebx
movzbl %bl, %edi
movq 0x103ef(%rip), %rsi     # 0x1fe60
callq 0x21b0
incl 0x103ec(%rip)           # 0x1fe68
movq %r12, 0x8(%rsp)
jmp 0xf912
movq %rbx, %r12
movq %r12, %rax
movq 0x40(%rsp), %rsi
subq %rsi, %rax
cmpq 0x30(%rsp), %rax
cmovll 0x28(%rsp), %r12d
movl %r12d, %eax
subl 0x8(%rsp), %eax
movq 0x38(%rsp), %rcx
movl %eax, (%rcx)
movl 0x1091d(%rip), %edi     # 0x203d0
subl %esi, %r12d
movl %r12d, %edx
callq 0xa1b3
movl %eax, 0x1090c(%rip)     # 0x203d0
movl %r12d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x38ec(%rip), %rdi      # 0x133c9
leaq 0x29cd(%rip), %rsi      # 0x124b1
leaq 0x38e7(%rip), %rcx      # 0x133d2
movl $0x28ee, %edx           # imm = 0x28EE
callq 0x2140