// File: /workspace/github_c_makefile_star2_O2/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, 0x48(%rsp)
movl %r8d, %r12d
movq %rcx, %rbp
movq %rdx, %r15
movq %rsi, 0x18(%rsp)
movq %rdi, 0x10(%rsp)
movq 0x1b0(%rsp), %rcx
movl (%rcx), %eax
movl %eax, 0x3c(%rsp)
movl 0x3c0(%rcx), %eax
movl %eax, 0x38(%rsp)
movslq %r8d, %rbx
shll $0x3, %r12d
leaq 0x1c(%rbp), %r14
leaq (,%rbx,4), %rax
movq %rax, 0x20(%rsp)
xorl %r13d, %r13d
cmpq %r12, %r13
jge 0x15a12
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 0x15d81
popq %rax
popq %rcx
addq %rbx, %r13
addq 0x20(%rsp), %r14
jmp 0x159dd
leal (%rbx,%rbx), %eax
leal (%rbx,%rbx,2), %ecx
leal (,%rbx,4), %edx
leal (%rbx,%rbx,4), %esi
imull $0x6, %ebx, %edi
imull $0x7, %ebx, %r8d
movslq %r8d, %r8
movslq %edi, %rdi
movslq %esi, %rsi
movslq %ecx, %rcx
leaq (%rbp,%rbx,4), %r9
movq %r9, 0x30(%rsp)
leaq (%rbp,%rax,4), %rax
movq %rax, 0x28(%rsp)
leaq (%rbp,%rcx,4), %rax
movq %rax, 0x58(%rsp)
leaq (%rbp,%rdx,4), %rax
movq %rax, 0x50(%rsp)
leaq (,%rsi,4), %rbx
addq %rbp, %rbx
leaq (,%rdi,4), %r14
addq %rbp, %r14
leaq (,%r8,4), %r12
addq %rbp, %r12
xorl %r13d, %r13d
cmpq $0x20, %r13
je 0x15acf
movq %rbp, %rdi
addq %r13, %rdi
movq 0x30(%rsp), %rax
leaq (%rax,%r13), %rsi
movq 0x28(%rsp), %rax
leaq (%rax,%r13), %rdx
movq 0x58(%rsp), %rax
leaq (%rax,%r13), %rcx
movq 0x50(%rsp), %rax
leaq (%rax,%r13), %r8
leaq (%rbx,%r13), %r9
leaq (%r14,%r13), %rax
leaq (%r12,%r13), %r10
pushq %r10
pushq %rax
callq 0x15d81
addq $0x10, %rsp
addq $0x4, %r13
jmp 0x15a81
xorl %eax, %eax
xorps %xmm0, %xmm0
leaq 0x6035(%rip), %rcx      # 0x1bb10
leaq 0x586e(%rip), %rdx      # 0x1b350
xorl %esi, %esi
movq 0x48(%rsp), %r11
cmpq $0x8, %rax
je 0x15b3f
movslq %esi, %rsi
leaq (%r11,%rsi,4), %r8
xorl %edi, %edi
cmpq $0x8, %rdi
je 0x15b32
movss (%rbp,%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
jmp 0x15af8
incq %rax
addq 0x20(%rsp), %rbp
addq %rdi, %rsi
jmp 0x15ae9
movl 0x60(%rsp), %ebx
movl %ebx, %edi
subl 0x1a0(%rsp), %edi
jne 0x15b65
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
movq 0x1a8(%rsp), %rcx
jmp 0x15bac
movl %ebx, %ebp
leaq 0xc(%rsp), %r12
movq %r12, %rsi
callq 0x15eaa
movzwl 0x2(%r12), %eax
movq 0x1a8(%rsp), %rcx
leaq (%rcx,%rax,4), %rcx
movq 0x10(%rsp), %r14
movq %r14, %rdi
movq 0x18(%rsp), %rbx
movq %rbx, %rsi
movq %r15, %rdx
callq 0x15ce6
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
movl %ebp, %ebx
callq 0x15ce6
xorl %ecx, %ecx
pushq $0x3f
popq %r13
testl %r13d, %r13d
je 0x15cbb
movl %r13d, %eax
cmpl $0x0, 0x60(%rsp,%rax,4)
jne 0x15bd1
incl %ecx
decq %r13
jmp 0x15bb7
movl %ecx, 0x28(%rsp)
movl %ebx, 0x30(%rsp)
pushq $0x1
popq %rax
leaq 0x38(%rsp), %r12
movq %r15, 0x40(%rsp)
cmpl %r13d, %eax
jg 0x15cb0
movq %rax, 0x20(%rsp)
cltq
xorl %ecx, %ecx
pushq $-0x1
popq %rdx
movl %edx, %ebx
movl %ecx, %r14d
movl 0x60(%rsp,%rax,4), %ebp
incl %ebx
cmpq %r13, %rax
jg 0x15c16
incq %rax
leal 0x1(%r14), %ecx
testl %ebp, %ebp
je 0x15bfd
movl %ebx, %r15d
cmpl $0x10, %ebx
jl 0x15c4b
shrl $0x4, %r14d
movq 0x40(%rsp), %r15
subl $0x1, %r14d
jb 0x15c44
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x15ce6
jmp 0x15c27
movl %ebx, %r15d
andl $0xf, %r15d
movl %ebp, %edi
leaq 0xc(%rsp), %rsi
callq 0x15eaa
shll $0x4, %r15d
movzwl 0xe(%rsp), %eax
movslq %r15d, %rcx
addq %rax, %rcx
movq 0x1b0(%rsp), %rax
leaq (%rax,%rcx,4), %rcx
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq 0x18(%rsp), %r14
movq %r14, %rsi
movq 0x40(%rsp), %r15
movq %r15, %rdx
callq 0x15ce6
movq %rbp, %rdi
movq %r14, %rsi
movq %r15, %rdx
leaq 0xc(%rsp), %rcx
callq 0x15ce6
movq 0x20(%rsp), %rax
addl %ebx, %eax
incl %eax
jmp 0x15be6
cmpl $0x0, 0x28(%rsp)
movl 0x30(%rsp), %ebx
je 0x15cd2
leaq 0x3c(%rsp), %rcx
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
callq 0x15ce6
movl %ebx, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq