// File: /workspace/github_cpp_makefile_star2_O2/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), %rdi
movq 0x58(%rsi), %rsi
xorl %r9d, %r9d
movabsq $0x60, %r8
movabsq $0xfffffffd63, %rcx     # imm = 0xFFFFFFFD63
cmpl $0x8, %r9d
je 0x75063
movswl 0x10(%rdx,%r9,2), %ebx
movzwl 0x20(%rdx,%r9,2), %eax
movl %eax, %r11d
orw %bx, %r11w
jne 0x74ef3
cmpw $0x0, 0x30(%rdx,%r9,2)
jne 0x74ef1
cmpw $0x0, 0x40(%rdx,%r9,2)
jne 0x74ef1
cmpw $0x0, 0x50(%rdx,%r9,2)
jne 0x74ef1
cmpw $0x0, 0x60(%rdx,%r9,2)
jne 0x74ef1
cmpw $0x0, 0x70(%rdx,%r9,2)
je 0x7502f
xorl %eax, %eax
movswl (%rdx,%r9,2), %r14d
imull (%rsi,%r9,4), %r14d
cwtl
imull 0x40(%rsi,%r9,4), %eax
movswl 0x40(%rdx,%r9,2), %r15d
imull 0x80(%rsi,%r9,4), %r15d
movswl 0x60(%rdx,%r9,2), %r12d
imull 0xc0(%rsi,%r9,4), %r12d
leal (%r15,%r14), %r11d
subl %r15d, %r14d
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,%r9,4), %ebx
subl %r13d, %r11d
movswl 0x30(%rdx,%r9,2), %r13d
imull 0x60(%rsi,%r9,4), %r13d
leal (%rax,%r14), %r12d
movswl 0x50(%rdx,%r9,2), %ebp
imull 0xa0(%rsi,%r9,4), %ebp
subl %eax, %r14d
movswl 0x70(%rdx,%r9,2), %eax
imull 0xe0(%rsi,%r9,4), %eax
leal (%rbp,%r13), %r10d
subl %r13d, %ebp
leal (%rax,%rbx), %r13d
subl %eax, %ebx
leal (%r10,%r13), %eax
subl %r10d, %r13d
movslq %r13d, %r10
imulq $0x16a, %r10, %r13      # imm = 0x16A
shrq $0x8, %r13
leal (%rbx,%rbp), %r10d
movslq %r10d, %r10
imulq $0x1d9, %r10, %r10      # imm = 0x1D9
shrq $0x8, %r10
movslq %ebx, %rbx
imulq $0x115, %rbx, %rbx      # imm = 0x115
shrq $0x8, %rbx
subl %r10d, %ebx
movslq %ebp, %rbp
imulq %rcx, %rbp
shrq $0x8, %rbp
subl %eax, %ebp
addl %r10d, %ebp
subl %ebp, %r13d
addl %r13d, %ebx
leal (%rax,%r15), %r10d
movl %r10d, -0x70(%rsp,%r9,4)
subl %eax, %r15d
movl %r15d, 0x70(%rsp,%r9,4)
leal (%r12,%rbp), %eax
movl %eax, -0x50(%rsp,%r9,4)
subl %ebp, %r12d
movl %r12d, 0x50(%rsp,%r9,4)
leal (%r14,%r13), %eax
movl %eax, -0x30(%rsp,%r9,4)
subl %r13d, %r14d
movl %r14d, 0x30(%rsp,%r9,4)
leal (%rbx,%r11), %eax
movl %eax, 0x10(%rsp,%r9,4)
subl %ebx, %r11d
movq %r8, %rax
addq %rsp, %rax
addq $-0x70, %rax
movl %r11d, (%rax,%r9,4)
incq %r9
jmp 0x74ea1
movswl (%rdx,%r9,2), %r11d
imull (%rsi,%r9,4), %r11d
movl %r11d, -0x70(%rsp,%r9,4)
movl %r11d, -0x50(%rsp,%r9,4)
movl %r11d, -0x30(%rsp,%r9,4)
movl %r11d, -0x10(%rsp,%r9,4)
movl %r11d, 0x10(%rsp,%r9,4)
movl %r11d, 0x30(%rsp,%r9,4)
movl %r11d, 0x50(%rsp,%r9,4)
movl $0xe0, %eax
jmp 0x7501c
movl -0x7c(%rsp), %ecx
movabsq $0x7, %r10
movl $0x3ff, %r8d            # imm = 0x3FF
cmpq $0x47, %r10
je 0x75273
movq -0x78(%rsp), %rax
movq -0x7(%rax,%r10), %r11
addq %rcx, %r11
movl -0x88(%rsp,%r10,4), %r15d
movl -0x84(%rsp,%r10,4), %esi
movl %esi, %eax
orl %r15d, %eax
jne 0x750d3
xorl %esi, %esi
cmpl $0x0, -0x80(%rsp,%r10,4)
jne 0x750d3
cmpl $0x0, -0x7c(%rsp,%r10,4)
jne 0x750d3
cmpl $0x0, -0x78(%rsp,%r10,4)
jne 0x750d3
cmpl $0x0, -0x74(%rsp,%r10,4)
jne 0x750d3
cmpl $0x0, -0x70(%rsp,%r10,4)
je 0x75231
movl -0x7c(%rsp,%r10,4), %r9d
movl -0x8c(%rsp,%r10,4), %r14d
movl -0x80(%rsp,%r10,4), %eax
leal (%r9,%r14), %ebx
subl %r9d, %r14d
movl -0x74(%rsp,%r10,4), %r9d
leal (%r9,%rsi), %r12d
subl %r9d, %esi
imulq $0x16a, %rsi, %r9       # imm = 0x16A
shrq $0x8, %r9
subl %r12d, %r9d
leal (%r12,%rbx), %esi
subl %r12d, %ebx
leal (%r9,%r14), %r12d
subl %r9d, %r14d
movl -0x78(%rsp,%r10,4), %ebp
leal (%rax,%rbp), %r13d
subl %eax, %ebp
movl -0x70(%rsp,%r10,4), %eax
leal (%rax,%r15), %edx
subl %eax, %r15d
leal (%rdx,%r13), %r9d
subl %r13d, %edx
imulq $0x16a, %rdx, %r13      # imm = 0x16A
shrq $0x8, %r13
leal (%r15,%rbp), %eax
imulq $0x1d9, %rax, %rax      # imm = 0x1D9
shrq $0x8, %rax
imulq $0x115, %r15, %r15      # imm = 0x115
shrq $0x8, %r15
subl %eax, %r15d
movabsq $0xfffffffd63, %rdx     # imm = 0xFFFFFFFD63
imulq %rdx, %rbp
shrq $0x8, %rbp
subl %r9d, %ebp
addl %eax, %ebp
subl %ebp, %r13d
addl %r13d, %r15d
leal (%r9,%rsi), %eax
shrl $0x5, %eax
andl %r8d, %eax
movb 0x80(%rdi,%rax), %al
movb %al, (%r11)
subl %r9d, %esi
shrl $0x5, %esi
andl %r8d, %esi
movb 0x80(%rdi,%rsi), %al
movb %al, 0x7(%r11)
leal (%r12,%rbp), %eax
shrl $0x5, %eax
andl %r8d, %eax
movb 0x80(%rdi,%rax), %al
movb %al, 0x1(%r11)
subl %ebp, %r12d
shrl $0x5, %r12d
andl %r8d, %r12d
movb 0x80(%rdi,%r12), %al
movb %al, 0x6(%r11)
leal (%r14,%r13), %eax
shrl $0x5, %eax
andl %r8d, %eax
movb 0x80(%rdi,%rax), %al
movb %al, 0x2(%r11)
subl %r13d, %r14d
shrl $0x5, %r14d
andl %r8d, %r14d
movb 0x80(%rdi,%r14), %al
movb %al, 0x5(%r11)
leal (%r15,%rbx), %eax
shrl $0x5, %eax
andl %r8d, %eax
movb 0x80(%rdi,%rax), %al
movb %al, 0x4(%r11)
subl %r15d, %ebx
shrl $0x5, %ebx
andl %r8d, %ebx
movb 0x80(%rdi,%rbx), %al
movabsq $0x3, %rsi
movb %al, (%r11,%rsi)
addq $0x8, %r10
jmp 0x75077
movl -0x8c(%rsp,%r10,4), %eax
shrl $0x5, %eax
andl $0x3ff, %eax            # imm = 0x3FF
movzbl 0x80(%rdi,%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, (%r11)
movb %al, 0x4(%r11)
movb %al, 0x5(%r11)
movb %al, 0x6(%r11)
movabsq $0x7, %rsi
jmp 0x75224
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)