// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/jpeg/jfdctint.c
// Function: jpeg_fdct_islow
GLOBAL(void)
jpeg_fdct_islow (DCTELEM * data)
{
  INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
  INT32 tmp10, tmp11, tmp12, tmp13;
  INT32 z1, z2, z3, z4, z5;
  DCTELEM *dataptr;
  int ctr;
  SHIFT_TEMPS

  /* Pass 1: process rows. */
  /* Note results are scaled up by sqrt(8) compared to a true DCT; */
  /* furthermore, we scale the results by 2**PASS1_BITS. */

  dataptr = data;
  for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
    tmp0 = dataptr[0] + dataptr[7];
    tmp7 = dataptr[0] - dataptr[7];
    tmp1 = dataptr[1] + dataptr[6];
    tmp6 = dataptr[1] - dataptr[6];
    tmp2 = dataptr[2] + dataptr[5];
    tmp5 = dataptr[2] - dataptr[5];
    tmp3 = dataptr[3] + dataptr[4];
    tmp4 = dataptr[3] - dataptr[4];
    
    /* Even part per LL&M figure 1 --- note that published figure is faulty;
     * rotator "sqrt(2)*c1" should be "sqrt(2)*c6".
     */
    
    tmp10 = tmp0 + tmp3;
    tmp13 = tmp0 - tmp3;
    tmp11 = tmp1 + tmp2;
    tmp12 = tmp1 - tmp2;
    
    dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS);
    dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS);
    
    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
    dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
				   CONST_BITS-PASS1_BITS);
    dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
				   CONST_BITS-PASS1_BITS);
    
    /* Odd part per figure 8 --- note paper omits factor of sqrt(2).
     * cK represents cos(K*pi/16).
     * i0..i3 in the paper are tmp4..tmp7 here.
     */
    
    z1 = tmp4 + tmp7;
    z2 = tmp5 + tmp6;
    z3 = tmp4 + tmp6;
    z4 = tmp5 + tmp7;
    z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
    
    tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
    tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
    tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
    tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
    z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
    z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
    z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
    z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
    
    z3 += z5;
    z4 += z5;
    
    dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS);
    dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS);
    dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS);
    dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS);
    
    dataptr += DCTSIZE;		/* advance pointer to next row */
  }

  /* Pass 2: process columns.
   * We remove the PASS1_BITS scaling, but leave the results scaled up
   * by an overall factor of 8.
   */

  dataptr = data;
  for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
    tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];
    tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];
    tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];
    tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];
    tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];
    tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];
    tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];
    tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];
    
    /* Even part per LL&M figure 1 --- note that published figure is faulty;
     * rotator "sqrt(2)*c1" should be "sqrt(2)*c6".
     */
    
    tmp10 = tmp0 + tmp3;
    tmp13 = tmp0 - tmp3;
    tmp11 = tmp1 + tmp2;
    tmp12 = tmp1 - tmp2;
    
    dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS);
    dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS);
    
    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
    dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
					   CONST_BITS+PASS1_BITS);
    dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
					   CONST_BITS+PASS1_BITS);
    
    /* Odd part per figure 8 --- note paper omits factor of sqrt(2).
     * cK represents cos(K*pi/16).
     * i0..i3 in the paper are tmp4..tmp7 here.
     */
    
    z1 = tmp4 + tmp7;
    z2 = tmp5 + tmp6;
    z3 = tmp4 + tmp6;
    z4 = tmp5 + tmp7;
    z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
    
    tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
    tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
    tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
    tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
    z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
    z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
    z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
    z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
    
    z3 += z5;
    z4 += z5;
    
    dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3,
					   CONST_BITS+PASS1_BITS);
    dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4,
					   CONST_BITS+PASS1_BITS);
    dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3,
					   CONST_BITS+PASS1_BITS);
    dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4,
					   CONST_BITS+PASS1_BITS);
    
    dataptr++;			/* advance pointer to next column */
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl $0x7, %eax
movabsq $0x7ffffffc4df, %rcx    # imm = 0x7FFFFFFC4DF
movq %rdi, %rdx
testl %eax, %eax
js 0x6e8c9
movl 0x1c(%rdx), %esi
movl (%rdx), %r8d
movl 0x4(%rdx), %r9d
leal (%rsi,%r8), %r10d
movslq %r10d, %r10
subl %esi, %r8d
movslq %r8d, %rsi
movl 0x18(%rdx), %r8d
leal (%r8,%r9), %r11d
movslq %r11d, %r11
subl %r8d, %r9d
movslq %r9d, %r8
movl 0x8(%rdx), %r9d
movl 0x14(%rdx), %ebx
leal (%rbx,%r9), %ebp
movslq %ebp, %r14
subl %ebx, %r9d
movslq %r9d, %r9
movl 0xc(%rdx), %ebx
movl 0x10(%rdx), %r15d
leal (%r15,%rbx), %ebp
movslq %ebp, %r12
subl %r15d, %ebx
movslq %ebx, %rbx
leal (%r12,%r10), %r15d
subq %r12, %r10
leal (%r14,%r11), %r12d
subq %r14, %r11
leal (%r15,%r12), %ebp
shll $0x2, %ebp
movl %ebp, (%rdx)
subl %r12d, %r15d
shll $0x2, %r15d
movl %r15d, 0x10(%rdx)
leaq (%r10,%r11), %r14
imulq $0x1151, %r14, %r14     # imm = 0x1151
imulq $0x187e, %r10, %r10     # imm = 0x187E
addq %r14, %r10
addq $0x400, %r10            # imm = 0x400
shrq $0xb, %r10
movl %r10d, 0x8(%rdx)
imulq %rcx, %r11
leaq (%r14,%r11), %r10
addq $0x400, %r10            # imm = 0x400
shrq $0xb, %r10
movl %r10d, 0x18(%rdx)
leaq (%rbx,%rsi), %r10
leaq (%r9,%r8), %r11
leaq (%rbx,%r8), %r14
leaq (%r9,%rsi), %r15
leaq (%r14,%r15), %r12
imulq $0x25a1, %r12, %r12     # imm = 0x25A1
imulq $0x98e, %rbx, %rbx      # imm = 0x98E
imulq $0x41b3, %r9, %r9       # imm = 0x41B3
imulq $0x6254, %r8, %r8       # imm = 0x6254
imulq $0x300b, %rsi, %rsi     # imm = 0x300B
imulq $-0x1ccd, %r10, %r10    # imm = 0xE333
imulq $-0x5203, %r11, %r11    # imm = 0xADFD
imulq $-0x3ec5, %r14, %r14    # imm = 0xC13B
imulq $-0xc7c, %r15, %r15     # imm = 0xF384
addq %r12, %r14
addq %r12, %r15
addq %r10, %rbx
addq $0x400, %rbx            # imm = 0x400
addq %r14, %rbx
shrq $0xb, %rbx
movl %ebx, 0x1c(%rdx)
addq %r11, %r9
addq $0x400, %r9             # imm = 0x400
addq %r15, %r9
shrq $0xb, %r9
movl %r9d, 0x14(%rdx)
addq %r11, %r8
addq $0x400, %r8             # imm = 0x400
addq %r14, %r8
shrq $0xb, %r8
movl %r8d, 0xc(%rdx)
addq %r10, %rsi
addq $0x400, %rsi            # imm = 0x400
addq %r15, %rsi
shrq $0xb, %rsi
movl %esi, 0x4(%rdx)
addq $0x20, %rdx
decl %eax
jmp 0x6e75e
movl $0x7, %eax
movabsq $0x7fffffffc4df, %rcx   # imm = 0x7FFFFFFFC4DF
testl %eax, %eax
js 0x6ea63
movl 0xe0(%rdi), %edx
movl (%rdi), %esi
movl 0x20(%rdi), %r8d
leal (%rdx,%rsi), %r9d
movslq %r9d, %r9
subl %edx, %esi
movslq %esi, %rdx
movl 0xc0(%rdi), %esi
leal (%rsi,%r8), %r10d
movslq %r10d, %r10
subl %esi, %r8d
movslq %r8d, %rsi
movl 0x40(%rdi), %r8d
movl 0xa0(%rdi), %r11d
leal (%r11,%r8), %ebx
movslq %ebx, %rbx
subl %r11d, %r8d
movslq %r8d, %r8
movl 0x60(%rdi), %r11d
movl 0x80(%rdi), %r14d
leal (%r14,%r11), %ebp
movslq %ebp, %r15
subl %r14d, %r11d
movslq %r11d, %r11
leaq (%r15,%r9), %r14
subq %r15, %r9
leaq (%rbx,%r10), %r15
subq %rbx, %r10
leaq (%r15,%r14), %rbx
addq $0x2, %rbx
shrq $0x2, %rbx
movl %ebx, (%rdi)
subq %r15, %r14
addq $0x2, %r14
shrq $0x2, %r14
movl %r14d, 0x80(%rdi)
leaq (%r9,%r10), %rbx
imulq $0x1151, %rbx, %rbx     # imm = 0x1151
imulq $0x187e, %r9, %r9       # imm = 0x187E
addq %rbx, %r9
addq $0x4000, %r9            # imm = 0x4000
shrq $0xf, %r9
movl %r9d, 0x40(%rdi)
imulq %rcx, %r10
leaq (%rbx,%r10), %r9
addq $0x4000, %r9            # imm = 0x4000
shrq $0xf, %r9
movl %r9d, 0xc0(%rdi)
leaq (%r11,%rdx), %r9
leaq (%r8,%rsi), %r10
leaq (%r11,%rsi), %rbx
leaq (%r8,%rdx), %r14
leaq (%rbx,%r14), %r15
imulq $0x25a1, %r15, %r15     # imm = 0x25A1
imulq $0x98e, %r11, %r11      # imm = 0x98E
imulq $0x41b3, %r8, %r8       # imm = 0x41B3
imulq $0x6254, %rsi, %rsi     # imm = 0x6254
imulq $0x300b, %rdx, %rdx     # imm = 0x300B
imulq $-0x1ccd, %r9, %r9      # imm = 0xE333
imulq $-0x5203, %r10, %r10    # imm = 0xADFD
imulq $-0x3ec5, %rbx, %rbx    # imm = 0xC13B
imulq $-0xc7c, %r14, %r14     # imm = 0xF384
addq %r15, %rbx
addq %r15, %r14
addq %r9, %r11
addq $0x4000, %r11           # imm = 0x4000
addq %rbx, %r11
shrq $0xf, %r11
movl %r11d, 0xe0(%rdi)
addq %r10, %r8
addq $0x4000, %r8            # imm = 0x4000
addq %r14, %r8
shrq $0xf, %r8
movl %r8d, 0xa0(%rdi)
addq %r10, %rsi
addq $0x4000, %rsi           # imm = 0x4000
addq %rbx, %rsi
shrq $0xf, %rsi
movl %esi, 0x60(%rdi)
addq %r9, %rdx
addq $0x4000, %rdx           # imm = 0x4000
addq %r14, %rdx
shrq $0xf, %rdx
movl %edx, 0x20(%rdi)
addq $0x4, %rdi
decl %eax
jmp 0x6e8d8
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq