// File: /workspace/github_c_makefile_star2_O1/ggerganov[P]font-rasterizer/./stb_image_write.h
// Function: stbiw__jpg_processDU
static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt, float *CDU, 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, diff, end0pos;
   int DU[64];

   // DCT rows
   for(dataOff=0; dataOff<64; dataOff+=8) {
      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+8], &CDU[dataOff+16], &CDU[dataOff+24], &CDU[dataOff+32], &CDU[dataOff+40], &CDU[dataOff+48], &CDU[dataOff+56]);
   }
   // Quantize/descale/zigzag the coefficients
   for(i=0; i<64; ++i) {
      float v = CDU[i]*fdtbl[i];
      // DU[stbiw__jpg_ZigZag[i]] = (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[i]] = (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
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movl %r9d, -0x40(%rbp)
movq %r8, -0x38(%rbp)
movq %rcx, %r13
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, -0x50(%rbp)
movq 0x18(%rbp), %rcx
movzwl (%rcx), %eax
movw %ax, -0x48(%rbp)
movzwl 0x2(%rcx), %eax
movw %ax, -0x46(%rbp)
movzwl 0x3c0(%rcx), %eax
movw %ax, -0x44(%rbp)
movzwl 0x3c2(%rcx), %eax
movw %ax, -0x42(%rbp)
movq $-0x8, %rbx
movq %r13, %r12
leaq 0x4(%r12), %rsi
leaq 0x8(%r12), %rdx
leaq 0xc(%r12), %rcx
leaq 0x10(%r12), %r8
leaq 0x14(%r12), %r9
leaq 0x18(%r12), %rax
leaq 0x1c(%r12), %r10
movq %r12, %rdi
pushq %r10
pushq %rax
callq 0xa94a
addq $0x10, %rsp
addq $0x8, %rbx
addq $0x20, %r12
cmpq $0x38, %rbx
jb 0xa5ca
xorl %ebx, %ebx
leaq (%rbx,%r13), %rdi
leaq (%rbx,%r13), %rsi
addq $0x20, %rsi
leaq 0x40(%r13,%rbx), %rdx
leaq 0x60(%r13,%rbx), %rcx
leaq 0x80(%r13,%rbx), %r8
leaq 0xa0(%r13,%rbx), %r9
leaq 0xc0(%r13,%rbx), %rax
leaq (%rbx,%r13), %r10
addq $0xe0, %r10
pushq %r10
pushq %rax
callq 0xa94a
addq $0x10, %rsp
addq $0x4, %rbx
cmpq $0x20, %rbx
jne 0xa60c
xorl %eax, %eax
xorps %xmm0, %xmm0
leaq 0x4519(%rip), %rcx      # 0xeb80
leaq 0x43b2(%rip), %rdx      # 0xea20
movq -0x38(%rbp), %r8
movss (%r13,%rax,4), %xmm1
mulss (%r8,%rax,4), %xmm1
xorl %esi, %esi
ucomiss %xmm1, %xmm0
seta %sil
addss (%rcx,%rsi,4), %xmm1
cvttss2si %xmm1, %esi
movzbl (%rax,%rdx), %edi
movl %esi, -0x170(%rbp,%rdi,4)
incq %rax
cmpq $0x40, %rax
jne 0xa672
movl -0x170(%rbp), %eax
movl %eax, -0x54(%rbp)
subl -0x40(%rbp), %eax
jne 0xa6c6
movq -0x50(%rbp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq 0x10(%rbp), %rcx
jmp 0xa72b
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 -0x2c(%rbp), %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 0x10(%rbp), %rcx
leaq (%rcx,%rax,4), %rcx
movq -0x50(%rbp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xa8a7
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0xa8a7
movl $0x40, %eax
leal -0x1(%rax), %ecx
cmpl $0x0, -0x170(%rbp,%rcx,4)
jne 0xa74b
decl %eax
cmpl $0x1, %eax
ja 0xa735
xorl %ecx, %ecx
testl %ecx, %ecx
je 0xa880
movq %r15, -0x38(%rbp)
movq %r14, -0x40(%rbp)
jle 0xa873
movl %ecx, %edx
movl $0x1, %r15d
movq %rcx, -0x68(%rbp)
movq %rdx, -0x60(%rbp)
movq %r15, -0x70(%rbp)
movslq %r15d, %rax
xorl %ecx, %ecx
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl %ecx, %r13d
movl -0x170(%rbp,%rax,4), %r15d
incl %r14d
cmpq %rdx, %rax
jg 0xa79f
incq %rax
leal 0x1(%r13), %ecx
testl %r15d, %r15d
je 0xa780
movl %r14d, %eax
cmpl $0x10, %r14d
jl 0xa7da
shrl $0x4, %r13d
cmpl $0x1, %r13d
adcl $0x0, %r13d
movq -0x50(%rbp), %rbx
leaq -0x44(%rbp), %r12
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %r12, %rcx
callq 0xa8a7
decl %r13d
jne 0xa7bc
movl %r14d, %eax
andl $0xf, %eax
movl %r15d, %ecx
negl %ecx
cmovsl %r15d, %ecx
bsrl %ecx, %edx
xorl $-0x20, %edx
addl $0x21, %edx
cmpl $0x2, %ecx
movl $0x1, %ecx
cmovbl %ecx, %edx
movw %dx, -0x2a(%rbp)
movl %r15d, %esi
sarl $0x1f, %esi
addl %r15d, %esi
movzbl %dl, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
shll %cl, %edx
movq -0x70(%rbp), %r15
leal (%r15,%r14), %edi
movl %edi, -0x58(%rbp)
notl %edx
andl %esi, %edx
movw %dx, -0x2c(%rbp)
shll $0x4, %eax
addl %ecx, %eax
cltq
movq 0x18(%rbp), %rcx
leaq (%rcx,%rax,4), %rcx
movq -0x50(%rbp), %r13
movq %r13, %rdi
movq -0x38(%rbp), %r12
movq %r12, %rsi
movq -0x40(%rbp), %rbx
movq %rbx, %rdx
callq 0xa8a7
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
leaq -0x2c(%rbp), %rcx
callq 0xa8a7
addl %r14d, %r15d
incl %r15d
movq -0x68(%rbp), %rcx
cmpl -0x58(%rbp), %ecx
movq -0x60(%rbp), %rdx
jg 0xa771
cmpl $0x3f, %ecx
movq -0x40(%rbp), %r14
movq -0x38(%rbp), %r15
je 0xa892
leaq -0x48(%rbp), %rcx
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xa8a7
movl -0x54(%rbp), %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq