// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/jpeg/jidctfst.c
// Function: jpeg_idct_ifast
GLOBAL(void)
jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
		 JCOEFPTR coef_block,
		 JSAMPARRAY output_buf, JDIMENSION output_col)
{
  DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
  DCTELEM tmp10, tmp11, tmp12, tmp13;
  DCTELEM z5, z10, z11, z12, z13;
  JCOEFPTR inptr;
  IFAST_MULT_TYPE * quantptr;
  int * wsptr;
  JSAMPROW outptr;
  JSAMPLE *range_limit = IDCT_range_limit(cinfo);
  int ctr;
  int workspace[DCTSIZE2];	/* buffers data between passes */
  SHIFT_TEMPS			/* for DESCALE */
  ISHIFT_TEMPS			/* for IDESCALE */

  /* Pass 1: process columns from input, store into work array. */

  inptr = coef_block;
  quantptr = (IFAST_MULT_TYPE *) compptr->dct_table;
  wsptr = workspace;
  for (ctr = DCTSIZE; ctr > 0; ctr--) {
    /* Due to quantization, we will usually find that many of the input
     * coefficients are zero, especially the AC terms.  We can exploit this
     * by short-circuiting the IDCT calculation for any column in which all
     * the AC terms are zero.  In that case each output is equal to the
     * DC coefficient (with scale factor as needed).
     * With typical images and quantization tables, half or more of the
     * column DCT calculations can be simplified this way.
     */
    
    if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
	inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&
	inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
	inptr[DCTSIZE*7] == 0) {
      /* AC terms all zero */
      int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);

      wsptr[DCTSIZE*0] = dcval;
      wsptr[DCTSIZE*1] = dcval;
      wsptr[DCTSIZE*2] = dcval;
      wsptr[DCTSIZE*3] = dcval;
      wsptr[DCTSIZE*4] = dcval;
      wsptr[DCTSIZE*5] = dcval;
      wsptr[DCTSIZE*6] = dcval;
      wsptr[DCTSIZE*7] = dcval;
      
      inptr++;			/* advance pointers to next column */
      quantptr++;
      wsptr++;
      continue;
    }
    
    /* Even part */

    tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
    tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
    tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
    tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);

    tmp10 = tmp0 + tmp2;	/* phase 3 */
    tmp11 = tmp0 - tmp2;

    tmp13 = tmp1 + tmp3;	/* phases 5-3 */
    tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */

    tmp0 = tmp10 + tmp13;	/* phase 2 */
    tmp3 = tmp10 - tmp13;
    tmp1 = tmp11 + tmp12;
    tmp2 = tmp11 - tmp12;
    
    /* Odd part */

    tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
    tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
    tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
    tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);

    z13 = tmp6 + tmp5;		/* phase 6 */
    z10 = tmp6 - tmp5;
    z11 = tmp4 + tmp7;
    z12 = tmp4 - tmp7;

    tmp7 = z11 + z13;		/* phase 5 */
    tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */

    z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
    tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */
    tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */

    tmp6 = tmp12 - tmp7;	/* phase 2 */
    tmp5 = tmp11 - tmp6;
    tmp4 = tmp10 + tmp5;

    wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7);
    wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7);
    wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6);
    wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6);
    wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5);
    wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5);
    wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4);
    wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4);

    inptr++;			/* advance pointers to next column */
    quantptr++;
    wsptr++;
  }
  
  /* Pass 2: process rows from work array, store into output array. */
  /* Note that we must descale the results by a factor of 8 == 2**3, */
  /* and also undo the PASS1_BITS scaling. */

  wsptr = workspace;
  for (ctr = 0; ctr < DCTSIZE; ctr++) {
    outptr = output_buf[ctr] + output_col;
    /* Rows of zeroes can be exploited in the same way as we did with columns.
     * However, the column calculation has created many nonzero AC terms, so
     * the simplification applies less often (typically 5% to 10% of the time).
     * On machines with very fast multiplication, it's possible that the
     * test takes more time than it's worth.  In that case this section
     * may be commented out.
     */
    
#ifndef NO_ZERO_ROW_TEST
    if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 &&
	wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
      /* AC terms all zero */
      JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3)
				  & RANGE_MASK];
      
      outptr[0] = dcval;
      outptr[1] = dcval;
      outptr[2] = dcval;
      outptr[3] = dcval;
      outptr[4] = dcval;
      outptr[5] = dcval;
      outptr[6] = dcval;
      outptr[7] = dcval;

      wsptr += DCTSIZE;		/* advance pointer to next row */
      continue;
    }
#endif
    
    /* Even part */

    tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]);
    tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]);

    tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]);
    tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562)
	    - tmp13;

    tmp0 = tmp10 + tmp13;
    tmp3 = tmp10 - tmp13;
    tmp1 = tmp11 + tmp12;
    tmp2 = tmp11 - tmp12;

    /* Odd part */

    z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3];
    z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3];
    z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7];
    z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7];

    tmp7 = z11 + z13;		/* phase 5 */
    tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */

    z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
    tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */
    tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */

    tmp6 = tmp12 - tmp7;	/* phase 2 */
    tmp5 = tmp11 - tmp6;
    tmp4 = tmp10 + tmp5;

    /* Final output stage: scale down by a factor of 8 and range-limit */

    outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3)
			    & RANGE_MASK];
    outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3)
			    & RANGE_MASK];
    outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3)
			    & RANGE_MASK];
    outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3)
			    & RANGE_MASK];
    outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3)
			    & RANGE_MASK];
    outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3)
			    & RANGE_MASK];
    outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3)
			    & RANGE_MASK];
    outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3)
			    & RANGE_MASK];

    wsptr += DCTSIZE;		/* advance pointer to next row */
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %r8d, -0x7c(%rsp)
movq %rcx, -0x78(%rsp)
movq 0x1a8(%rdi), %r8
movq 0x58(%rsi), %rsi
movl $0x9, %r9d
xorl %r10d, %r10d
movabsq $0xfffffffd63, %rcx     # imm = 0xFFFFFFFD63
movswl 0x10(%rdx,%r10), %r14d
testl %r14d, %r14d
jne 0x822e2
cmpw $0x0, 0x20(%rdx,%r10)
jne 0x822e2
cmpw $0x0, 0x30(%rdx,%r10)
jne 0x822e2
cmpw $0x0, 0x40(%rdx,%r10)
jne 0x822e2
cmpw $0x0, 0x50(%rdx,%r10)
jne 0x822e2
cmpw $0x0, 0x60(%rdx,%r10)
jne 0x822e2
cmpw $0x0, 0x70(%rdx,%r10)
je 0x8242f
movswl (%rdx,%r10), %ebx
imull (%rsi,%r10,2), %ebx
movswl 0x20(%rdx,%r10), %eax
imull 0x40(%rsi,%r10,2), %eax
movswl 0x40(%rdx,%r10), %r15d
imull 0x80(%rsi,%r10,2), %r15d
movswl 0x60(%rdx,%r10), %r12d
imull 0xc0(%rsi,%r10,2), %r12d
leal (%r15,%rbx), %r11d
subl %r15d, %ebx
leal (%r12,%rax), %r13d
subl %r12d, %eax
cltq
imulq $0x16a, %rax, %rax      # imm = 0x16A
shrq $0x8, %rax
subl %r13d, %eax
leal (%r11,%r13), %r15d
imull 0x20(%rsi,%r10,2), %r14d
subl %r13d, %r11d
movswl 0x30(%rdx,%r10), %r13d
imull 0x60(%rsi,%r10,2), %r13d
leal (%rax,%rbx), %r12d
movswl 0x50(%rdx,%r10), %ebp
imull 0xa0(%rsi,%r10,2), %ebp
subl %eax, %ebx
movswl 0x70(%rdx,%r10), %eax
imull 0xe0(%rsi,%r10,2), %eax
leal (%rbp,%r13), %edi
subl %r13d, %ebp
leal (%rax,%r14), %r13d
subl %eax, %r14d
leal (%rdi,%r13), %eax
subl %edi, %r13d
movslq %r13d, %rdi
imulq $0x16a, %rdi, %r13      # imm = 0x16A
shrq $0x8, %r13
leal (%r14,%rbp), %edi
movslq %edi, %rdi
imulq $0x1d9, %rdi, %rdi      # imm = 0x1D9
shrq $0x8, %rdi
movslq %r14d, %r14
imulq $0x115, %r14, %r14      # imm = 0x115
shrq $0x8, %r14
subl %edi, %r14d
movslq %ebp, %rbp
imulq %rcx, %rbp
shrq $0x8, %rbp
subl %eax, %ebp
addl %edi, %ebp
subl %ebp, %r13d
addl %r13d, %r14d
leal (%rax,%r15), %edi
movl %edi, -0x70(%rsp,%r10,2)
subl %eax, %r15d
movl %r15d, 0x70(%rsp,%r10,2)
leal (%r12,%rbp), %eax
movl %eax, -0x50(%rsp,%r10,2)
subl %ebp, %r12d
movl %r12d, 0x50(%rsp,%r10,2)
leal (%rbx,%r13), %eax
movl %eax, -0x30(%rsp,%r10,2)
subl %r13d, %ebx
movl %ebx, 0x30(%rsp,%r10,2)
leal (%r14,%r11), %eax
movl %eax, 0x10(%rsp,%r10,2)
subl %r14d, %r11d
movl $0x60, %eax
addq %rsp, %rax
addq $-0x70, %rax
movl %r11d, (%rax,%r10,2)
decl %r9d
addq $0x2, %r10
cmpl $0x1, %r9d
ja 0x8229d
jmp 0x82463
movswl (%rdx,%r10), %r11d
imull (%rsi,%r10,2), %r11d
movl %r11d, -0x70(%rsp,%r10,2)
movl %r11d, -0x50(%rsp,%r10,2)
movl %r11d, -0x30(%rsp,%r10,2)
movl %r11d, -0x10(%rsp,%r10,2)
movl %r11d, 0x10(%rsp,%r10,2)
movl %r11d, 0x30(%rsp,%r10,2)
movl %r11d, 0x50(%rsp,%r10,2)
movl $0xe0, %eax
jmp 0x82411
movl -0x7c(%rsp), %edx
movl $0x7, %esi
movl $0x3ff, %ecx            # imm = 0x3FF
movq -0x78(%rsp), %rax
movq -0x7(%rax,%rsi), %r9
addq %rdx, %r9
movl -0x88(%rsp,%rsi,4), %ebx
testl %ebx, %ebx
jne 0x824ba
cmpl $0x0, -0x84(%rsp,%rsi,4)
jne 0x824ba
cmpl $0x0, -0x80(%rsp,%rsi,4)
jne 0x824ba
cmpl $0x0, -0x7c(%rsp,%rsi,4)
jne 0x824ba
cmpl $0x0, -0x78(%rsp,%rsi,4)
jne 0x824ba
cmpl $0x0, -0x74(%rsp,%rsi,4)
jne 0x824ba
cmpl $0x0, -0x70(%rsp,%rsi,4)
je 0x82622
movl -0x7c(%rsp,%rsi,4), %eax
movl -0x8c(%rsp,%rsi,4), %r11d
movl -0x84(%rsp,%rsi,4), %edi
leal (%rax,%r11), %r10d
subl %eax, %r11d
movl -0x74(%rsp,%rsi,4), %eax
leal (%rax,%rdi), %r14d
subl %eax, %edi
imulq $0x16a, %rdi, %rax      # imm = 0x16A
shrq $0x8, %rax
subl %r14d, %eax
leal (%r14,%r10), %r13d
subl %r14d, %r10d
leal (%rax,%r11), %r14d
subl %eax, %r11d
movl -0x78(%rsp,%rsi,4), %r15d
movl -0x80(%rsp,%rsi,4), %eax
leal (%rax,%r15), %edi
subl %eax, %r15d
movl -0x70(%rsp,%rsi,4), %eax
leal (%rax,%rbx), %r12d
subl %eax, %ebx
leal (%r12,%rdi), %ebp
subl %edi, %r12d
imulq $0x16a, %r12, %r12      # imm = 0x16A
shrq $0x8, %r12
leal (%rbx,%r15), %eax
imulq $0x1d9, %rax, %rax      # imm = 0x1D9
shrq $0x8, %rax
imulq $0x115, %rbx, %rbx      # imm = 0x115
shrq $0x8, %rbx
subl %eax, %ebx
movabsq $0xfffffffd63, %rdi     # imm = 0xFFFFFFFD63
imulq %rdi, %r15
shrq $0x8, %r15
subl %ebp, %r15d
addl %eax, %r15d
subl %r15d, %r12d
addl %r12d, %ebx
leal (%rbp,%r13), %eax
shrl $0x5, %eax
andl %ecx, %eax
movb 0x80(%r8,%rax), %al
movb %al, (%r9)
subl %ebp, %r13d
shrl $0x5, %r13d
andl %ecx, %r13d
movb 0x80(%r8,%r13), %al
movb %al, 0x7(%r9)
leal (%r15,%r14), %eax
shrl $0x5, %eax
andl %ecx, %eax
movb 0x80(%r8,%rax), %al
movb %al, 0x1(%r9)
subl %r15d, %r14d
shrl $0x5, %r14d
andl %ecx, %r14d
movb 0x80(%r8,%r14), %al
movb %al, 0x6(%r9)
leal (%r12,%r11), %eax
shrl $0x5, %eax
andl %ecx, %eax
movb 0x80(%r8,%rax), %al
movb %al, 0x2(%r9)
subl %r12d, %r11d
shrl $0x5, %r11d
andl %ecx, %r11d
movb 0x80(%r8,%r11), %al
movb %al, 0x5(%r9)
leal (%rbx,%r10), %eax
shrl $0x5, %eax
andl %ecx, %eax
movb 0x80(%r8,%rax), %al
movb %al, 0x4(%r9)
subl %ebx, %r10d
shrl $0x5, %r10d
andl %ecx, %r10d
movb 0x80(%r8,%r10), %al
movl $0x3, %r10d
movb %al, (%r9,%r10)
addq $0x8, %rsi
cmpq $0x47, %rsi
jne 0x82471
jmp 0x82660
movl -0x8c(%rsp,%rsi,4), %eax
shrl $0x5, %eax
andl $0x3ff, %eax            # imm = 0x3FF
movzbl 0x80(%r8,%rax), %eax
movd %eax, %xmm0
punpcklbw %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
pshuflw $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0,4,5,6,7]
movd %xmm0, (%r9)
movb %al, 0x4(%r9)
movb %al, 0x5(%r9)
movb %al, 0x6(%r9)
movl $0x7, %r10d
jmp 0x8260e
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop