// File: 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
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x138(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x8, -0x1c(%rbp)
jge 0x2b983
movq -0x138(%rbp), %rax
movswl 0x10(%rax), %eax
cmpl $0x0, %eax
jne 0x2b5a7
movq -0x138(%rbp), %rax
movswl 0x20(%rax), %eax
cmpl $0x0, %eax
jne 0x2b5a7
movq -0x138(%rbp), %rax
movswl 0x30(%rax), %eax
cmpl $0x0, %eax
jne 0x2b5a7
movq -0x138(%rbp), %rax
movswl 0x40(%rax), %eax
cmpl $0x0, %eax
jne 0x2b5a7
movq -0x138(%rbp), %rax
movswl 0x50(%rax), %eax
cmpl $0x0, %eax
jne 0x2b5a7
movq -0x138(%rbp), %rax
movswl 0x60(%rax), %eax
cmpl $0x0, %eax
jne 0x2b5a7
movq -0x138(%rbp), %rax
movswl 0x70(%rax), %eax
cmpl $0x0, %eax
jne 0x2b5a7
movq -0x138(%rbp), %rax
movswl (%rax), %eax
shll $0x2, %eax
movl %eax, -0x13c(%rbp)
movl -0x13c(%rbp), %ecx
movl %ecx, -0x1a8(%rbp)
movq -0x128(%rbp), %rax
movl %ecx, 0xe0(%rax)
movq -0x128(%rbp), %rax
movl %ecx, 0xc0(%rax)
movq -0x128(%rbp), %rax
movl %ecx, 0xa0(%rax)
movq -0x128(%rbp), %rax
movl %ecx, 0x80(%rax)
movq -0x128(%rbp), %rax
movl %ecx, 0x60(%rax)
movq -0x128(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x128(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x128(%rbp), %rax
movl %ecx, (%rax)
jmp 0x2b94f
movq -0x138(%rbp), %rax
movswl 0x20(%rax), %eax
movl %eax, -0x154(%rbp)
movq -0x138(%rbp), %rax
movswl 0x60(%rax), %eax
movl %eax, -0x158(%rbp)
movl -0x154(%rbp), %eax
addl -0x158(%rbp), %eax
imull $0x8a9, %eax, %eax      # imm = 0x8A9
movl %eax, -0x150(%rbp)
movl -0x150(%rbp), %eax
imull $0xffffe271, -0x158(%rbp), %ecx # imm = 0xFFFFE271
addl %ecx, %eax
movl %eax, -0x148(%rbp)
movl -0x150(%rbp), %eax
imull $0xc3f, -0x154(%rbp), %ecx # imm = 0xC3F
addl %ecx, %eax
movl %eax, -0x14c(%rbp)
movq -0x138(%rbp), %rax
movswl (%rax), %eax
movl %eax, -0x154(%rbp)
movq -0x138(%rbp), %rax
movswl 0x40(%rax), %eax
movl %eax, -0x158(%rbp)
movl -0x154(%rbp), %eax
addl -0x158(%rbp), %eax
shll $0xc, %eax
movl %eax, -0x140(%rbp)
movl -0x154(%rbp), %eax
subl -0x158(%rbp), %eax
shll $0xc, %eax
movl %eax, -0x144(%rbp)
movl -0x140(%rbp), %eax
addl -0x14c(%rbp), %eax
movl %eax, -0x164(%rbp)
movl -0x140(%rbp), %eax
subl -0x14c(%rbp), %eax
movl %eax, -0x170(%rbp)
movl -0x144(%rbp), %eax
addl -0x148(%rbp), %eax
movl %eax, -0x168(%rbp)
movl -0x144(%rbp), %eax
subl -0x148(%rbp), %eax
movl %eax, -0x16c(%rbp)
movq -0x138(%rbp), %rax
movswl 0x70(%rax), %eax
movl %eax, -0x140(%rbp)
movq -0x138(%rbp), %rax
movswl 0x50(%rax), %eax
movl %eax, -0x144(%rbp)
movq -0x138(%rbp), %rax
movswl 0x30(%rax), %eax
movl %eax, -0x148(%rbp)
movq -0x138(%rbp), %rax
movswl 0x10(%rax), %eax
movl %eax, -0x14c(%rbp)
movl -0x140(%rbp), %eax
addl -0x148(%rbp), %eax
movl %eax, -0x158(%rbp)
movl -0x144(%rbp), %eax
addl -0x14c(%rbp), %eax
movl %eax, -0x15c(%rbp)
movl -0x140(%rbp), %eax
addl -0x14c(%rbp), %eax
movl %eax, -0x150(%rbp)
movl -0x144(%rbp), %eax
addl -0x148(%rbp), %eax
movl %eax, -0x154(%rbp)
movl -0x158(%rbp), %eax
addl -0x15c(%rbp), %eax
imull $0x12d0, %eax, %eax     # imm = 0x12D0
movl %eax, -0x160(%rbp)
imull $0x4c7, -0x140(%rbp), %eax # imm = 0x4C7
movl %eax, -0x140(%rbp)
imull $0x20da, -0x144(%rbp), %eax # imm = 0x20DA
movl %eax, -0x144(%rbp)
imull $0x312a, -0x148(%rbp), %eax # imm = 0x312A
movl %eax, -0x148(%rbp)
imull $0x1805, -0x14c(%rbp), %eax # imm = 0x1805
movl %eax, -0x14c(%rbp)
movl -0x160(%rbp), %eax
imull $0xfffff19b, -0x150(%rbp), %ecx # imm = 0xFFFFF19B
addl %ecx, %eax
movl %eax, -0x150(%rbp)
movl -0x160(%rbp), %eax
imull $0xffffd6ff, -0x154(%rbp), %ecx # imm = 0xFFFFD6FF
addl %ecx, %eax
movl %eax, -0x154(%rbp)
imull $0xffffe09e, -0x158(%rbp), %eax # imm = 0xFFFFE09E
movl %eax, -0x158(%rbp)
imull $0xfffff9c3, -0x15c(%rbp), %eax # imm = 0xFFFFF9C3
movl %eax, -0x15c(%rbp)
movl -0x150(%rbp), %eax
addl -0x15c(%rbp), %eax
addl -0x14c(%rbp), %eax
movl %eax, -0x14c(%rbp)
movl -0x154(%rbp), %eax
addl -0x158(%rbp), %eax
addl -0x148(%rbp), %eax
movl %eax, -0x148(%rbp)
movl -0x154(%rbp), %eax
addl -0x15c(%rbp), %eax
addl -0x144(%rbp), %eax
movl %eax, -0x144(%rbp)
movl -0x150(%rbp), %eax
addl -0x158(%rbp), %eax
addl -0x140(%rbp), %eax
movl %eax, -0x140(%rbp)
movl -0x164(%rbp), %eax
addl $0x200, %eax            # imm = 0x200
movl %eax, -0x164(%rbp)
movl -0x168(%rbp), %eax
addl $0x200, %eax            # imm = 0x200
movl %eax, -0x168(%rbp)
movl -0x16c(%rbp), %eax
addl $0x200, %eax            # imm = 0x200
movl %eax, -0x16c(%rbp)
movl -0x170(%rbp), %eax
addl $0x200, %eax            # imm = 0x200
movl %eax, -0x170(%rbp)
movl -0x164(%rbp), %ecx
addl -0x14c(%rbp), %ecx
sarl $0xa, %ecx
movq -0x128(%rbp), %rax
movl %ecx, (%rax)
movl -0x164(%rbp), %ecx
subl -0x14c(%rbp), %ecx
sarl $0xa, %ecx
movq -0x128(%rbp), %rax
movl %ecx, 0xe0(%rax)
movl -0x168(%rbp), %ecx
addl -0x148(%rbp), %ecx
sarl $0xa, %ecx
movq -0x128(%rbp), %rax
movl %ecx, 0x20(%rax)
movl -0x168(%rbp), %ecx
subl -0x148(%rbp), %ecx
sarl $0xa, %ecx
movq -0x128(%rbp), %rax
movl %ecx, 0xc0(%rax)
movl -0x16c(%rbp), %ecx
addl -0x144(%rbp), %ecx
sarl $0xa, %ecx
movq -0x128(%rbp), %rax
movl %ecx, 0x40(%rax)
movl -0x16c(%rbp), %ecx
subl -0x144(%rbp), %ecx
sarl $0xa, %ecx
movq -0x128(%rbp), %rax
movl %ecx, 0xa0(%rax)
movl -0x170(%rbp), %ecx
addl -0x140(%rbp), %ecx
sarl $0xa, %ecx
movq -0x128(%rbp), %rax
movl %ecx, 0x60(%rax)
movl -0x170(%rbp), %ecx
subl -0x140(%rbp), %ecx
sarl $0xa, %ecx
movq -0x128(%rbp), %rax
movl %ecx, 0x80(%rax)
jmp 0x2b951
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x138(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x138(%rbp)
movq -0x128(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x128(%rbp)
jmp 0x2b496
movl $0x0, -0x1c(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x130(%rbp)
cmpl $0x8, -0x1c(%rbp)
jge 0x2bdb0
movq -0x128(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x188(%rbp)
movq -0x128(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x18c(%rbp)
movl -0x188(%rbp), %eax
addl -0x18c(%rbp), %eax
imull $0x8a9, %eax, %eax      # imm = 0x8A9
movl %eax, -0x184(%rbp)
movl -0x184(%rbp), %eax
imull $0xffffe271, -0x18c(%rbp), %ecx # imm = 0xFFFFE271
addl %ecx, %eax
movl %eax, -0x17c(%rbp)
movl -0x184(%rbp), %eax
imull $0xc3f, -0x188(%rbp), %ecx # imm = 0xC3F
addl %ecx, %eax
movl %eax, -0x180(%rbp)
movq -0x128(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x188(%rbp)
movq -0x128(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x18c(%rbp)
movl -0x188(%rbp), %eax
addl -0x18c(%rbp), %eax
shll $0xc, %eax
movl %eax, -0x174(%rbp)
movl -0x188(%rbp), %eax
subl -0x18c(%rbp), %eax
shll $0xc, %eax
movl %eax, -0x178(%rbp)
movl -0x174(%rbp), %eax
addl -0x180(%rbp), %eax
movl %eax, -0x198(%rbp)
movl -0x174(%rbp), %eax
subl -0x180(%rbp), %eax
movl %eax, -0x1a4(%rbp)
movl -0x178(%rbp), %eax
addl -0x17c(%rbp), %eax
movl %eax, -0x19c(%rbp)
movl -0x178(%rbp), %eax
subl -0x17c(%rbp), %eax
movl %eax, -0x1a0(%rbp)
movq -0x128(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x174(%rbp)
movq -0x128(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x178(%rbp)
movq -0x128(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x17c(%rbp)
movq -0x128(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x180(%rbp)
movl -0x174(%rbp), %eax
addl -0x17c(%rbp), %eax
movl %eax, -0x18c(%rbp)
movl -0x178(%rbp), %eax
addl -0x180(%rbp), %eax
movl %eax, -0x190(%rbp)
movl -0x174(%rbp), %eax
addl -0x180(%rbp), %eax
movl %eax, -0x184(%rbp)
movl -0x178(%rbp), %eax
addl -0x17c(%rbp), %eax
movl %eax, -0x188(%rbp)
movl -0x18c(%rbp), %eax
addl -0x190(%rbp), %eax
imull $0x12d0, %eax, %eax     # imm = 0x12D0
movl %eax, -0x194(%rbp)
imull $0x4c7, -0x174(%rbp), %eax # imm = 0x4C7
movl %eax, -0x174(%rbp)
imull $0x20da, -0x178(%rbp), %eax # imm = 0x20DA
movl %eax, -0x178(%rbp)
imull $0x312a, -0x17c(%rbp), %eax # imm = 0x312A
movl %eax, -0x17c(%rbp)
imull $0x1805, -0x180(%rbp), %eax # imm = 0x1805
movl %eax, -0x180(%rbp)
movl -0x194(%rbp), %eax
imull $0xfffff19b, -0x184(%rbp), %ecx # imm = 0xFFFFF19B
addl %ecx, %eax
movl %eax, -0x184(%rbp)
movl -0x194(%rbp), %eax
imull $0xffffd6ff, -0x188(%rbp), %ecx # imm = 0xFFFFD6FF
addl %ecx, %eax
movl %eax, -0x188(%rbp)
imull $0xffffe09e, -0x18c(%rbp), %eax # imm = 0xFFFFE09E
movl %eax, -0x18c(%rbp)
imull $0xfffff9c3, -0x190(%rbp), %eax # imm = 0xFFFFF9C3
movl %eax, -0x190(%rbp)
movl -0x184(%rbp), %eax
addl -0x190(%rbp), %eax
addl -0x180(%rbp), %eax
movl %eax, -0x180(%rbp)
movl -0x188(%rbp), %eax
addl -0x18c(%rbp), %eax
addl -0x17c(%rbp), %eax
movl %eax, -0x17c(%rbp)
movl -0x188(%rbp), %eax
addl -0x190(%rbp), %eax
addl -0x178(%rbp), %eax
movl %eax, -0x178(%rbp)
movl -0x184(%rbp), %eax
addl -0x18c(%rbp), %eax
addl -0x174(%rbp), %eax
movl %eax, -0x174(%rbp)
movl -0x198(%rbp), %eax
addl $0x1010000, %eax        # imm = 0x1010000
movl %eax, -0x198(%rbp)
movl -0x19c(%rbp), %eax
addl $0x1010000, %eax        # imm = 0x1010000
movl %eax, -0x19c(%rbp)
movl -0x1a0(%rbp), %eax
addl $0x1010000, %eax        # imm = 0x1010000
movl %eax, -0x1a0(%rbp)
movl -0x1a4(%rbp), %eax
addl $0x1010000, %eax        # imm = 0x1010000
movl %eax, -0x1a4(%rbp)
movl -0x198(%rbp), %edi
addl -0x180(%rbp), %edi
sarl $0x11, %edi
callq 0x2c070
movb %al, %cl
movq -0x130(%rbp), %rax
movb %cl, (%rax)
movl -0x198(%rbp), %edi
subl -0x180(%rbp), %edi
sarl $0x11, %edi
callq 0x2c070
movb %al, %cl
movq -0x130(%rbp), %rax
movb %cl, 0x7(%rax)
movl -0x19c(%rbp), %edi
addl -0x17c(%rbp), %edi
sarl $0x11, %edi
callq 0x2c070
movb %al, %cl
movq -0x130(%rbp), %rax
movb %cl, 0x1(%rax)
movl -0x19c(%rbp), %edi
subl -0x17c(%rbp), %edi
sarl $0x11, %edi
callq 0x2c070
movb %al, %cl
movq -0x130(%rbp), %rax
movb %cl, 0x6(%rax)
movl -0x1a0(%rbp), %edi
addl -0x178(%rbp), %edi
sarl $0x11, %edi
callq 0x2c070
movb %al, %cl
movq -0x130(%rbp), %rax
movb %cl, 0x2(%rax)
movl -0x1a0(%rbp), %edi
subl -0x178(%rbp), %edi
sarl $0x11, %edi
callq 0x2c070
movb %al, %cl
movq -0x130(%rbp), %rax
movb %cl, 0x5(%rax)
movl -0x1a4(%rbp), %edi
addl -0x174(%rbp), %edi
sarl $0x11, %edi
callq 0x2c070
movb %al, %cl
movq -0x130(%rbp), %rax
movb %cl, 0x3(%rax)
movl -0x1a4(%rbp), %edi
subl -0x174(%rbp), %edi
sarl $0x11, %edi
callq 0x2c070
movb %al, %cl
movq -0x130(%rbp), %rax
movb %cl, 0x4(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x128(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x128(%rbp)
movl -0xc(%rbp), %ecx
movq -0x130(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x130(%rbp)
jmp 0x2b9a3
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
nopl (%rax)