// File: /workspace/github_cpp_makefile_star2_O2/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
movl %esi, %ebx
movq %rdi, %r14
addl %esi, 0x1056a(%rip)     # 0x1de94
leaq 0x1055b(%rip), %r15     # 0x1de8c
testl %ebx, %ebx
je 0xdab5
movl 0x1053d(%rip), %ecx     # 0x1de7c
movl 0x10533(%rip), %eax     # 0x1de78
movl %eax, %edx
subl %ecx, %edx
jle 0xd983
cmpl %edx, %ebx
cmovll %ebx, %edx
movslq %ecx, %rdi
addq 0x10516(%rip), %rdi     # 0x1de70
movslq %edx, %r12
movq %r14, %rsi
movq %r12, %rdx
callq 0x2230
subl %r12d, %ebx
addq %r12, %r14
movl 0x10508(%rip), %ecx     # 0x1de7c
addl %r12d, %ecx
movl %ecx, 0x104ff(%rip)     # 0x1de7c
movl 0x104f5(%rip), %eax     # 0x1de78
cmpl %eax, %ecx
jl 0xdab5
movl 0x104ef(%rip), %eax     # 0x1de80
movl 0x104f1(%rip), %esi     # 0x1de88
addl %eax, %esi
movl %ecx, %edx
subl %esi, %edx
jle 0xd9ea
testl %edx, %edx
jle 0xdb1e
movslq %eax, %rdi
movq 0x104bf(%rip), %rax     # 0x1de70
addq %rax, %rdi
movslq %ecx, %rsi
addq %rax, %rsi
movq 0x104d7(%rip), %r8      # 0x1de98
movl 0x104d8(%rip), %r9d     # 0x1dea0
movq %r15, %rcx
callq 0xdb3d
addl 0x104aa(%rip), %eax     # 0x1de80
movl %eax, 0x104a4(%rip)     # 0x1de80
movl 0x1049a(%rip), %ecx     # 0x1de7c
movl 0x104a0(%rip), %esi     # 0x1de88
addl %eax, %esi
cmpl %ecx, %esi
jl 0xdac1
movslq 0x1048b(%rip), %r12     # 0x1de84
cmpl %r12d, %eax
jl 0xdaff
cmpl %r12d, %ecx
jl 0xdae0
movslq 0x1047a(%rip), %rsi     # 0x1de8c
movl %eax, %edx
subl %esi, %edx
cmpl %r12d, %edx
jge 0xda3a
movslq %eax, %rdi
addq 0x1044b(%rip), %rdi     # 0x1de70
subq %rsi, %rdi
callq 0xe1bd
andl $0x0, 0x10458(%rip)     # 0x1de8c
movl 0x10442(%rip), %ecx     # 0x1de7c
movq 0x1042f(%rip), %rdi     # 0x1de70
leaq (%rdi,%r12), %rsi
subl %r12d, %ecx
movslq %ecx, %rdx
callq 0x22d0
movq 0x10424(%rip), %xmm0    # 0x1de7c
movd %r12d, %xmm1
pshufd $0x50, %xmm1, %xmm1     # xmm1 = xmm1[0,0,1,1]
psubd %xmm1, %xmm0
movq %xmm0, 0x1040e(%rip)    # 0x1de7c
movl 0x1042c(%rip), %eax     # 0x1dea0
movq %r12, %rcx
negq %rcx
incl %eax
xorl %edx, %edx
cmpq %rdx, %rax
je 0xd931
movq 0x1040a(%rip), %rsi     # 0x1de98
movq (%rsi,%rdx,8), %rdi
movq 0x103d7(%rip), %r8      # 0x1de70
addq %r12, %r8
leaq (%rdi,%rcx), %r9
cmpq %r8, %rdi
movl $0x0, %edi
cmovaeq %r9, %rdi
movq %rdi, (%rsi,%rdx,8)
incq %rdx
jmp 0xda7e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x3325(%rip), %rdi      # 0x10ded
leaq 0x2952(%rip), %rsi      # 0x10421
leaq 0x32fb(%rip), %rcx      # 0x10dd1
movl $0x2a00, %edx           # imm = 0x2A00
callq 0x2140
leaq 0x333c(%rip), %rdi      # 0x10e23
leaq 0x2933(%rip), %rsi      # 0x10421
leaq 0x32dc(%rip), %rcx      # 0x10dd1
movl $0x2a08, %edx           # imm = 0x2A08
callq 0x2140
leaq 0x330a(%rip), %rdi      # 0x10e10
leaq 0x2914(%rip), %rsi      # 0x10421
leaq 0x32bd(%rip), %rcx      # 0x10dd1
movl $0x2a07, %edx           # imm = 0x2A07
callq 0x2140
leaq 0x32a1(%rip), %rdi      # 0x10dc6
leaq 0x28f5(%rip), %rsi      # 0x10421
leaq 0x329e(%rip), %rcx      # 0x10dd1
movl $0x29fa, %edx           # imm = 0x29FA
callq 0x2140