// File: /workspace/github_c_makefile_star2_O3/yui0[P]img2vec/./stb_image_write.h
// Function: stbiw__jpg_processDU
static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt, float *CDU, int du_stride, float *fdtbl, int DC, const unsigned short HTDC[256][2], const unsigned short HTAC[256][2]) {
   const unsigned short EOB[2] = { HTAC[0x00][0], HTAC[0x00][1] };
   const unsigned short M16zeroes[2] = { HTAC[0xF0][0], HTAC[0xF0][1] };
   int dataOff, i, j, n, diff, end0pos, x, y;
   int DU[64];

   // DCT rows
   for(dataOff=0, n=du_stride*8; dataOff<n; dataOff+=du_stride) {
      stbiw__jpg_DCT(&CDU[dataOff], &CDU[dataOff+1], &CDU[dataOff+2], &CDU[dataOff+3], &CDU[dataOff+4], &CDU[dataOff+5], &CDU[dataOff+6], &CDU[dataOff+7]);
   }
   // DCT columns
   for(dataOff=0; dataOff<8; ++dataOff) {
      stbiw__jpg_DCT(&CDU[dataOff], &CDU[dataOff+du_stride], &CDU[dataOff+du_stride*2], &CDU[dataOff+du_stride*3], &CDU[dataOff+du_stride*4],
                     &CDU[dataOff+du_stride*5], &CDU[dataOff+du_stride*6], &CDU[dataOff+du_stride*7]);
   }
   // Quantize/descale/zigzag the coefficients
   for(y = 0, j=0; y < 8; ++y) {
      for(x = 0; x < 8; ++x,++j) {
         float v;
         i = y*du_stride+x;
         v = CDU[i]*fdtbl[j];
         // DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? ceilf(v - 0.5f) : floorf(v + 0.5f));
         // ceilf() and floorf() are C99, not C89, but I /think/ they're not needed here anyway?
         DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? v - 0.5f : v + 0.5f);
      }
   }

   // Encode DC
   diff = DU[0] - DC;
   if (diff == 0) {
      stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[0]);
   } else {
      unsigned short bits[2];
      stbiw__jpg_calcBits(diff, bits);
      stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[bits[1]]);
      stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits);
   }
   // Encode ACs
   end0pos = 63;
   for(; (end0pos>0)&&(DU[end0pos]==0); --end0pos) {
   }
   // end0pos = first element in reverse order !=0
   if(end0pos == 0) {
      stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB);
      return DU[0];
   }
   for(i = 1; i <= end0pos; ++i) {
      int startpos = i;
      int nrzeroes;
      unsigned short bits[2];
      for (; DU[i]==0 && i<=end0pos; ++i) {
      }
      nrzeroes = i-startpos;
      if ( nrzeroes >= 16 ) {
         int lng = nrzeroes>>4;
         int nrmarker;
         for (nrmarker=1; nrmarker <= lng; ++nrmarker)
            stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes);
         nrzeroes &= 15;
      }
      stbiw__jpg_calcBits(DU[i], bits);
      stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes<<4)+bits[1]]);
      stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits);
   }
   if(end0pos != 63) {
      stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB);
   }
   return DU[0];
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %r9, 0x30(%rsp)
movq %rcx, %r15
movq %rdx, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdi, 0x10(%rsp)
movq 0x1b0(%rsp), %rcx
movzwl (%rcx), %eax
movl %eax, 0x4c(%rsp)
movzwl 0x2(%rcx), %eax
movl %eax, 0x48(%rsp)
movzwl 0x3c0(%rcx), %eax
movl %eax, 0x54(%rsp)
movzwl 0x3c2(%rcx), %eax
movl %eax, 0x50(%rsp)
testl %r8d, %r8d
je 0x1a061
leal (,%r8,8), %ebx
movq %r8, 0x8(%rsp)
movslq %r8d, %rbp
leaq 0x1c(%r15), %r14
leaq (,%rbp,4), %r12
xorl %r13d, %r13d
leaq -0x1c(%r14), %rdi
leaq -0x18(%r14), %rsi
leaq -0x14(%r14), %rdx
leaq -0x10(%r14), %rcx
leaq -0xc(%r14), %r8
leaq -0x8(%r14), %r9
leaq -0x4(%r14), %rax
pushq %r14
pushq %rax
callq 0x1a478
addq $0x10, %rsp
addq %rbp, %r13
addq %r12, %r14
cmpq %rbx, %r13
jl 0x1a027
movq 0x8(%rsp), %r8
jmp 0x1a063
xorl %ebp, %ebp
leal (%r8,%r8), %eax
leal (%r8,%r8,2), %ecx
leal (,%r8,4), %edx
leal (%r8,%r8,4), %esi
leal (%rax,%rax,2), %edi
leal (,%r8,8), %r9d
subl %r8d, %r9d
movslq %ecx, %rcx
movslq %esi, %rsi
movslq %edi, %rdi
movslq %r9d, %r8
movq %rbp, 0x28(%rsp)
leaq (%r15,%rbp,4), %r9
movq %r9, 0x8(%rsp)
leaq (%r15,%rax,4), %rax
movq %rax, 0x40(%rsp)
leaq (%r15,%rcx,4), %rax
movq %rax, 0x38(%rsp)
leaq (%r15,%rdx,4), %rbx
leaq (%r15,%rsi,4), %r13
leaq (%r15,%rdi,4), %r14
leaq (%r15,%r8,4), %r12
xorl %ebp, %ebp
leaq (%r15,%rbp), %rdi
movq 0x8(%rsp), %rax
leaq (%rax,%rbp), %rsi
movq 0x40(%rsp), %rax
leaq (%rax,%rbp), %rdx
movq 0x38(%rsp), %rax
leaq (%rax,%rbp), %rcx
leaq (%rbx,%rbp), %r8
leaq (%r13,%rbp), %r9
leaq (%r14,%rbp), %rax
leaq (%r12,%rbp), %r10
pushq %r10
pushq %rax
callq 0x1a478
addq $0x10, %rsp
addq $0x4, %rbp
cmpq $0x20, %rbp
jne 0x1a0c3
movq 0x28(%rsp), %r13
shlq $0x2, %r13
xorl %eax, %eax
xorps %xmm0, %xmm0
leaq 0x6b02(%rip), %rcx      # 0x20c20
leaq 0x633b(%rip), %rdx      # 0x20460
xorl %esi, %esi
movq 0x20(%rsp), %rbx
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %r12
movq 0x30(%rsp), %r11
movslq %esi, %rsi
leaq (%r11,%rsi,4), %r8
xorl %edi, %edi
movss (%r15,%rdi,4), %xmm1
mulss (%r8,%rdi,4), %xmm1
xorl %r9d, %r9d
ucomiss %xmm1, %xmm0
seta %r9b
addss (%rcx,%r9,4), %xmm1
cvttss2si %xmm1, %r9d
leaq (%rsi,%rdi), %r10
movzbl (%rdx,%r10), %r10d
movl %r9d, 0x60(%rsp,%r10,4)
incq %rdi
cmpq $0x8, %rdi
jne 0x1a144
incq %rax
addq %rdi, %rsi
addq %r13, %r15
cmpq $0x8, %rax
jne 0x1a13b
movl 0x60(%rsp), %ebp
movl %ebp, %eax
subl 0x1a0(%rsp), %eax
jne 0x1a1b5
movq 0x1a8(%rsp), %rax
movzwl 0x2(%rax), %r8d
movzwl (%rax), %ecx
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
jmp 0x1a21e
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
bsrl %ecx, %edx
xorl $-0x20, %edx
addl $0x21, %edx
cmpl $0x2, %ecx
movl $0x1, %r13d
cmovael %edx, %r13d
movl %eax, %edx
sarl $0x1f, %edx
addl %eax, %edx
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl %r13d, %ecx
shll %cl, %r15d
notl %r15d
andl %edx, %r15d
movzbl %r13b, %eax
movq 0x1a8(%rsp), %rcx
movzwl 0x2(%rcx,%rax,4), %r8d
movzwl (%rcx,%rax,4), %ecx
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1a3c7
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movl %r15d, %ecx
movl %r13d, %r8d
callq 0x1a3c7
movl $0x40, %eax
leal -0x1(%rax), %ecx
cmpl $0x0, 0x60(%rsp,%rcx,4)
jne 0x1a23e
movl %ecx, %eax
cmpl $0x1, %ecx
ja 0x1a228
jmp 0x1a39c
testl %ecx, %ecx
jle 0x1a39c
movq %rax, 0x58(%rsp)
movl %ebp, 0x28(%rsp)
movl %ecx, %edx
movl $0x1, %eax
movq %rcx, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movq %rax, 0x8(%rsp)
cltq
xorl %ecx, %ecx
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl %ecx, %r15d
movl 0x60(%rsp,%rax,4), %r13d
incl %r12d
cmpq %rdx, %rax
jg 0x1a28b
incq %rax
leal 0x1(%r15), %ecx
testl %r13d, %r13d
je 0x1a26f
movl %r12d, %eax
cmpl $0x10, %r12d
jl 0x1a2d1
shrl $0x4, %r15d
cmpl $0x1, %r15d
adcl $0x0, %r15d
movq 0x10(%rsp), %rbx
movl 0x54(%rsp), %r14d
movl 0x50(%rsp), %ebp
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movl %r14d, %ecx
movl %ebp, %r8d
callq 0x1a3c7
decl %r15d
jne 0x1a2ae
movl %r12d, %eax
andl $0xf, %eax
movl %r13d, %ecx
negl %ecx
cmovsl %r13d, %ecx
bsrl %ecx, %r15d
xorl $-0x20, %r15d
addl $0x21, %r15d
cmpl $0x2, %ecx
movl $0x1, %ecx
cmovbl %ecx, %r15d
movl %r13d, %edx
sarl $0x1f, %edx
addl %r13d, %edx
movzbl %r15b, %ecx
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
shll %cl, %r13d
movq 0x8(%rsp), %rsi
addl %r12d, %esi
movl %esi, 0x40(%rsp)
notl %r13d
andl %edx, %r13d
shll $0x4, %eax
addl %ecx, %eax
cltq
movq 0x1b0(%rsp), %rcx
movzwl 0x2(%rcx,%rax,4), %r8d
movzwl (%rcx,%rax,4), %ecx
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq 0x18(%rsp), %rbp
movq %rbp, %rsi
movq 0x20(%rsp), %r14
movq %r14, %rdx
callq 0x1a3c7
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movl %r13d, %ecx
movl %r15d, %r8d
callq 0x1a3c7
movq 0x8(%rsp), %rax
addl %r12d, %eax
incl %eax
movq 0x38(%rsp), %rcx
cmpl 0x40(%rsp), %ecx
movq 0x30(%rsp), %rdx
jg 0x1a260
cmpl $0x40, 0x58(%rsp)
movq 0x20(%rsp), %rbx
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %r12
movl 0x28(%rsp), %ebp
je 0x1a3b3
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movl 0x4c(%rsp), %ecx
movl 0x48(%rsp), %r8d
callq 0x1a3c7
movl %ebp, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq