// File: /workspace/github_cpp_makefile_star2_O1/srajangarg[P]raytracer/src/core/stb_image.hpp
// Function: stbi__idct_block(unsigned char*, int, short*)
static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64])
{
   int i,val[64],*v=val;
   stbi_uc *o;
   short *d = data;

   // columns
   for (i=0; i < 8; ++i,++d, ++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] << 2;
         v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm;
      } else {
         STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[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 $0xb8, %rsp
movl %esi, -0x78(%rsp)
movq %rdi, %r11
movl $0x38, %eax
movq %rdi, -0x70(%rsp)
movswl -0x60(%rdx,%rax,2), %edi
testl %edi, %edi
jne 0x1cc5c
cmpw $0x0, -0x50(%rdx,%rax,2)
jne 0x1cc5c
cmpw $0x0, -0x40(%rdx,%rax,2)
jne 0x1cc5c
cmpw $0x0, -0x30(%rdx,%rax,2)
jne 0x1cc5c
cmpw $0x0, -0x20(%rdx,%rax,2)
jne 0x1cc5c
cmpw $0x0, -0x10(%rdx,%rax,2)
jne 0x1cc5c
cmpw $0x0, (%rdx,%rax,2)
je 0x1cdcf
movswl -0x50(%rdx,%rax,2), %ecx
movswl -0x10(%rdx,%rax,2), %r8d
leal (%r8,%rcx), %r9d
imull $0x8a9, %r9d, %r9d      # imm = 0x8A9
imull $0xffffe271, %r8d, %esi # imm = 0xFFFFE271
addl %r9d, %esi
movl %esi, -0x7c(%rsp)
imull $0xc3f, %ecx, %ebp      # imm = 0xC3F
addl %r9d, %ebp
movswl -0x70(%rdx,%rax,2), %r8d
movswl -0x30(%rdx,%rax,2), %ecx
leal (%rcx,%r8), %r10d
subl %ecx, %r8d
movswl (%rdx,%rax,2), %ecx
movswl -0x20(%rdx,%rax,2), %r14d
movswl -0x40(%rdx,%rax,2), %r12d
leal (%r12,%rcx), %r13d
leal (%r14,%rdi), %esi
leal (%r12,%r14), %r15d
leal (%rsi,%r13), %r9d
imull $0x12d0, %r9d, %ebx     # imm = 0x12D0
imull $0x4c7, %ecx, %r9d      # imm = 0x4C7
addl %edi, %ecx
imull $0xfffff19b, %ecx, %ecx # imm = 0xFFFFF19B
addl %ebx, %ecx
imull $0xffffd6ff, %r15d, %r11d # imm = 0xFFFFD6FF
addl %ebx, %r11d
imull $0x20da, %r14d, %r14d   # imm = 0x20DA
imull $0x1805, %edi, %r15d    # imm = 0x1805
imull $0xfffff9c3, %esi, %esi # imm = 0xFFFFF9C3
addl %esi, %r15d
addl %esi, %r14d
imull $0x312a, %r12d, %r12d   # imm = 0x312A
imull $0xffffe09e, %r13d, %esi # imm = 0xFFFFE09E
addl %esi, %r12d
addl %r11d, %r12d
addl %r11d, %r14d
movq -0x70(%rsp), %r11
addl %esi, %r9d
shll $0xc, %r10d
shll $0xc, %r8d
addl %ecx, %r15d
addl %ecx, %r9d
movl %r10d, %ebx
subl %ebp, %ebx
movl $0x200, %esi            # imm = 0x200
addl %esi, %r10d
addl %ebp, %r10d
movl %r8d, %r13d
movl -0x7c(%rsp), %ecx
subl %ecx, %r13d
addl %esi, %r8d
addl %ecx, %r8d
leal (%r15,%r10), %ecx
sarl $0xa, %ecx
movl %ecx, -0x130(%rsp,%rax,4)
subl %r15d, %r10d
sarl $0xa, %r10d
movl %r10d, -0x50(%rsp,%rax,4)
leal (%r12,%r8), %ecx
sarl $0xa, %ecx
movl %ecx, -0x110(%rsp,%rax,4)
subl %r12d, %r8d
sarl $0xa, %r8d
movl %r8d, -0x70(%rsp,%rax,4)
leal (%r14,%r13), %ecx
addl $0x200, %ecx            # imm = 0x200
sarl $0xa, %ecx
movl %ecx, -0xf0(%rsp,%rax,4)
leal (%rsi,%r13), %ecx
subl %r14d, %ecx
sarl $0xa, %ecx
movl %ecx, -0x90(%rsp,%rax,4)
leal (%rbx,%r9), %ecx
addl $0x200, %ecx            # imm = 0x200
sarl $0xa, %ecx
movl %ecx, -0xd0(%rsp,%rax,4)
leal (%rbx,%rsi), %ecx
subl %r9d, %ecx
sarl $0xa, %ecx
movl %ecx, -0xb0(%rsp,%rax,4)
incq %rax
cmpl $0x40, %eax
jne 0x1cc20
jmp 0x1ce0b
movswl -0x70(%rdx,%rax,2), %ecx
shll $0x2, %ecx
movl %ecx, -0x50(%rsp,%rax,4)
movl %ecx, -0x70(%rsp,%rax,4)
movl %ecx, -0x90(%rsp,%rax,4)
movl %ecx, -0xb0(%rsp,%rax,4)
movl %ecx, -0xd0(%rsp,%rax,4)
movl %ecx, -0xf0(%rsp,%rax,4)
movl %ecx, -0x110(%rsp,%rax,4)
movl %ecx, -0x130(%rsp,%rax,4)
jmp 0x1cdc1
movslq -0x78(%rsp), %rax
movq %rax, -0x60(%rsp)
addq $0x7, %r11
movl $0x1c, %ecx
movq %r11, -0x70(%rsp)
movl -0x64(%rsp,%rcx), %eax
movl -0x54(%rsp,%rcx), %edx
movq %rdx, -0x58(%rsp)
addl %eax, %edx
imull $0x8a9, %edx, %ebp      # imm = 0x8A9
imull $0xc3f, %eax, %r15d     # imm = 0xC3F
addl %ebp, %r15d
movl -0x5c(%rsp,%rcx), %r13d
movl -0x6c(%rsp,%rcx), %r10d
movl $0x1010000, %r11d       # imm = 0x1010000
movl -0x68(%rsp,%rcx), %edi
leal (%r10,%r13), %esi
shll $0xc, %esi
movl -0x50(%rsp,%rcx), %ebx
movl -0x58(%rsp,%rcx), %r8d
movl -0x60(%rsp,%rcx), %eax
leal (%rax,%rbx), %edx
movq %r8, %r14
leal (%rdi,%r8), %r9d
leal (%r9,%rdx), %r8d
imull $0x12d0, %r8d, %r12d    # imm = 0x12D0
imull $0x1805, %edi, %r8d     # imm = 0x1805
movq %rbx, -0x78(%rsp)
addl %ebx, %edi
imull $0xfffff19b, %edi, %edi # imm = 0xFFFFF19B
addl %r12d, %edi
imull $0xfffff9c3, %r9d, %ebx # imm = 0xFFFFF9C3
addl %ebx, %r8d
movl %edi, -0x64(%rsp)
addl %edi, %r8d
leal (%rsi,%r11), %r9d
movl %r15d, -0x7c(%rsp)
addl %r15d, %r9d
leal (%r8,%r9), %r11d
sarl $0x11, %r11d
cmpl $0x100, %r11d           # imm = 0x100
jb 0x1ced5
testl %r11d, %r11d
js 0x1ceda
movb $-0x1, %r15b
cmpl $0xff, %r11d
jg 0x1cedd
movl %r11d, %r15d
jmp 0x1cedd
xorl %r15d, %r15d
movq -0x70(%rsp), %r11
movb %r15b, -0x7(%r11)
subl %r8d, %r9d
sarl $0x11, %r9d
cmpl $0x100, %r9d            # imm = 0x100
movl $0x1010000, %edi        # imm = 0x1010000
movq %r14, %r15
jb 0x1cf0f
testl %r9d, %r9d
js 0x1cf14
movb $-0x1, %r8b
cmpl $0xff, %r9d
jg 0x1cf17
movl %r9d, %r8d
jmp 0x1cf17
xorl %r8d, %r8d
imull $0xffffe271, -0x58(%rsp), %r9d # imm = 0xFFFFE271
addl %r9d, %ebp
subl %r13d, %r10d
shll $0xc, %r10d
imull $0x312a, %eax, %r9d     # imm = 0x312A
addl %r15d, %eax
imull $0xffffd6ff, %eax, %eax # imm = 0xFFFFD6FF
addl %eax, %r12d
imull $0xffffe09e, %edx, %r14d # imm = 0xFFFFE09E
addl %r14d, %r9d
addl %r12d, %r9d
leal (%r10,%rdi), %eax
addl %ebp, %eax
movb %r8b, (%r11)
leal (%r9,%rax), %edx
sarl $0x11, %edx
cmpl $0x100, %edx            # imm = 0x100
jb 0x1cf71
testl %edx, %edx
js 0x1cf76
movb $-0x1, %r8b
cmpl $0xff, %edx
jg 0x1cf79
movl %edx, %r8d
jmp 0x1cf79
xorl %r8d, %r8d
movb %r8b, -0x6(%r11)
subl %r9d, %eax
sarl $0x11, %eax
cmpl $0x100, %eax            # imm = 0x100
jb 0x1cf97
testl %eax, %eax
js 0x1cf9b
movb $-0x1, %dl
cmpl $0xff, %eax
jg 0x1cf9d
movl %eax, %edx
jmp 0x1cf9d
xorl %edx, %edx
subl %ebp, %r10d
imull $0x20da, %r15d, %eax    # imm = 0x20DA
addl %eax, %ebx
addl %r12d, %ebx
addl %edi, %r10d
movb %dl, -0x1(%r11)
leal (%rbx,%r10), %eax
sarl $0x11, %eax
cmpl $0x100, %eax            # imm = 0x100
jb 0x1cfce
testl %eax, %eax
js 0x1cfd2
movb $-0x1, %dl
cmpl $0xff, %eax
jg 0x1cfd4
movl %eax, %edx
jmp 0x1cfd4
xorl %edx, %edx
movb %dl, -0x5(%r11)
subl %ebx, %r10d
sarl $0x11, %r10d
cmpl $0x100, %r10d           # imm = 0x100
jb 0x1cff8
testl %r10d, %r10d
js 0x1cffd
movb $-0x1, %al
cmpl $0xff, %r10d
jg 0x1cfff
movl %r10d, %eax
jmp 0x1cfff
xorl %eax, %eax
subl -0x7c(%rsp), %esi
imull $0x4c7, -0x78(%rsp), %edx # imm = 0x4C7
addl %edx, %r14d
addl -0x64(%rsp), %r14d
addl %edi, %esi
movb %al, -0x2(%r11)
leal (%r14,%rsi), %eax
sarl $0x11, %eax
cmpl $0x100, %eax            # imm = 0x100
jb 0x1d034
testl %eax, %eax
js 0x1d038
movb $-0x1, %dl
cmpl $0xff, %eax
jg 0x1d03a
movl %eax, %edx
jmp 0x1d03a
xorl %edx, %edx
movb %dl, -0x4(%r11)
subl %r14d, %esi
sarl $0x11, %esi
cmpl $0x100, %esi            # imm = 0x100
jb 0x1d05a
testl %esi, %esi
js 0x1d05e
movb $-0x1, %al
cmpl $0xff, %esi
jg 0x1d060
movl %esi, %eax
jmp 0x1d060
xorl %eax, %eax
movb %al, -0x3(%r11)
addq $0x20, %rcx
addq -0x60(%rsp), %r11
cmpl $0x11c, %ecx            # imm = 0x11C
jne 0x1ce1e
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq