// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/jpeg/jidctred.c
// Function: jpeg_idct_2x2
GLOBAL(void)
jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
	       JCOEFPTR coef_block,
	       JSAMPARRAY output_buf, JDIMENSION output_col)
{
  INT32 tmp0, tmp10, z1;
  JCOEFPTR inptr;
  ISLOW_MULT_TYPE * quantptr;
  int * wsptr;
  JSAMPROW outptr;
  JSAMPLE *range_limit = IDCT_range_limit(cinfo);
  int ctr;
  int workspace[DCTSIZE*2];	/* buffers data between passes */
  SHIFT_TEMPS

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

  inptr = coef_block;
  quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
  wsptr = workspace;
  for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
    /* Don't bother to process columns 2,4,6 */
    if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6)
      continue;
    if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 &&
	inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) {
      /* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */
      int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS;
      
      wsptr[DCTSIZE*0] = dcval;
      wsptr[DCTSIZE*1] = dcval;
      
      continue;
    }
    
    /* Even part */
    
    z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
    tmp10 = z1 << (CONST_BITS+2);
    
    /* Odd part */

    z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
    tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */
    z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
    tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */
    z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
    tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */
    z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
    tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */

    /* Final output stage */
    
    wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2);
    wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2);
  }
  
  /* Pass 2: process 2 rows from work array, store into output array. */

  wsptr = workspace;
  for (ctr = 0; ctr < 2; ctr++) {
    outptr = output_buf[ctr] + output_col;
    /* It's not clear whether a zero row test is worthwhile here ... */

#ifndef NO_ZERO_ROW_TEST
    if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) {
      /* AC terms all zero */
      JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3)
				  & RANGE_MASK];
      
      outptr[0] = dcval;
      outptr[1] = dcval;
      
      wsptr += DCTSIZE;		/* advance pointer to next row */
      continue;
    }
#endif
    
    /* Even part */
    
    tmp10 = ((INT32) wsptr[0]) << (CONST_BITS+2);
    
    /* Odd part */

    tmp0 = MULTIPLY((INT32) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3-c1) */
	 + MULTIPLY((INT32) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c7) */
	 + MULTIPLY((INT32) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5-c7) */
	 + MULTIPLY((INT32) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */

    /* Final output stage */
    
    outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0,
					  CONST_BITS+PASS1_BITS+3+2)
			    & RANGE_MASK];
    outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0,
					  CONST_BITS+PASS1_BITS+3+2)
			    & RANGE_MASK];
    
    wsptr += DCTSIZE;		/* advance pointer to next row */
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq 0x1a8(%rdi), %rax
movq 0x58(%rsi), %rsi
movl $0x8, %edi
xorl %r9d, %r9d
cmpl $0x10, %r9d
je 0x760b0
cmpl $0xc, %r9d
je 0x76090
movl %edi, %r10d
andl $0x7ffffffd, %r10d      # imm = 0x7FFFFFFD
cmpl $0x4, %r10d
je 0x76090
movswq 0x10(%rdx,%r9), %r10
movzwl 0x30(%rdx,%r9), %ebx
movl %ebx, %r11d
orw %r10w, %r11w
jne 0x75ff9
cmpw $0x0, 0x50(%rdx,%r9)
jne 0x75ff7
cmpw $0x0, 0x70(%rdx,%r9)
je 0x7609b
xorl %ebx, %ebx
movswq (%rdx,%r9), %r14
movslq (%rsi,%r9,2), %r11
imulq %r14, %r11
shlq $0xf, %r11
movswq 0x70(%rdx,%r9), %r14
movslq 0xe0(%rsi,%r9,2), %r15
imulq %r14, %r15
imulq $-0x1712, %r15, %r14    # imm = 0xE8EE
movswq 0x50(%rdx,%r9), %r15
movslq 0xa0(%rsi,%r9,2), %r12
imulq %r15, %r12
imulq $0x1b37, %r12, %r15     # imm = 0x1B37
addq %r14, %r15
movslq 0x60(%rsi,%r9,2), %r14
movswq %bx, %rbx
imulq %r14, %rbx
imulq $-0x28ba, %rbx, %rbx    # imm = 0xD746
addq %r15, %rbx
movslq 0x20(%rsi,%r9,2), %r14
imulq %r10, %r14
imulq $0x73fc, %r14, %r10     # imm = 0x73FC
addq %rbx, %r10
leaq (%r11,%r10), %rbx
addq $0x1000, %rbx           # imm = 0x1000
orq $0x1000, %r11           # imm = 0x1000
shrq $0xd, %rbx
movl %ebx, -0x40(%rsp,%r9,2)
subq %r10, %r11
shrq $0xd, %r11
movl %r11d, -0x20(%rsp,%r9,2)
decl %edi
addq $0x2, %r9
jmp 0x75fa4
movswl (%rdx,%r9), %r11d
imull (%rsi,%r9,2), %r11d
shll $0x2, %r11d
movl %r11d, -0x40(%rsp,%r9,2)
jmp 0x7608b
movl %r8d, %edx
xorl %esi, %esi
movl $0x3ff, %edi            # imm = 0x3FF
cmpq $0x10, %rsi
je 0x76182
movq (%rcx,%rsi), %r8
movl -0x3c(%rsp,%rsi,4), %r9d
movl -0x34(%rsp,%rsi,4), %r10d
movl %r10d, %r11d
orl %r9d, %r11d
jne 0x760eb
xorl %r10d, %r10d
cmpl $0x0, -0x2c(%rsp,%rsi,4)
jne 0x760eb
cmpl $0x0, -0x24(%rsp,%rsi,4)
je 0x76160
movl -0x40(%rsp,%rsi,4), %r11d
shll $0xf, %r11d
imull $0xffffe8ee, -0x24(%rsp,%rsi,4), %ebx # imm = 0xFFFFE8EE
imull $0x1b37, -0x2c(%rsp,%rsi,4), %ebp # imm = 0x1B37
imull $0xffffd746, %r10d, %r10d # imm = 0xFFFFD746
addl %ebp, %r10d
imull $0x73fc, %r9d, %r9d     # imm = 0x73FC
addl %ebx, %r9d
addl %r10d, %r9d
leal (%r11,%r9), %r10d
addl $0x80000, %r10d         # imm = 0x80000
addl $0x80000, %r11d         # imm = 0x80000
shrl $0x14, %r10d
andl %edi, %r10d
movb 0x80(%rax,%r10), %r10b
movb %r10b, (%r8,%rdx)
subl %r9d, %r11d
shrl $0x14, %r11d
andl %edi, %r11d
movb 0x80(%rax,%r11), %r9b
movb %r9b, 0x1(%r8,%rdx)
addq $0x8, %rsi
jmp 0x760ba
movl -0x40(%rsp,%rsi,4), %r9d
addl $0x10, %r9d
shrl $0x5, %r9d
andl $0x3ff, %r9d            # imm = 0x3FF
movb 0x80(%rax,%r9), %r9b
movb %r9b, (%r8,%rdx)
jmp 0x76152
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq