// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/jpeg/jcdctmgr.c
// Function: start_pass_fdctmgr
METHODDEF(void)
start_pass_fdctmgr (j_compress_ptr cinfo)
{
  my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
  int ci, qtblno, i;
  jpeg_component_info *compptr;
  JQUANT_TBL * qtbl;
  DCTELEM * dtbl;

  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
       ci++, compptr++) {
    qtblno = compptr->quant_tbl_no;
    /* Make sure specified quantization table is present */
    if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||
	cinfo->quant_tbl_ptrs[qtblno] == NULL)
      ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
    qtbl = cinfo->quant_tbl_ptrs[qtblno];
    /* Compute divisors for this quant table */
    /* We may do this more than once for same table, but it's not a big deal */
    switch (cinfo->dct_method) {
#ifdef DCT_ISLOW_SUPPORTED
    case JDCT_ISLOW:
      /* For LL&M IDCT method, divisors are equal to raw quantization
       * coefficients multiplied by 8 (to counteract scaling).
       */
      if (fdct->divisors[qtblno] == NULL) {
	fdct->divisors[qtblno] = (DCTELEM *)
	  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
				      DCTSIZE2 * SIZEOF(DCTELEM));
      }
      dtbl = fdct->divisors[qtblno];
      for (i = 0; i < DCTSIZE2; i++) {
	dtbl[i] = ((DCTELEM) qtbl->quantval[i]) << 3;
      }
      break;
#endif
#ifdef DCT_IFAST_SUPPORTED
    case JDCT_IFAST:
      {
	/* For AA&N IDCT method, divisors are equal to quantization
	 * coefficients scaled by scalefactor[row]*scalefactor[col], where
	 *   scalefactor[0] = 1
	 *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
	 * We apply a further scale factor of 8.
	 */
#define CONST_BITS 14
	static const INT16 aanscales[DCTSIZE2] = {
	  /* precomputed values scaled up by 14 bits */
	  16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
	  22725, 31521, 29692, 26722, 22725, 17855, 12299,  6270,
	  21407, 29692, 27969, 25172, 21407, 16819, 11585,  5906,
	  19266, 26722, 25172, 22654, 19266, 15137, 10426,  5315,
	  16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
	  12873, 17855, 16819, 15137, 12873, 10114,  6967,  3552,
	   8867, 12299, 11585, 10426,  8867,  6967,  4799,  2446,
	   4520,  6270,  5906,  5315,  4520,  3552,  2446,  1247
	};
	SHIFT_TEMPS

	if (fdct->divisors[qtblno] == NULL) {
	  fdct->divisors[qtblno] = (DCTELEM *)
	    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
					DCTSIZE2 * SIZEOF(DCTELEM));
	}
	dtbl = fdct->divisors[qtblno];
	for (i = 0; i < DCTSIZE2; i++) {
	  dtbl[i] = (DCTELEM)
	    DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i],
				  (INT32) aanscales[i]),
		    CONST_BITS-3);
	}
      }
      break;
#endif
#ifdef DCT_FLOAT_SUPPORTED
    case JDCT_FLOAT:
      {
	/* For float AA&N IDCT method, divisors are equal to quantization
	 * coefficients scaled by scalefactor[row]*scalefactor[col], where
	 *   scalefactor[0] = 1
	 *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
	 * We apply a further scale factor of 8.
	 * What's actually stored is 1/divisor so that the inner loop can
	 * use a multiplication rather than a division.
	 */
	FAST_FLOAT * fdtbl;
	int row, col;
	static const double aanscalefactor[DCTSIZE] = {
	  1.0, 1.387039845, 1.306562965, 1.175875602,
	  1.0, 0.785694958, 0.541196100, 0.275899379
	};

	if (fdct->float_divisors[qtblno] == NULL) {
	  fdct->float_divisors[qtblno] = (FAST_FLOAT *)
	    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
					DCTSIZE2 * SIZEOF(FAST_FLOAT));
	}
	fdtbl = fdct->float_divisors[qtblno];
	i = 0;
	for (row = 0; row < DCTSIZE; row++) {
	  for (col = 0; col < DCTSIZE; col++) {
	    fdtbl[i] = (FAST_FLOAT)
	      (1.0 / (((double) qtbl->quantval[i] *
		       aanscalefactor[row] * aanscalefactor[col] * 8.0)));
	    i++;
	  }
	}
      }
      break;
#endif
    default:
      ERREXIT(cinfo, JERR_NOT_COMPILED);
      break;
    }
  }
}

// Assembly:
cmpl $0x0, 0x4c(%rdi)
jle 0x7953d
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x58(%rdi), %r14
movq 0x1e8(%rdi), %rax
movq %rax, (%rsp)
xorl %r12d, %r12d
leaq 0x313bd(%rip), %r13     # 0xaa620
pxor %xmm6, %xmm6
movapd 0x312f1(%rip), %xmm7    # 0xaa560
movapd 0x29ce8(%rip), %xmm8    # 0xa2f60
movdqa 0x312ef(%rip), %xmm9    # 0xaa570
movl 0x10(%r14), %ebp
cmpq $0x3, %rbp
ja 0x79295
movq 0x60(%rbx,%rbp,8), %r15
testq %r15, %r15
jne 0x792d0
movslq %ebp, %rbp
movq (%rbx), %rax
movl $0x34, 0x28(%rax)
movl %ebp, 0x2c(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movdqa 0x312ba(%rip), %xmm9    # 0xaa570
movapd 0x29ca1(%rip), %xmm8    # 0xa2f60
movapd 0x31299(%rip), %xmm7    # 0xaa560
pxor %xmm6, %xmm6
movq 0x60(%rbx,%rbp,8), %r15
movl 0x114(%rbx), %eax
cmpl $0x2, %eax
je 0x7943e
cmpl $0x1, %eax
je 0x79359
testl %eax, %eax
jne 0x794f1
movq (%rsp), %rax
movq 0x18(%rax,%rbp,8), %rax
testq %rax, %rax
jne 0x79334
movq 0x8(%rbx), %rax
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
movl $0x1, %esi
callq *(%rax)
movdqa 0x3125a(%rip), %xmm9    # 0xaa570
movapd 0x29c41(%rip), %xmm8    # 0xa2f60
movapd 0x31239(%rip), %xmm7    # 0xaa560
pxor %xmm6, %xmm6
movq (%rsp), %rcx
movq %rax, 0x18(%rcx,%rbp,8)
xorl %ecx, %ecx
movq (%r15,%rcx,2), %xmm0
punpcklwd %xmm6, %xmm0    # xmm0 = xmm0[0],xmm6[0],xmm0[1],xmm6[1],xmm0[2],xmm6[2],xmm0[3],xmm6[3]
pslld $0x3, %xmm0
movdqu %xmm0, (%rax,%rcx,4)
addq $0x4, %rcx
cmpq $0x40, %rcx
jne 0x79336
jmp 0x7951e
movq (%rsp), %rax
movq 0x18(%rax,%rbp,8), %rax
testq %rax, %rax
jne 0x793a1
movq 0x8(%rbx), %rax
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
movl $0x1, %esi
callq *(%rax)
movdqa 0x311ed(%rip), %xmm9    # 0xaa570
movapd 0x29bd4(%rip), %xmm8    # 0xa2f60
movapd 0x311cc(%rip), %xmm7    # 0xaa560
pxor %xmm6, %xmm6
movq (%rsp), %rcx
movq %rax, 0x18(%rcx,%rbp,8)
xorl %ecx, %ecx
leaq 0x311f6(%rip), %rdx     # 0xaa5a0
movq (%r15,%rcx), %xmm0
punpcklwd %xmm6, %xmm0    # xmm0 = xmm0[0],xmm6[0],xmm0[1],xmm6[1],xmm0[2],xmm6[2],xmm0[3],xmm6[3]
movdqa %xmm0, %xmm1
punpckldq %xmm6, %xmm1    # xmm1 = xmm1[0],xmm6[0],xmm1[1],xmm6[1]
punpckhdq %xmm6, %xmm0    # xmm0 = xmm0[2],xmm6[2],xmm0[3],xmm6[3]
movq (%rcx,%rdx), %xmm2
punpcklwd %xmm2, %xmm2    # xmm2 = xmm2[0,0,1,1,2,2,3,3]
psrad $0x10, %xmm2
pshufd $0xd4, %xmm2, %xmm3     # xmm3 = xmm2[0,1,1,3]
pxor %xmm4, %xmm4
pcmpgtd %xmm2, %xmm4
pshufd $0xf6, %xmm2, %xmm2     # xmm2 = xmm2[2,1,3,3]
pmuludq %xmm0, %xmm2
pshufd $0xf6, %xmm4, %xmm5     # xmm5 = xmm4[2,1,3,3]
pmuludq %xmm0, %xmm5
psllq $0x20, %xmm5
pmuludq %xmm1, %xmm3
pshufd $0xd4, %xmm4, %xmm0     # xmm0 = xmm4[0,1,1,3]
pmuludq %xmm1, %xmm0
psllq $0x20, %xmm0
paddq %xmm9, %xmm3
paddq %xmm0, %xmm3
paddq %xmm9, %xmm2
paddq %xmm5, %xmm2
psrlq $0xb, %xmm2
psrlq $0xb, %xmm3
shufps $0x88, %xmm2, %xmm3     # xmm3 = xmm3[0,2],xmm2[0,2]
movups %xmm3, (%rax,%rcx,2)
addq $0x8, %rcx
cmpq $0x80, %rcx
jne 0x793aa
jmp 0x7951e
movq (%rsp), %rax
movq 0x40(%rax,%rbp,8), %rax
testq %rax, %rax
jne 0x79486
movq 0x8(%rbx), %rax
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
movl $0x1, %esi
callq *(%rax)
movdqa 0x31108(%rip), %xmm9    # 0xaa570
movapd 0x29aef(%rip), %xmm8    # 0xa2f60
movapd 0x310e7(%rip), %xmm7    # 0xaa560
pxor %xmm6, %xmm6
movq (%rsp), %rcx
movq %rax, 0x40(%rcx,%rbp,8)
xorl %ecx, %ecx
xorl %edx, %edx
movslq %edx, %rdi
leaq 0x8(%rdi), %rdx
movsd (%r13,%rcx,8), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
leaq (%r15,%rdi,2), %rsi
leaq (%rax,%rdi,4), %rdi
movq %r13, %r8
xorl %r9d, %r9d
movd (%rsi,%r9,2), %xmm1
punpcklwd %xmm6, %xmm1    # xmm1 = xmm1[0],xmm6[0],xmm1[1],xmm6[1],xmm1[2],xmm6[2],xmm1[3],xmm6[3]
cvtdq2pd %xmm1, %xmm1
mulpd %xmm0, %xmm1
mulpd (%r8), %xmm1
mulpd %xmm7, %xmm1
movapd %xmm8, %xmm2
divpd %xmm1, %xmm2
cvtpd2ps %xmm2, %xmm1
movlpd %xmm1, (%rdi,%r9,4)
addq $0x2, %r9
addq $0x10, %r8
cmpq $0x8, %r9
jne 0x794aa
incq %rcx
cmpq $0x8, %rcx
jne 0x7948a
jmp 0x7951e
movq (%rbx), %rax
movl $0x30, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
movdqa 0x31067(%rip), %xmm9    # 0xaa570
movapd 0x29a4e(%rip), %xmm8    # 0xa2f60
movapd 0x31046(%rip), %xmm7    # 0xaa560
pxor %xmm6, %xmm6
incl %r12d
addq $0x60, %r14
cmpl 0x4c(%rbx), %r12d
jl 0x79281
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq