// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/jpeg/jcdctmgr.c
// Function: forward_DCT_float
METHODDEF(void)
forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr,
		   JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
		   JDIMENSION start_row, JDIMENSION start_col,
		   JDIMENSION num_blocks)
/* This version is used for floating-point DCT implementations. */
{
  /* This routine is heavily used, so it's worth coding it tightly. */
  my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
  float_DCT_method_ptr do_dct = fdct->do_float_dct;
  FAST_FLOAT * divisors = fdct->float_divisors[compptr->quant_tbl_no];
  FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */
  JDIMENSION bi;

  sample_data += start_row;	/* fold in the vertical offset once */

  for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) {
    /* Load data into workspace, applying unsigned->signed conversion */
    { register FAST_FLOAT *workspaceptr;
      register JSAMPROW elemptr;
      register int elemr;

      workspaceptr = workspace;
      for (elemr = 0; elemr < DCTSIZE; elemr++) {
	elemptr = sample_data[elemr] + start_col;
#if DCTSIZE == 8		/* unroll the inner loop */
	*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
	*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
	*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
	*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
	*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
	*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
	*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
	*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
#else
	{ register int elemc;
	  for (elemc = DCTSIZE; elemc > 0; elemc--) {
	    *workspaceptr++ = (FAST_FLOAT)
	      (GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
	  }
	}
#endif
      }
    }

    /* Perform the DCT */
    (*do_dct) (workspace);

    /* Quantize/descale the coefficients, and store into coef_blocks[] */
    { register FAST_FLOAT temp;
      register int i;
      register JCOEFPTR output_ptr = coef_blocks[bi];

      for (i = 0; i < DCTSIZE2; i++) {
	/* Apply the quantization and scaling factor */
	temp = workspace[i] * divisors[i];
	/* Round to nearest integer.
	 * Since C does not specify the direction of rounding for negative
	 * quotients, we have to force the dividend positive for portability.
	 * The maximum coefficient size is +-16K (for 12-bit data), so this
	 * code should work for either 16-bit or 32-bit ints.
	 */
	output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384);
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movl 0x150(%rsp), %eax
testl %eax, %eax
je 0x7a4b5
movl %r9d, %ebx
movq %rcx, %r14
movq 0x1e8(%rdi), %rcx
movq 0x38(%rcx), %rdi
movq %rdi, 0x8(%rsp)
movslq 0x10(%rsi), %rsi
movq 0x40(%rcx,%rsi,8), %r13
movl %r8d, %ecx
leaq (%rdx,%rcx,8), %rbp
movl %eax, %r15d
xorl %r12d, %r12d
movl %ebx, %ebx
xorl %eax, %eax
movq (%rbp,%rax), %rcx
movzbl (%rcx,%rbx), %edx
addl $-0x80, %edx
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
movss %xmm0, 0x10(%rsp,%rax,4)
movzbl 0x1(%rcx,%rbx), %edx
addl $-0x80, %edx
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
movss %xmm0, 0x14(%rsp,%rax,4)
movzbl 0x2(%rcx,%rbx), %edx
addl $-0x80, %edx
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
movss %xmm0, 0x18(%rsp,%rax,4)
movzbl 0x3(%rcx,%rbx), %edx
addl $-0x80, %edx
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
movss %xmm0, 0x1c(%rsp,%rax,4)
movzbl 0x4(%rcx,%rbx), %edx
addl $-0x80, %edx
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
movss %xmm0, 0x20(%rsp,%rax,4)
movzbl 0x5(%rcx,%rbx), %edx
addl $-0x80, %edx
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
movss %xmm0, 0x24(%rsp,%rax,4)
movzbl 0x6(%rcx,%rbx), %edx
addl $-0x80, %edx
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
movss %xmm0, 0x28(%rsp,%rax,4)
movzbl 0x7(%rcx,%rbx), %ecx
addl $-0x80, %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movss %xmm0, 0x2c(%rsp,%rax,4)
addq $0x8, %rax
cmpq $0x40, %rax
jne 0x7a399
leaq 0x10(%rsp), %rdi
callq *0x8(%rsp)
xorl %eax, %eax
movaps 0x3010b(%rip), %xmm1    # 0xaa570
movdqa 0x30113(%rip), %xmm2    # 0xaa580
movups (%r13,%rax,4), %xmm0
mulps 0x10(%rsp,%rax,4), %xmm0
addps %xmm1, %xmm0
cvttps2dq %xmm0, %xmm0
pshuflw $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3,4,5,6,7]
pshufhw $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,1,2,3,4,6,6,7]
pshufd $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3]
paddw %xmm2, %xmm0
movq %xmm0, (%r14,%rax,2)
addq $0x4, %rax
cmpq $0x40, %rax
jne 0x7a46d
incq %r12
addl $0x8, %ebx
subq $-0x80, %r14
cmpq %r15, %r12
jne 0x7a395
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop