// File: /workspace/github_c_makefile_star2_O2/archer1357[P]Offline-Raytracer/stb_image.c
// Function: stbi__idct_block
static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64], stbi_dequantize_t *dequantize)
{
   int i,val[64],*v=val;
   stbi_dequantize_t *dq = dequantize;
   stbi_uc *o;
   short *d = data;

   // columns
   for (i=0; i < 8; ++i,++d,++dq, ++v) {
      // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing
      if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0
           && d[40]==0 && d[48]==0 && d[56]==0) {
         //    no shortcut                 0     seconds
         //    (1|2|3|4|5|6|7)==0          0     seconds
         //    all separate               -0.047 seconds
         //    1 && 2|3 && 4|5 && 6|7:    -0.047 seconds
         int dcterm = d[0] * dq[0] << 2;
         v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm;
      } else {
         STBI__IDCT_1D(d[ 0]*dq[ 0],d[ 8]*dq[ 8],d[16]*dq[16],d[24]*dq[24],
                 d[32]*dq[32],d[40]*dq[40],d[48]*dq[48],d[56]*dq[56])
         // constants scaled things up by 1<<12; let's bring them back
         // down, but keep 2 extra bits of precision
         x0 += 512; x1 += 512; x2 += 512; x3 += 512;
         v[ 0] = (x0+t3) >> 10;
         v[56] = (x0-t3) >> 10;
         v[ 8] = (x1+t2) >> 10;
         v[48] = (x1-t2) >> 10;
         v[16] = (x2+t1) >> 10;
         v[40] = (x2-t1) >> 10;
         v[24] = (x3+t0) >> 10;
         v[32] = (x3-t0) >> 10;
      }
   }

   for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) {
      // no fast case since the first 1D IDCT spread components out
      STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7])
      // constants scaled things up by 1<<12, plus we had 1<<2 from first
      // loop, plus horizontal and vertical each scale by sqrt(8) so together
      // we've got an extra 1<<3, so 1<<17 total we need to remove.
      // so we want to round that, which means adding 0.5 * 1<<17,
      // aka 65536. Also, we'll end up with -128 to 127 that we want
      // to encode as 0..255 by adding 128, so we'll add that before the shift
      x0 += 65536 + (128<<17);
      x1 += 65536 + (128<<17);
      x2 += 65536 + (128<<17);
      x3 += 65536 + (128<<17);
      // tried computing the shifts into temps, or'ing the temps to see
      // if any were out of range, but that was slower
      o[0] = stbi__clamp((x0+t3) >> 17);
      o[7] = stbi__clamp((x0-t3) >> 17);
      o[1] = stbi__clamp((x1+t2) >> 17);
      o[6] = stbi__clamp((x1-t2) >> 17);
      o[2] = stbi__clamp((x2+t1) >> 17);
      o[5] = stbi__clamp((x2-t1) >> 17);
      o[3] = stbi__clamp((x3+t0) >> 17);
      o[4] = stbi__clamp((x3-t0) >> 17);
   }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rcx, -0x78(%rsp)
movl %esi, -0x64(%rsp)
movq %rdi, -0x70(%rsp)
xorl %eax, %eax
cmpl $0x8, %eax
je 0x40e4e6
movswl 0x10(%rdx,%rax,2), %ebx
movzwl 0x20(%rdx,%rax,2), %esi
movl %esi, %r8d
orw %bx, %r8w
jne 0x40e306
cmpw $0x0, 0x30(%rdx,%rax,2)
jne 0x40e304
cmpw $0x0, 0x40(%rdx,%rax,2)
jne 0x40e304
cmpw $0x0, 0x50(%rdx,%rax,2)
jne 0x40e304
cmpw $0x0, 0x60(%rdx,%rax,2)
jne 0x40e304
cmpw $0x0, 0x70(%rdx,%rax,2)
je 0x40e4a4
xorl %esi, %esi
movswl %si, %esi
movq -0x78(%rsp), %rdi
movzbl 0x10(%rdi,%rax), %r8d
imull %esi, %r8d
movswl 0x60(%rdx,%rax,2), %esi
movzbl 0x30(%rdi,%rax), %r9d
imull %esi, %r9d
leal (%r9,%r8), %esi
imull $0x8a9, %esi, %esi      # imm = 0x8A9
imull $0xffffe271, %r9d, %ecx # imm = 0xFFFFE271
addl %esi, %ecx
imull $0xc3f, %r8d, %ebp      # imm = 0xC3F
addl %esi, %ebp
movswl (%rdx,%rax,2), %esi
movzbl (%rdi,%rax), %r9d
imull %esi, %r9d
movswl 0x40(%rdx,%rax,2), %esi
movzbl 0x20(%rdi,%rax), %r8d
imull %esi, %r8d
leal (%r8,%r9), %r10d
subl %r8d, %r9d
movswl 0x70(%rdx,%rax,2), %esi
movzbl 0x38(%rdi,%rax), %r14d
imull %esi, %r14d
movswl 0x50(%rdx,%rax,2), %esi
movzbl 0x28(%rdi,%rax), %r12d
imull %esi, %r12d
movswl 0x30(%rdx,%rax,2), %esi
movzbl 0x18(%rdi,%rax), %r15d
imull %esi, %r15d
movzbl 0x8(%rdi,%rax), %r13d
imull %ebx, %r13d
leal (%r15,%r14), %r8d
leal (%r12,%r13), %edi
leal (%r14,%r13), %esi
leal (%r15,%r12), %ebx
leal (%rdi,%r8), %r11d
imull $0x12d0, %r11d, %r11d   # imm = 0x12D0
imull $0xfffff19b, %esi, %esi # imm = 0xFFFFF19B
addl %r11d, %esi
imull $0xffffd6ff, %ebx, %ebx # imm = 0xFFFFD6FF
addl %r11d, %ebx
imull $0x20da, %r12d, %r11d   # imm = 0x20DA
imull $0x1805, %r13d, %r12d   # imm = 0x1805
imull $0xfffff9c3, %edi, %edi # imm = 0xFFFFF9C3
addl %edi, %r12d
addl %edi, %r11d
imull $0x312a, %r15d, %r13d   # imm = 0x312A
imull $0xffffe09e, %r8d, %edi # imm = 0xFFFFE09E
addl %edi, %r13d
addl %ebx, %r13d
addl %ebx, %r11d
imull $0x4c7, %r14d, %r14d    # imm = 0x4C7
addl %edi, %r14d
shll $0xc, %r10d
shll $0xc, %r9d
addl %esi, %r12d
addl %esi, %r14d
movl %r10d, %r15d
subl %ebp, %r15d
movl $0x200, %esi            # imm = 0x200
addl %esi, %r10d
addl %ebp, %r10d
movl %r9d, %ebp
subl %ecx, %ebp
addl %esi, %r9d
addl %ecx, %r9d
leal (%r12,%r10), %ecx
sarl $0xa, %ecx
movl %ecx, -0x60(%rsp,%rax,4)
subl %r12d, %r10d
sarl $0xa, %r10d
movl %r10d, 0x80(%rsp,%rax,4)
leal (%r9,%r13), %ecx
sarl $0xa, %ecx
movl %ecx, -0x40(%rsp,%rax,4)
subl %r13d, %r9d
sarl $0xa, %r9d
movl %r9d, 0x60(%rsp,%rax,4)
leal (%r11,%rbp), %ecx
addl $0x200, %ecx            # imm = 0x200
sarl $0xa, %ecx
movl %ecx, -0x20(%rsp,%rax,4)
leal (%rsi,%rbp), %ecx
subl %r11d, %ecx
sarl $0xa, %ecx
movl %ecx, 0x40(%rsp,%rax,4)
leal (%r15,%r14), %ecx
addl $0x200, %ecx            # imm = 0x200
sarl $0xa, %ecx
movl %ecx, (%rsp,%rax,4)
leal (%r15,%rsi), %ecx
subl %r14d, %ecx
sarl $0xa, %ecx
movl %ecx, 0x20(%rsp,%rax,4)
incq %rax
jmp 0x40e2bc
movswl (%rdx,%rax,2), %esi
movq -0x78(%rsp), %rcx
movzbl (%rcx,%rax), %r8d
imull %esi, %r8d
shll $0x2, %r8d
movl %r8d, 0x80(%rsp,%rax,4)
movl %r8d, 0x60(%rsp,%rax,4)
movl %r8d, 0x40(%rsp,%rax,4)
movl %r8d, 0x20(%rsp,%rax,4)
movl %r8d, (%rsp,%rax,4)
movl %r8d, -0x20(%rsp,%rax,4)
movl %r8d, -0x40(%rsp,%rax,4)
movl %r8d, -0x60(%rsp,%rax,4)
jmp 0x40e49c
movslq -0x64(%rsp), %rax
movq %rax, -0x78(%rsp)
addq $0x7, -0x70(%rsp)
movabsq $0x1c, %rcx
cmpl $0x11c, %ecx            # imm = 0x11C
je 0x40e6cd
movl -0x74(%rsp,%rcx), %eax
movl -0x64(%rsp,%rcx), %edx
leal (%rdx,%rax), %edi
imull $0x8a9, %edi, %edi      # imm = 0x8A9
imull $0xffffe271, %edx, %ebp # imm = 0xFFFFE271
addl %edi, %ebp
imull $0xc3f, %eax, %r15d     # imm = 0xC3F
addl %edi, %r15d
movl -0x6c(%rsp,%rcx), %eax
movl -0x7c(%rsp,%rcx), %r8d
movl -0x78(%rsp,%rcx), %r11d
leal (%rax,%r8), %ebx
subl %eax, %r8d
movl -0x60(%rsp,%rcx), %r9d
movl -0x68(%rsp,%rcx), %edi
movl -0x70(%rsp,%rcx), %r14d
leal (%r14,%r9), %eax
leal (%r11,%rdi), %r12d
leal (%r11,%r9), %edx
leal (%r14,%rdi), %r10d
leal (%r12,%rax), %r13d
imull $0x12d0, %r13d, %r13d   # imm = 0x12D0
imull $0xfffff19b, %edx, %edx # imm = 0xFFFFF19B
addl %r13d, %edx
imull $0xffffd6ff, %r10d, %esi # imm = 0xFFFFD6FF
addl %r13d, %esi
imull $0x20da, %edi, %r10d    # imm = 0x20DA
imull $0x1805, %r11d, %r13d   # imm = 0x1805
imull $0xfffff9c3, %r12d, %edi # imm = 0xFFFFF9C3
addl %edi, %r13d
addl %edi, %r10d
imull $0x312a, %r14d, %r12d   # imm = 0x312A
imull $0xffffe09e, %eax, %eax # imm = 0xFFFFE09E
addl %eax, %r12d
addl %esi, %r12d
addl %esi, %r10d
shll $0xc, %ebx
shll $0xc, %r8d
imull $0x4c7, %r9d, %r9d      # imm = 0x4C7
addl %eax, %r9d
movl %ebx, %r11d
subl %r15d, %r11d
addl %edx, %r13d
addl %edx, %r9d
movl %r8d, %r14d
subl %ebp, %r14d
movl $0x1010000, %esi        # imm = 0x1010000
addl %esi, %ebx
addl %r15d, %ebx
addl %esi, %r8d
addl %ebp, %r8d
leal (%rbx,%r13), %eax
sarl $0x11, %eax
setns %dl
negb %dl
movl $0x100, %ebp            # imm = 0x100
cmpl %ebp, %eax
movzbl %dl, %edx
cmovbl %eax, %edx
subl %r13d, %ebx
sarl $0x11, %ebx
setns %al
negb %al
cmpl %ebp, %ebx
movzbl %al, %eax
cmovbl %ebx, %eax
movq -0x70(%rsp), %rdi
movb %dl, -0x7(%rdi)
movb %al, (%rdi)
leal (%r12,%r8), %eax
sarl $0x11, %eax
setns %dl
negb %dl
cmpl %ebp, %eax
movzbl %dl, %edx
cmovbl %eax, %edx
movb %dl, -0x6(%rdi)
subl %r12d, %r8d
sarl $0x11, %r8d
setns %al
negb %al
cmpl %ebp, %r8d
movzbl %al, %eax
cmovbl %r8d, %eax
movb %al, -0x1(%rdi)
leal (%r14,%r10), %eax
addl $0x1010000, %eax        # imm = 0x1010000
sarl $0x11, %eax
setns %dl
negb %dl
cmpl %ebp, %eax
movzbl %dl, %edx
cmovbl %eax, %edx
movb %dl, -0x5(%rdi)
leal (%r14,%rsi), %eax
subl %r10d, %eax
sarl $0x11, %eax
setns %dl
negb %dl
cmpl %ebp, %eax
movzbl %dl, %edx
cmovbl %eax, %edx
movb %dl, -0x2(%rdi)
leal (%r11,%r9), %eax
addl $0x1010000, %eax        # imm = 0x1010000
sarl $0x11, %eax
setns %dl
negb %dl
cmpl %ebp, %eax
movzbl %dl, %edx
cmovbl %eax, %edx
leal (%r11,%rsi), %eax
subl %r9d, %eax
sarl $0x11, %eax
setns %sil
negb %sil
cmpl %ebp, %eax
movzbl %sil, %esi
cmovbl %eax, %esi
movb %dl, -0x4(%rdi)
movb %sil, -0x3(%rdi)
addq -0x78(%rsp), %rdi
movq %rdi, -0x70(%rsp)
addq $0x20, %rcx
jmp 0x40e500
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq