// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/jpeg/jdcoefct.c
// Function: decompress_smooth_data
METHODDEF(int)
decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
{
  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
  JDIMENSION block_num, last_block_column;
  int ci, block_row, block_rows, access_rows;
  JBLOCKARRAY buffer;
  JBLOCKROW buffer_ptr, prev_block_row, next_block_row;
  JSAMPARRAY output_ptr;
  JDIMENSION output_col;
  jpeg_component_info *compptr;
  inverse_DCT_method_ptr inverse_DCT;
  jboolean first_row, last_row;
  JBLOCK workspace;
  int *coef_bits;
  JQUANT_TBL *quanttbl;
  INT32 Q00,Q01,Q02,Q10,Q11,Q20, num;
  int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9;
  int Al, pred;

  /* Force some input to be done if we are getting ahead of the input. */
  while (cinfo->input_scan_number <= cinfo->output_scan_number &&
	 ! cinfo->inputctl->eoi_reached) {
    if (cinfo->input_scan_number == cinfo->output_scan_number) {
      /* If input is working on current scan, we ordinarily want it to
       * have completed the current row.  But if input scan is DC,
       * we want it to keep one row ahead so that next block row's DC
       * values are up to date.
       */
      JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0;
      if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta)
	break;
    }
    if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)
      return JPEG_SUSPENDED;
  }

  /* OK, output from the virtual arrays. */
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
       ci++, compptr++) {
    /* Don't bother to IDCT an uninteresting component. */
    if (! compptr->component_needed)
      continue;
    /* Count non-dummy DCT block rows in this iMCU row. */
    if (cinfo->output_iMCU_row < last_iMCU_row) {
      block_rows = compptr->v_samp_factor;
      access_rows = block_rows * 2; /* this and next iMCU row */
      last_row = FALSE;
    } else {
      /* NB: can't use last_row_height here; it is input-side-dependent! */
      block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
      if (block_rows == 0) block_rows = compptr->v_samp_factor;
      access_rows = block_rows; /* this iMCU row only */
      last_row = TRUE;
    }
    /* Align the virtual buffer for this component. */
    if (cinfo->output_iMCU_row > 0) {
      access_rows += compptr->v_samp_factor; /* prior iMCU row too */
      buffer = (*cinfo->mem->access_virt_barray)
	((j_common_ptr) cinfo, coef->whole_image[ci],
	 (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
	 (JDIMENSION) access_rows, FALSE);
      buffer += compptr->v_samp_factor;	/* point to current iMCU row */
      first_row = FALSE;
    } else {
      buffer = (*cinfo->mem->access_virt_barray)
	((j_common_ptr) cinfo, coef->whole_image[ci],
	 (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE);
      first_row = TRUE;
    }
    /* Fetch component-dependent info */
    coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);
    quanttbl = compptr->quant_table;
    Q00 = quanttbl->quantval[0];
    Q01 = quanttbl->quantval[Q01_POS];
    Q10 = quanttbl->quantval[Q10_POS];
    Q20 = quanttbl->quantval[Q20_POS];
    Q11 = quanttbl->quantval[Q11_POS];
    Q02 = quanttbl->quantval[Q02_POS];
    inverse_DCT = cinfo->idct->inverse_DCT[ci];
    output_ptr = output_buf[ci];
    /* Loop over all DCT blocks to be processed. */
    for (block_row = 0; block_row < block_rows; block_row++) {
      buffer_ptr = buffer[block_row];
      if (first_row && block_row == 0)
	prev_block_row = buffer_ptr;
      else
	prev_block_row = buffer[block_row-1];
      if (last_row && block_row == block_rows-1)
	next_block_row = buffer_ptr;
      else
	next_block_row = buffer[block_row+1];
      /* We fetch the surrounding DC values using a sliding-register approach.
       * Initialize all nine here so as to do the right thing on narrow pics.
       */
      DC1 = DC2 = DC3 = (int) prev_block_row[0][0];
      DC4 = DC5 = DC6 = (int) buffer_ptr[0][0];
      DC7 = DC8 = DC9 = (int) next_block_row[0][0];
      output_col = 0;
      last_block_column = compptr->width_in_blocks - 1;
      for (block_num = 0; block_num <= last_block_column; block_num++) {
	/* Fetch current DCT block into workspace so we can modify it. */
	jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1);
	/* Update DC values */
	if (block_num < last_block_column) {
	  DC3 = (int) prev_block_row[1][0];
	  DC6 = (int) buffer_ptr[1][0];
	  DC9 = (int) next_block_row[1][0];
	}
	/* Compute coefficient estimates per K.8.
	 * An estimate is applied only if coefficient is still zero,
	 * and is not known to be fully accurate.
	 */
	/* AC01 */
	if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) {
	  num = 36 * Q00 * (DC4 - DC6);
	  if (num >= 0) {
	    pred = (int) (((Q01<<7) + num) / (Q01<<8));
	    if (Al > 0 && pred >= (1<<Al))
	      pred = (1<<Al)-1;
	  } else {
	    pred = (int) (((Q01<<7) - num) / (Q01<<8));
	    if (Al > 0 && pred >= (1<<Al))
	      pred = (1<<Al)-1;
	    pred = -pred;
	  }
	  workspace[1] = (JCOEF) pred;
	}
	/* AC10 */
	if ((Al=coef_bits[2]) != 0 && workspace[8] == 0) {
	  num = 36 * Q00 * (DC2 - DC8);
	  if (num >= 0) {
	    pred = (int) (((Q10<<7) + num) / (Q10<<8));
	    if (Al > 0 && pred >= (1<<Al))
	      pred = (1<<Al)-1;
	  } else {
	    pred = (int) (((Q10<<7) - num) / (Q10<<8));
	    if (Al > 0 && pred >= (1<<Al))
	      pred = (1<<Al)-1;
	    pred = -pred;
	  }
	  workspace[8] = (JCOEF) pred;
	}
	/* AC20 */
	if ((Al=coef_bits[3]) != 0 && workspace[16] == 0) {
	  num = 9 * Q00 * (DC2 + DC8 - 2*DC5);
	  if (num >= 0) {
	    pred = (int) (((Q20<<7) + num) / (Q20<<8));
	    if (Al > 0 && pred >= (1<<Al))
	      pred = (1<<Al)-1;
	  } else {
	    pred = (int) (((Q20<<7) - num) / (Q20<<8));
	    if (Al > 0 && pred >= (1<<Al))
	      pred = (1<<Al)-1;
	    pred = -pred;
	  }
	  workspace[16] = (JCOEF) pred;
	}
	/* AC11 */
	if ((Al=coef_bits[4]) != 0 && workspace[9] == 0) {
	  num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9);
	  if (num >= 0) {
	    pred = (int) (((Q11<<7) + num) / (Q11<<8));
	    if (Al > 0 && pred >= (1<<Al))
	      pred = (1<<Al)-1;
	  } else {
	    pred = (int) (((Q11<<7) - num) / (Q11<<8));
	    if (Al > 0 && pred >= (1<<Al))
	      pred = (1<<Al)-1;
	    pred = -pred;
	  }
	  workspace[9] = (JCOEF) pred;
	}
	/* AC02 */
	if ((Al=coef_bits[5]) != 0 && workspace[2] == 0) {
	  num = 9 * Q00 * (DC4 + DC6 - 2*DC5);
	  if (num >= 0) {
	    pred = (int) (((Q02<<7) + num) / (Q02<<8));
	    if (Al > 0 && pred >= (1<<Al))
	      pred = (1<<Al)-1;
	  } else {
	    pred = (int) (((Q02<<7) - num) / (Q02<<8));
	    if (Al > 0 && pred >= (1<<Al))
	      pred = (1<<Al)-1;
	    pred = -pred;
	  }
	  workspace[2] = (JCOEF) pred;
	}
	/* OK, do the IDCT */
	(*inverse_DCT) (cinfo, compptr, (JCOEFPTR) workspace,
			output_ptr, output_col);
	/* Advance for next column */
	DC1 = DC2; DC2 = DC3;
	DC4 = DC5; DC5 = DC6;
	DC7 = DC8; DC8 = DC9;
	buffer_ptr++, prev_block_row++, next_block_row++;
	output_col += compptr->DCT_scaled_size;
      }
      output_ptr += compptr->DCT_scaled_size;
    }
  }

  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
    return JPEG_ROW_COMPLETED;
  return JPEG_SCAN_COMPLETED;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rsi, 0xd8(%rsp)
movq %rdi, %rbx
movq 0x230(%rdi), %r14
movl 0x1a4(%rdi), %eax
decl %eax
movl %eax, 0x14(%rsp)
movl 0xac(%rbx), %ecx
movl 0xb4(%rbx), %edx
cmpl %edx, %ecx
jg 0x7423a
movq 0x240(%rbx), %rax
cmpl $0x0, 0x24(%rax)
jne 0x7423a
cmpl %edx, %ecx
jne 0x7422a
movl 0xb8(%rbx), %ecx
cmpl $0x1, 0x20c(%rbx)
adcl $0x0, %ecx
cmpl %ecx, 0xb0(%rbx)
ja 0x7423a
movq %rbx, %rdi
callq *(%rax)
testl %eax, %eax
jne 0x741f1
xorl %eax, %eax
jmp 0x748dc
movq 0x130(%rbx), %r15
xorl %ecx, %ecx
movq %rbx, 0x30(%rsp)
movq %r14, 0x50(%rsp)
movslq 0x38(%rbx), %rax
cmpq %rax, %rcx
jge 0x748c2
movq %rcx, 0x58(%rsp)
cmpl $0x0, 0x30(%r15)
je 0x748ac
movq 0x30(%rsp), %rbx
movl 0xb8(%rbx), %r13d
cmpl 0x14(%rsp), %r13d
jb 0x74294
movl 0xc(%r15), %edi
movl 0x20(%r15), %eax
xorl %edx, %edx
divl %edi
movl %edx, %ecx
testl %edx, %edx
cmovel %edi, %ecx
movl %ecx, %ebp
jmp 0x7429d
movl 0xc(%r15), %edi
leal (%rdi,%rdi), %ecx
movl %edi, %ebp
movq 0x50(%rsp), %r14
testl %r13d, %r13d
movq 0x58(%rsp), %r12
je 0x742d4
addl %edi, %ecx
movq 0x8(%rbx), %rax
movq 0x88(%r14,%r12,8), %rsi
leal -0x1(%r13), %edx
imull %edi, %edx
movq %rbx, %rdi
xorl %r8d, %r8d
callq *0x40(%rax)
movslq 0xc(%r15), %rcx
leaq (%rax,%rcx,8), %rax
jmp 0x742eb
movq 0x8(%rbx), %rax
movq 0x88(%r14,%r12,8), %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %r8d, %r8d
callq *0x40(%rax)
movq %rax, 0x60(%rsp)
imulq $0x18, %r12, %rdx
movq 0x50(%r15), %rcx
movzwl (%rcx), %eax
movzwl 0x2(%rcx), %esi
movzwl 0x10(%rcx), %edi
movzwl 0x20(%rcx), %r8d
movzwl 0x12(%rcx), %r9d
movzwl 0x4(%rcx), %r10d
movq 0x258(%rbx), %rcx
movq 0x8(%rcx,%r12,8), %rcx
movq %rcx, 0x110(%rsp)
leal -0x1(%rbp), %ecx
movq %rcx, 0xe0(%rsp)
imulq $0x24, %rax, %rcx
movq %rcx, 0xc0(%rsp)
movl %esi, %ecx
shll $0x7, %ecx
movq %rcx, 0x88(%rsp)
shll $0x8, %esi
movq %rsi, 0xb0(%rsp)
movl %edi, %ecx
shll $0x7, %ecx
movq %rcx, 0x80(%rsp)
shll $0x8, %edi
movq %rdi, 0xa8(%rsp)
movl %r8d, %ecx
shll $0x7, %ecx
movq %rcx, 0x78(%rsp)
shll $0x8, %r8d
movq %r8, 0xa0(%rsp)
movl %r9d, %ecx
shll $0x7, %ecx
movq %rcx, 0x70(%rsp)
shll $0x8, %r9d
movq %r9, 0x98(%rsp)
movl %r10d, %ecx
shll $0x7, %ecx
movq %rcx, 0x68(%rsp)
shll $0x8, %r10d
movq %r10, 0x90(%rsp)
testl %ebp, %ebp
movl $0x0, %ecx
cmovlel %ecx, %ebp
movq %rbp, 0xf0(%rsp)
leaq (%rax,%rax,8), %rcx
movq %rcx, 0xb8(%rsp)
leaq (%rax,%rax,4), %rax
movq %rax, 0x100(%rsp)
movq 0xd8(%r14), %r11
movq 0xd8(%rsp), %rax
movq (%rax,%r12,8), %rax
movq %rax, 0x38(%rsp)
xorl %esi, %esi
movq %r15, 0xc8(%rsp)
movq %r13, 0xe8(%rsp)
movq %rdx, 0x118(%rsp)
cmpq 0xf0(%rsp), %rsi
movq 0x60(%rsp), %rcx
je 0x748ac
movq (%rcx,%rsi,8), %rdi
movl %r13d, %eax
orl %esi, %eax
movq %rdi, 0x20(%rsp)
movq %rdi, 0x28(%rsp)
je 0x74440
movq -0x8(%rcx,%rsi,8), %rax
movq %rax, 0x28(%rsp)
cmpl 0x14(%rsp), %r13d
jb 0x74456
movq 0x20(%rsp), %rdx
cmpq 0xe0(%rsp), %rsi
je 0x7445b
movq 0x8(%rcx,%rsi,8), %rdx
movq %rsi, 0xf8(%rsp)
movq 0x28(%rsp), %rax
movswl (%rax), %r14d
movq 0x20(%rsp), %rax
movswl (%rax), %edi
movq %rdx, 0x108(%rsp)
movswl (%rdx), %ebx
movl 0x1c(%r15), %eax
decl %eax
xorl %edx, %edx
xorl %esi, %esi
xorl %ecx, %ecx
movl %r14d, %r8d
movl %edi, 0x10(%rsp)
movl %edi, %r13d
movl %ebx, %r10d
movl %eax, 0x44(%rsp)
cmpl %eax, %ecx
ja 0x7487a
movl %ebx, 0x48(%rsp)
movl %r14d, 0xc(%rsp)
movq %r11, %r15
movl %esi, %r14d
movl %eax, %ebx
movq 0x20(%rsp), %rax
movq %rdx, 0xd0(%rsp)
leaq (%rax,%rdx), %rdi
leaq 0x120(%rsp), %rsi
pushq $0x1
popq %rdx
movl %ecx, %r12d
movl %r8d, 0x1c(%rsp)
movl %r10d, 0x18(%rsp)
callq 0x791b9
movl 0x18(%rsp), %r10d
movq %r13, %r9
movl 0x1c(%rsp), %r8d
movl %r8d, %r11d
movl %r10d, %ebp
movl %r12d, 0x4c(%rsp)
cmpl %ebx, %r12d
jae 0x74534
movq 0x28(%rsp), %rax
movq 0xd0(%rsp), %rcx
movswl 0x80(%rax,%rcx), %r11d
movq 0x20(%rsp), %rax
movswl 0x80(%rax,%rcx), %r13d
movq 0x108(%rsp), %rax
movswl 0x80(%rax,%rcx), %ebp
movq 0x118(%rsp), %rdi
movq %r15, %rbx
movl 0x4(%r15,%rdi), %ecx
testl %ecx, %ecx
je 0x745ce
cmpw $0x0, 0x122(%rsp)
jne 0x745ce
movl 0x10(%rsp), %eax
subl %r13d, %eax
cltq
imulq 0xc0(%rsp), %rax
testq %rax, %rax
js 0x74595
addq 0x88(%rsp), %rax
xorl %edx, %edx
divq 0xb0(%rsp)
testl %ecx, %ecx
jle 0x745c6
pushq $0x1
popq %rdx
shll %cl, %edx
leal -0x1(%rdx), %ecx
cmpl %eax, %edx
cmovgl %eax, %ecx
movl %ecx, %eax
jmp 0x745c6
movq 0x88(%rsp), %rdx
subq %rax, %rdx
movq %rdx, %rax
xorl %edx, %edx
divq 0xb0(%rsp)
movq %rax, %rdx
pushq $0x1
popq %rax
movl %eax, %esi
shll %cl, %esi
leal -0x1(%rsi), %eax
cmpl %edx, %esi
cmovgl %edx, %eax
testl %ecx, %ecx
cmovlel %edx, %eax
negl %eax
movw %ax, 0x122(%rsp)
movl 0x8(%rbx,%rdi), %ecx
testl %ecx, %ecx
je 0x7465b
cmpw $0x0, 0x130(%rsp)
jne 0x7465b
movl %r8d, %eax
subl %r10d, %eax
cltq
imulq 0xc0(%rsp), %rax
testq %rax, %rax
js 0x74622
addq 0x80(%rsp), %rax
xorl %edx, %edx
divq 0xa8(%rsp)
testl %ecx, %ecx
jle 0x74653
pushq $0x1
popq %rdx
shll %cl, %edx
leal -0x1(%rdx), %ecx
cmpl %eax, %edx
cmovgl %eax, %ecx
movl %ecx, %eax
jmp 0x74653
movq 0x80(%rsp), %rdx
subq %rax, %rdx
movq %rdx, %rax
xorl %edx, %edx
divq 0xa8(%rsp)
movq %rax, %rdx
pushq $0x1
popq %rax
movl %eax, %esi
shll %cl, %esi
leal -0x1(%rsi), %eax
cmpl %edx, %esi
cmovgl %edx, %eax
testl %ecx, %ecx
cmovlel %edx, %eax
negl %eax
movw %ax, 0x130(%rsp)
movl 0xc(%rbx,%rdi), %ecx
testl %ecx, %ecx
je 0x746e9
cmpw $0x0, 0x140(%rsp)
jne 0x746e9
movl %r8d, %edx
subl %r9d, %edx
subl %r9d, %edx
addl %r10d, %edx
movslq %edx, %rax
imulq 0xb8(%rsp), %rax
testq %rax, %rax
js 0x746b3
addq 0x78(%rsp), %rax
xorl %edx, %edx
divq 0xa0(%rsp)
testl %ecx, %ecx
jle 0x746e1
pushq $0x1
popq %rdx
shll %cl, %edx
leal -0x1(%rdx), %ecx
cmpl %eax, %edx
cmovgl %eax, %ecx
movl %ecx, %eax
jmp 0x746e1
movq 0x78(%rsp), %rdx
subq %rax, %rdx
movq %rdx, %rax
xorl %edx, %edx
divq 0xa0(%rsp)
movq %rax, %rdx
pushq $0x1
popq %rax
movl %eax, %esi
shll %cl, %esi
leal -0x1(%rsi), %eax
cmpl %edx, %esi
cmovgl %edx, %eax
testl %ecx, %ecx
cmovlel %edx, %eax
negl %eax
movw %ax, 0x140(%rsp)
movl 0x10(%rbx,%rdi), %ecx
testl %ecx, %ecx
je 0x74779
cmpw $0x0, 0x132(%rsp)
jne 0x74779
movl 0x48(%rsp), %edx
addl %r11d, %edx
movl 0xc(%rsp), %eax
subl %edx, %eax
addl %ebp, %eax
cltq
imulq 0x100(%rsp), %rax
testq %rax, %rax
js 0x74743
addq 0x70(%rsp), %rax
xorl %edx, %edx
divq 0x98(%rsp)
testl %ecx, %ecx
jle 0x74771
pushq $0x1
popq %rdx
shll %cl, %edx
leal -0x1(%rdx), %ecx
cmpl %eax, %edx
cmovgl %eax, %ecx
movl %ecx, %eax
jmp 0x74771
movq 0x70(%rsp), %rdx
subq %rax, %rdx
movq %rdx, %rax
xorl %edx, %edx
divq 0x98(%rsp)
movq %rax, %rdx
pushq $0x1
popq %rax
movl %eax, %esi
shll %cl, %esi
leal -0x1(%rsi), %eax
cmpl %edx, %esi
cmovgl %edx, %eax
testl %ecx, %ecx
cmovlel %edx, %eax
negl %eax
movw %ax, 0x132(%rsp)
movl %ebp, 0xc(%rsp)
movl %r11d, %r15d
movl 0x14(%rbx,%rdi), %ecx
testl %ecx, %ecx
je 0x7480f
cmpw $0x0, 0x124(%rsp)
jne 0x7480f
movl 0x10(%rsp), %edx
subl %r9d, %edx
subl %r9d, %edx
addl %r13d, %edx
movslq %edx, %rax
imulq 0xb8(%rsp), %rax
testq %rax, %rax
js 0x747d9
addq 0x68(%rsp), %rax
xorl %edx, %edx
divq 0x90(%rsp)
testl %ecx, %ecx
jle 0x74807
pushq $0x1
popq %rdx
shll %cl, %edx
leal -0x1(%rdx), %ecx
cmpl %eax, %edx
cmovgl %eax, %ecx
movl %ecx, %eax
jmp 0x74807
movq 0x68(%rsp), %rdx
subq %rax, %rdx
movq %rdx, %rax
xorl %edx, %edx
divq 0x90(%rsp)
movq %rax, %rdx
pushq $0x1
popq %rax
movl %eax, %esi
shll %cl, %esi
leal -0x1(%rsi), %eax
cmpl %edx, %esi
cmovgl %edx, %eax
testl %ecx, %ecx
cmovlel %edx, %eax
negl %eax
movw %ax, 0x124(%rsp)
movq 0x30(%rsp), %rdi
movl %r13d, %ebp
movq 0xc8(%rsp), %r13
movq %r13, %rsi
leaq 0x120(%rsp), %rdx
movq 0x38(%rsp), %rcx
movl %r14d, %r8d
movq %r9, %r12
callq *0x110(%rsp)
movl %r14d, %esi
addl 0x24(%r13), %esi
movl 0x4c(%rsp), %ecx
incl %ecx
movq 0xd0(%rsp), %rdx
subq $-0x80, %rdx
movl 0x1c(%rsp), %r14d
movl %r15d, %r8d
movl %r12d, 0x10(%rsp)
movq %rbx, %r11
movl %ebp, %r13d
movl 0x18(%rsp), %ebx
movl 0xc(%rsp), %r10d
movl 0x44(%rsp), %eax
jmp 0x7449c
movq 0xc8(%rsp), %r15
movslq 0x24(%r15), %rax
movq 0x38(%rsp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, 0x38(%rsp)
movq 0xf8(%rsp), %rsi
incq %rsi
movq 0xe8(%rsp), %r13
jmp 0x7440e
movq 0x58(%rsp), %rcx
incq %rcx
addq $0x60, %r15
movq 0x30(%rsp), %rbx
jmp 0x7424d
movl 0xb8(%rbx), %eax
incl %eax
movl %eax, 0xb8(%rbx)
cmpl 0x1a4(%rbx), %eax
pushq $0x4
popq %rax
sbbl $0x0, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop