// File: /workspace/github_cpp_makefile_star2_O2/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 $0x108, %rsp            # imm = 0x108
movl %r9d, %ebx
movq %rcx, %r14
movq 0x1e8(%rdi), %rax
movq 0x38(%rax), %r13
movslq 0x10(%rsi), %rcx
movq 0x40(%rax,%rcx,8), %rbp
movl %r8d, %eax
leaq (%rdx,%rax,8), %r12
xorl %r15d, %r15d
movl 0x140(%rsp), %eax
cmpq %rax, %r15
je 0x6e280
movl %ebx, %eax
xorl %ecx, %ecx
cmpq $0x40, %rcx
je 0x6e238
movq (%r12,%rcx), %rdx
movzbl (%rdx,%rax), %esi
addl $-0x80, %esi
cvtsi2ss %esi, %xmm0
movss %xmm0, (%rsp,%rcx,4)
movzbl 0x1(%rdx,%rax), %esi
addl $-0x80, %esi
cvtsi2ss %esi, %xmm0
movss %xmm0, 0x4(%rsp,%rcx,4)
movzbl 0x2(%rdx,%rax), %esi
addl $-0x80, %esi
cvtsi2ss %esi, %xmm0
movss %xmm0, 0x8(%rsp,%rcx,4)
movzbl 0x3(%rdx,%rax), %esi
addl $-0x80, %esi
cvtsi2ss %esi, %xmm0
movss %xmm0, 0xc(%rsp,%rcx,4)
movzbl 0x4(%rdx,%rax), %esi
addl $-0x80, %esi
cvtsi2ss %esi, %xmm0
movss %xmm0, 0x10(%rsp,%rcx,4)
movzbl 0x5(%rdx,%rax), %esi
addl $-0x80, %esi
cvtsi2ss %esi, %xmm0
movss %xmm0, 0x14(%rsp,%rcx,4)
movzbl 0x6(%rdx,%rax), %esi
addl $-0x80, %esi
cvtsi2ss %esi, %xmm0
movss %xmm0, 0x18(%rsp,%rcx,4)
movzbl 0x7(%rdx,%rax), %edx
addl $-0x80, %edx
cvtsi2ss %edx, %xmm0
movss %xmm0, 0x1c(%rsp,%rcx,4)
addq $0x8, %rcx
jmp 0x6e193
movq %rsp, %rdi
callq *%r13
movss 0x2d20e(%rip), %xmm1    # 0x9b454
xorl %eax, %eax
cmpq $0x40, %rax
je 0x6e271
movss (%rsp,%rax,4), %xmm0
mulss (%rbp,%rax,4), %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %ecx
addl $0xffffc000, %ecx       # imm = 0xFFFFC000
movw %cx, (%r14,%rax,2)
incq %rax
jmp 0x6e248
incq %r15
addl $0x8, %ebx
subq $-0x80, %r14
jmp 0x6e17f
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop