// File: /workspace/github_c_makefile_star2_O1/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 $0x158, %rsp            # imm = 0x158
movq %r9, 0x28(%rsp)
movq %rcx, %r13
movq %rdx, 0x30(%rsp)
movq %rsi, 0x8(%rsp)
movq %rdi, 0x10(%rsp)
movq 0x1a0(%rsp), %rcx
movzwl (%rcx), %eax
movw %ax, 0x1c(%rsp)
movzwl 0x2(%rcx), %eax
movw %ax, 0x1e(%rsp)
movzwl 0x3c0(%rcx), %eax
movw %ax, 0x18(%rsp)
movzwl 0x3c2(%rcx), %eax
movw %ax, 0x1a(%rsp)
movslq %r8d, %rbp
testl %r8d, %r8d
je 0x19258
leal (,%rbp,8), %ebx
leaq 0x1c(%r13), %r14
leaq (,%rbp,4), %r15
xorl %r12d, %r12d
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 0x19651
addq $0x10, %rsp
addq %rbp, %r12
addq %r15, %r14
cmpq %rbx, %r12
jl 0x19225
leal (,%rbp,2), %eax
leal (%rbp,%rbp,2), %ecx
leal (,%rbp,4), %edx
leal (%rbp,%rbp,4), %esi
leal (%rax,%rax,2), %edi
leal (,%rbp,8), %r8d
subl %ebp, %r8d
movslq %ecx, %rcx
movslq %esi, %rsi
movslq %edi, %rdi
movslq %r8d, %r8
movq %rbp, 0x20(%rsp)
leaq (%r13,%rbp,4), %r9
movq %r9, 0x48(%rsp)
leaq (%r13,%rax,4), %rax
movq %rax, 0x40(%rsp)
leaq (%r13,%rcx,4), %rax
movq %rax, 0x38(%rsp)
leaq (%r13,%rdx,4), %r12
leaq (,%rsi,4), %rbp
addq %r13, %rbp
leaq (,%rdi,4), %rbx
addq %r13, %rbx
leaq (,%r8,4), %r14
addq %r13, %r14
xorl %r15d, %r15d
leaq (%r15,%r13), %rdi
movq 0x48(%rsp), %rax
leaq (%rax,%r15), %rsi
movq 0x40(%rsp), %rax
leaq (%rax,%r15), %rdx
movq 0x38(%rsp), %rax
leaq (%rax,%r15), %rcx
leaq (%r12,%r15), %r8
leaq (%rbp,%r15), %r9
leaq (%rbx,%r15), %rax
leaq (%r14,%r15), %r10
pushq %r10
pushq %rax
callq 0x19651
addq $0x10, %rsp
addq $0x4, %r15
cmpq $0x20, %r15
jne 0x192d4
movq 0x20(%rsp), %rbx
shlq $0x2, %rbx
xorl %eax, %eax
xorps %xmm0, %xmm0
leaq 0x67b1(%rip), %rcx      # 0x1fae0
leaq 0x5fea(%rip), %rdx      # 0x1f320
xorl %esi, %esi
movq 0x30(%rsp), %r15
movq 0x28(%rsp), %r11
movslq %esi, %rsi
leaq (%r11,%rsi,4), %r8
xorl %edi, %edi
movss (%r13,%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, 0x50(%rsp,%r10,4)
incq %rdi
cmpq $0x8, %rdi
jne 0x1934b
incq %rax
addq %rdi, %rsi
addq %rbx, %r13
cmpq $0x8, %rax
jne 0x19342
movl 0x50(%rsp), %r14d
movl %r14d, %eax
subl 0x190(%rsp), %eax
jne 0x193bb
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rdx
movq 0x198(%rsp), %rcx
jmp 0x1942b
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
bsrl %ecx, %edx
xorl $-0x20, %edx
addl $0x21, %edx
cmpl $0x2, %ecx
movl $0x1, %ecx
cmovael %edx, %ecx
leaq 0x4(%rsp), %r12
movw %cx, 0x2(%r12)
movl %eax, %edx
sarl $0x1f, %edx
addl %eax, %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shll %cl, %eax
notl %eax
andl %edx, %eax
movw %ax, (%r12)
movzbl %cl, %eax
movq 0x198(%rsp), %rcx
leaq (%rcx,%rax,4), %rcx
movq 0x10(%rsp), %r13
movq %r13, %rdi
movq 0x8(%rsp), %rbx
movq %rbx, %rsi
movq %r15, %rdx
callq 0x195b7
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x195b7
movl $0x40, %eax
leal -0x1(%rax), %r13d
cmpl $0x0, 0x50(%rsp,%r13,4)
jne 0x1944b
decl %eax
cmpl $0x1, %eax
ja 0x19435
xorl %r13d, %r13d
testl %r13d, %r13d
je 0x1958b
movl %r14d, 0x20(%rsp)
jle 0x19580
movl %r13d, %edx
movl $0x1, %ebp
movq %r13, 0x28(%rsp)
movq %rdx, 0x38(%rsp)
movq %rbp, 0x48(%rsp)
movslq %ebp, %rax
xorl %ecx, %ecx
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ecx, %r15d
movl 0x50(%rsp,%rax,4), %r14d
incl %ebx
cmpq %rdx, %rax
jg 0x1949b
incq %rax
leal 0x1(%r15), %ecx
testl %r14d, %r14d
je 0x19480
movl %ebx, %eax
cmpl $0x10, %ebx
jl 0x194df
shrl $0x4, %r15d
cmpl $0x1, %r15d
adcl $0x0, %r15d
movq 0x8(%rsp), %rbp
movq 0x30(%rsp), %r12
leaq 0x18(%rsp), %r13
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x195b7
decl %r15d
jne 0x194bd
movl %ebx, %eax
andl $0xf, %eax
movq 0x28(%rsp), %r13
movl %r14d, %ecx
negl %ecx
cmovsl %r14d, %ecx
bsrl %ecx, %edx
xorl $-0x20, %edx
addl $0x21, %edx
cmpl $0x2, %ecx
movl $0x1, %ecx
cmovbl %ecx, %edx
movw %dx, 0x6(%rsp)
movl %r14d, %esi
sarl $0x1f, %esi
addl %r14d, %esi
movzbl %dl, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
shll %cl, %edx
movq 0x48(%rsp), %rbp
leal (%rbx,%rbp), %edi
movl %edi, 0x40(%rsp)
notl %edx
andl %esi, %edx
movw %dx, 0x4(%rsp)
shll $0x4, %eax
addl %ecx, %eax
cltq
movq 0x1a0(%rsp), %rcx
leaq (%rcx,%rax,4), %rcx
movq 0x10(%rsp), %r12
movq %r12, %rdi
movq 0x8(%rsp), %r14
movq %r14, %rsi
movq 0x30(%rsp), %r15
movq %r15, %rdx
callq 0x195b7
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
leaq 0x4(%rsp), %rcx
callq 0x195b7
addl %ebx, %ebp
incl %ebp
cmpl 0x40(%rsp), %r13d
movq 0x38(%rsp), %rdx
jg 0x19471
cmpl $0x3f, %r13d
movl 0x20(%rsp), %r14d
je 0x195a2
leaq 0x1c(%rsp), %rcx
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rdx
callq 0x195b7
movl %r14d, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq