// File: /workspace/github_cpp_makefile_star2_O3/attractivechaos[P]udb2/stb/./stb.h
// Function: stb_write
void stb_write(char *data, int data_len)
{
   stb_uint i;

   // @TODO: fast path for filling the buffer and doing nothing else
   //   if (xtb.valid + data_len < xtb.size)

   xtb.total_bytes += data_len;

   while (data_len) {
      // fill buffer
      if (xtb.valid < xtb.size) {
         int amt = xtb.size - xtb.valid;
         if (data_len < amt) amt = data_len;
         memcpy(xtb.buffer + xtb.valid, data, amt);
         data_len -= amt;
         data     += amt;
         xtb.valid += amt;
      }
      if (xtb.valid < xtb.size)
         return;

      // at this point, the buffer is full

      // if we can process some data, go for it; make sure
      // we leave an 'fsize's worth of data, though
      if (xtb.start + xtb.fsize < xtb.valid) {
         int amount = (xtb.valid - xtb.fsize) - xtb.start;
         int n;
         assert(amount > 0);
         n = stb_compress_chunk(xtb.buffer, xtb.buffer + xtb.start, xtb.buffer + xtb.valid,
                                amount, &xtb.pending_literals, xtb.chash, xtb.hashmask);
         xtb.start += n;
      }

      assert(xtb.start + xtb.fsize >= xtb.valid);
      // at this point, our future size is too small, so we
      // need to flush some history. we, in fact, flush exactly
      // one window's worth of history

      {
         int flush = xtb.window;
         assert(xtb.start >= flush);
         assert(xtb.valid >= flush);

         // if 'pending literals' extends back into the shift region,
         // write them out
         if (xtb.start - xtb.pending_literals < flush) {
            outliterals(xtb.buffer + xtb.start - xtb.pending_literals, xtb.pending_literals);
            xtb.pending_literals = 0;
         }

         // now shift the window
         memmove(xtb.buffer, xtb.buffer + flush, xtb.valid - flush);
         xtb.start -= flush;
         xtb.valid -= flush;
   
         for (i=0; i <= xtb.hashmask; ++i)
            if (xtb.chash[i] < xtb.buffer + flush)
               xtb.chash[i] = NULL;
            else
               xtb.chash[i] -= flush;
      }
      // and now that we've made room for more data, go back to the top
   }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
addl %esi, 0x10d4a(%rip)     # 0x1fe94
testl %esi, %esi
je 0xf2ea
movl %esi, %ebx
movq %rdi, %r14
movl 0x10d1f(%rip), %ecx     # 0x1fe7c
leaq 0x10d28(%rip), %r15     # 0x1fe8c
movl 0x10d0e(%rip), %eax     # 0x1fe78
movl %eax, %edx
subl %ecx, %edx
jle 0xf1a8
cmpl %edx, %ebx
cmovll %ebx, %edx
movslq %ecx, %rdi
addq 0x10cf1(%rip), %rdi     # 0x1fe70
movslq %edx, %r12
movq %r14, %rsi
movq %r12, %rdx
callq 0x2230
subl %r12d, %ebx
addq %r12, %r14
movl 0x10ce3(%rip), %ecx     # 0x1fe7c
addl %r12d, %ecx
movl %ecx, 0x10cda(%rip)     # 0x1fe7c
movl 0x10cd0(%rip), %eax     # 0x1fe78
cmpl %eax, %ecx
jl 0xf2ea
movl 0x10cca(%rip), %eax     # 0x1fe80
movl 0x10ccc(%rip), %esi     # 0x1fe88
addl %eax, %esi
movl %ecx, %edx
subl %esi, %edx
jle 0xf20f
testl %edx, %edx
jle 0xf353
movslq %eax, %rdi
movq 0x10c9a(%rip), %rax     # 0x1fe70
addq %rax, %rdi
movslq %ecx, %rsi
addq %rax, %rsi
movq 0x10cb2(%rip), %r8      # 0x1fe98
movl 0x10cb3(%rip), %r9d     # 0x1fea0
movq %r15, %rcx
callq 0xf372
addl 0x10c85(%rip), %eax     # 0x1fe80
movl %eax, 0x10c7f(%rip)     # 0x1fe80
movl 0x10c75(%rip), %ecx     # 0x1fe7c
movl 0x10c7b(%rip), %esi     # 0x1fe88
addl %eax, %esi
cmpl %ecx, %esi
jl 0xf315
movslq 0x10c66(%rip), %r12     # 0x1fe84
cmpl %r12d, %eax
jl 0xf2f6
cmpl %r12d, %ecx
jl 0xf334
movslq 0x10c55(%rip), %rsi     # 0x1fe8c
movl %eax, %edx
subl %esi, %edx
cmpl %r12d, %edx
jge 0xf262
movslq %eax, %rdi
addq 0x10c26(%rip), %rdi     # 0x1fe70
subq %rsi, %rdi
callq 0xfaf5
movl $0x0, 0x10c30(%rip)     # 0x1fe8c
movl 0x10c1a(%rip), %ecx     # 0x1fe7c
movq 0x10c07(%rip), %rdi     # 0x1fe70
leaq (%rdi,%r12), %rsi
subl %r12d, %ecx
movslq %ecx, %rdx
callq 0x22d0
movq 0x10bfc(%rip), %xmm0    # 0x1fe7c
movd %r12d, %xmm1
pshufd $0x50, %xmm1, %xmm1     # xmm1 = xmm1[0,0,1,1]
psubd %xmm1, %xmm0
movq %xmm0, 0x10be6(%rip)    # 0x1fe7c
movl 0x10c04(%rip), %eax     # 0x1fea0
movq %r12, %rcx
negq %rcx
leal 0x1(%rax), %edx
cmpl $0x1, %edx
adcl $0x1, %eax
xorl %edx, %edx
movq 0x10be4(%rip), %rsi     # 0x1fe98
movq (%rsi,%rdx,8), %rdi
movq 0x10bb1(%rip), %r8      # 0x1fe70
addq %r12, %r8
leaq (%rdi,%rcx), %r9
cmpq %r8, %rdi
movl $0x0, %edi
cmovaeq %r9, %rdi
movq %rdi, (%rsi,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0xf2ad
movd %xmm0, %ecx
testl %ebx, %ebx
jne 0xf164
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x3ba3(%rip), %rdi      # 0x12ea0
leaq 0x31ad(%rip), %rsi      # 0x124b1
leaq 0x3b56(%rip), %rcx      # 0x12e61
movl $0x2a07, %edx           # imm = 0x2A07
callq 0x2140
leaq 0x3b61(%rip), %rdi      # 0x12e7d
leaq 0x318e(%rip), %rsi      # 0x124b1
leaq 0x3b37(%rip), %rcx      # 0x12e61
movl $0x2a00, %edx           # imm = 0x2A00
callq 0x2140
leaq 0x3b78(%rip), %rdi      # 0x12eb3
leaq 0x316f(%rip), %rsi      # 0x124b1
leaq 0x3b18(%rip), %rcx      # 0x12e61
movl $0x2a08, %edx           # imm = 0x2A08
callq 0x2140
leaq 0x3afc(%rip), %rdi      # 0x12e56
leaq 0x3150(%rip), %rsi      # 0x124b1
leaq 0x3af9(%rip), %rcx      # 0x12e61
movl $0x29fa, %edx           # imm = 0x29FA
callq 0x2140