// File: /workspace/github_cpp_makefile_star2_O1/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, 0x10a25(%rip)     # 0x1fea4
testl %esi, %esi
je 0xf60f
movl %esi, %ebx
movq %rdi, %r14
leaq 0x10a09(%rip), %r15     # 0x1fe9c
movslq 0x109f2(%rip), %rdi     # 0x1fe8c
movl 0x109e8(%rip), %eax     # 0x1fe88
cmpl %edi, %eax
jle 0xf4cd
subl %edi, %eax
cmpl %eax, %ebx
cmovll %ebx, %eax
addq 0x109ce(%rip), %rdi     # 0x1fe80
movslq %eax, %r12
movq %r14, %rsi
movq %r12, %rdx
callq 0x2230
subl %r12d, %ebx
addq %r12, %r14
addl %r12d, 0x109bf(%rip)    # 0x1fe8c
movslq 0x109b8(%rip), %rsi     # 0x1fe8c
cmpl 0x109ae(%rip), %esi     # 0x1fe88
jl 0xf60f
movslq 0x109a9(%rip), %rdi     # 0x1fe90
movl 0x109ab(%rip), %eax     # 0x1fe98
addl %edi, %eax
cmpl %eax, %esi
jle 0xf528
movl %esi, %edx
subl %eax, %edx
testl %edx, %edx
jle 0xf678
movq 0x1097a(%rip), %rax     # 0x1fe80
addq %rax, %rdi
addq %rax, %rsi
movq 0x10995(%rip), %r8      # 0x1fea8
movl 0x10996(%rip), %r9d     # 0x1feb0
movq %r15, %rcx
callq 0xf697
addl %eax, 0x10968(%rip)     # 0x1fe90
movslq 0x10961(%rip), %rdi     # 0x1fe90
movl 0x10963(%rip), %ecx     # 0x1fe98
addl %edi, %ecx
movl 0x1094f(%rip), %eax     # 0x1fe8c
cmpl %eax, %ecx
jl 0xf63a
movslq 0x10948(%rip), %r12     # 0x1fe94
cmpl %r12d, %edi
jl 0xf61b
cmpl %r12d, %eax
jl 0xf659
movslq 0x10937(%rip), %rsi     # 0x1fe9c
movl %edi, %eax
subl %esi, %eax
cmpl %r12d, %eax
jge 0xf587
addq 0x1090b(%rip), %rdi     # 0x1fe80
subq %rsi, %rdi
callq 0xfdaa
movl $0x0, 0x10915(%rip)     # 0x1fe9c
movq 0x108f2(%rip), %rdi     # 0x1fe80
leaq (%rdi,%r12), %rsi
movslq 0x108f3(%rip), %rdx     # 0x1fe8c
subq %r12, %rdx
callq 0x22d0
movq 0x108e3(%rip), %xmm0    # 0x1fe8c
movd %r12d, %xmm1
pshufd $0x50, %xmm1, %xmm1     # xmm1 = xmm1[0,0,1,1]
psubd %xmm1, %xmm0
movq %xmm0, 0x108cd(%rip)    # 0x1fe8c
movl 0x108eb(%rip), %eax     # 0x1feb0
movq %r12, %rcx
negq %rcx
leal 0x1(%rax), %edx
cmpl $0x1, %edx
adcl $0x1, %eax
xorl %edx, %edx
movq 0x108cb(%rip), %rsi     # 0x1fea8
movq (%rsi,%rdx,8), %rdi
movq 0x10898(%rip), %r8      # 0x1fe80
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 0xf5d6
testl %ebx, %ebx
jne 0xf493
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x38d8(%rip), %rdi      # 0x12efa
leaq 0x2ed8(%rip), %rsi      # 0x12501
leaq 0x388b(%rip), %rcx      # 0x12ebb
movl $0x2a07, %edx           # imm = 0x2A07
callq 0x2140
leaq 0x3896(%rip), %rdi      # 0x12ed7
leaq 0x2eb9(%rip), %rsi      # 0x12501
leaq 0x386c(%rip), %rcx      # 0x12ebb
movl $0x2a00, %edx           # imm = 0x2A00
callq 0x2140
leaq 0x38ad(%rip), %rdi      # 0x12f0d
leaq 0x2e9a(%rip), %rsi      # 0x12501
leaq 0x384d(%rip), %rcx      # 0x12ebb
movl $0x2a08, %edx           # imm = 0x2A08
callq 0x2140
leaq 0x3831(%rip), %rdi      # 0x12eb0
leaq 0x2e7b(%rip), %rsi      # 0x12501
leaq 0x382e(%rip), %rcx      # 0x12ebb
movl $0x29fa, %edx           # imm = 0x29FA
callq 0x2140