// File: /workspace/github_cpp_makefile_star2_O1/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 $0x1b8, %rsp            # imm = 0x1B8
movq %rsi, 0xc8(%rsp)
movq 0x230(%rdi), %rax
movq %rax, 0x40(%rsp)
movl 0x1a4(%rdi), %eax
decl %eax
movl %eax, 0x2c(%rsp)
movl 0xac(%rdi), %ecx
movl 0xb4(%rdi), %edx
cmpl %edx, %ecx
jg 0x8152d
movq 0x240(%rdi), %rax
cmpl $0x0, 0x24(%rax)
jne 0x8152d
cmpl %edx, %ecx
jne 0x8151a
movl 0xb8(%rdi), %ecx
cmpl $0x1, 0x20c(%rdi)
adcl $0x0, %ecx
cmpl %ecx, 0xb0(%rdi)
ja 0x8152d
movq %rdi, %rbx
callq *(%rax)
movq %rbx, %rdi
testl %eax, %eax
jne 0x814e1
xorl %eax, %eax
jmp 0x81c07
cmpl $0x0, 0x38(%rdi)
jle 0x81beb
movq 0x130(%rdi), %r14
movq $0x0, 0x20(%rsp)
movq %rdi, 0x108(%rsp)
cmpl $0x0, 0x30(%r14)
je 0x81bcd
movl 0xb8(%rdi), %r13d
cmpl 0x2c(%rsp), %r13d
jb 0x8157f
movl 0xc(%r14), %esi
movl 0x20(%r14), %eax
xorl %edx, %edx
divl %esi
movl %edx, %ecx
testl %edx, %edx
cmovel %esi, %ecx
movl %ecx, %ebx
jmp 0x81586
movl 0xc(%r14), %ebx
leal (%rbx,%rbx), %ecx
testl %r13d, %r13d
movq %rdi, %r15
je 0x815c2
movl 0xc(%r14), %eax
addl %eax, %ecx
movq 0x8(%rdi), %r9
movq 0x40(%rsp), %rdx
movq 0x20(%rsp), %rsi
movq 0x88(%rdx,%rsi,8), %rsi
leal -0x1(%r13), %edx
imull %eax, %edx
xorl %r8d, %r8d
callq *0x40(%r9)
movslq 0xc(%r14), %rcx
leaq (%rax,%rcx,8), %rsi
jmp 0x815e3
movq 0x8(%rdi), %rax
movq 0x40(%rsp), %rdx
movq 0x20(%rsp), %rsi
movq 0x88(%rdx,%rsi,8), %rsi
xorl %edx, %edx
xorl %r8d, %r8d
callq *0x40(%rax)
movq %rax, %rsi
testl %ebx, %ebx
leaq 0x130(%rsp), %r12
movq %r15, %rdi
jle 0x81bcd
movq 0x258(%rdi), %rax
movq 0x20(%rsp), %rdx
movq 0x8(%rax,%rdx,8), %rax
movq %rax, 0x120(%rsp)
leaq (,%rdx,8), %rcx
movq 0x50(%r14), %rax
movzwl 0x4(%rax), %edi
movzwl 0x12(%rax), %r8d
movzwl 0x20(%rax), %r9d
movzwl 0x10(%rax), %r10d
movzwl 0x2(%rax), %r11d
movzwl (%rax), %eax
leaq (%rcx,%rcx,2), %rcx
movq %rcx, 0x118(%rsp)
leal (,%rax,4), %ecx
leaq (%rcx,%rcx,8), %rcx
movq %rcx, 0xb8(%rsp)
movl %r11d, %ecx
shll $0x7, %ecx
movq %rcx, 0x80(%rsp)
shll $0x8, %r11d
movq %r11, 0x88(%rsp)
movl %r10d, %ecx
shll $0x7, %ecx
movq %rcx, 0x78(%rsp)
shll $0x8, %r10d
movq %r10, 0x90(%rsp)
leaq (%rax,%rax,8), %rcx
movq %rcx, 0xb0(%rsp)
movl %r9d, %ecx
shll $0x7, %ecx
movq %rcx, 0x70(%rsp)
shll $0x8, %r9d
movq %r9, 0x98(%rsp)
leaq (%rax,%rax,4), %rax
movq %rax, 0xf8(%rsp)
movl %r8d, %eax
shll $0x7, %eax
movq %rax, 0x68(%rsp)
shll $0x8, %r8d
movq %r8, 0xa0(%rsp)
movl %edi, %eax
shll $0x7, %eax
movq %rax, 0x60(%rsp)
shll $0x8, %edi
movq %rdi, 0xa8(%rsp)
leal -0x1(%rbx), %eax
movq %rax, 0xd0(%rsp)
movl %ebx, %eax
movq %rax, 0xd8(%rsp)
movq 0xc8(%rsp), %rax
movq (%rax,%rdx,8), %rax
movq %rax, 0x50(%rsp)
movq 0x40(%rsp), %rax
movq 0xd8(%rax), %rax
movq %rax, 0x110(%rsp)
xorl %ecx, %ecx
movq %r14, 0xc0(%rsp)
movq %r13, 0xe8(%rsp)
movq %rsi, 0xe0(%rsp)
movq (%rsi,%rcx,8), %rdx
movl %r13d, %eax
orl %ecx, %eax
movq %rdx, 0x38(%rsp)
movq %rdx, 0x48(%rsp)
je 0x81754
movq -0x8(%rsi,%rcx,8), %rax
movq %rax, 0x48(%rsp)
cmpl 0x2c(%rsp), %r13d
jb 0x8176a
movq 0x38(%rsp), %rdx
cmpq 0xd0(%rsp), %rcx
je 0x8176f
movq 0x8(%rsi,%rcx,8), %rdx
movq %rcx, 0xf0(%rsp)
movq 0x48(%rsp), %rax
movswl (%rax), %ecx
movq 0x38(%rsp), %rax
movswl (%rax), %esi
movq %rdx, 0x100(%rsp)
movswl (%rdx), %edx
movl 0x1c(%r14), %eax
decl %eax
xorl %ebp, %ebp
movl %edx, 0x18(%rsp)
movl %edx, 0x10(%rsp)
movl %esi, %r14d
movl %ecx, 0x1c(%rsp)
movl %ecx, 0xc(%rsp)
xorl %r13d, %r13d
xorl %r15d, %r15d
movl %eax, 0x5c(%rsp)
movl %r15d, 0x34(%rsp)
movl 0xc(%rsp), %ebx
movl 0x1c(%rsp), %ecx
movl %ecx, 0xc(%rsp)
movl %r14d, 0x30(%rsp)
movl %esi, %r14d
movl 0x10(%rsp), %ecx
movl %ecx, 0x14(%rsp)
movl 0x18(%rsp), %ecx
movl %ecx, 0x10(%rsp)
movl %eax, %r15d
movq 0x38(%rsp), %rax
leaq (%rax,%rbp), %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x86b0b
movl %r14d, %r10d
cmpl %r15d, %r13d
jae 0x81834
movq 0x48(%rsp), %rax
movswl 0x80(%rax,%rbp), %eax
movl %eax, 0x1c(%rsp)
movq 0x38(%rsp), %rax
movswl 0x80(%rax,%rbp), %r10d
movq 0x100(%rsp), %rax
movswl 0x80(%rax,%rbp), %eax
movl %eax, 0x18(%rsp)
movq 0x118(%rsp), %rdi
movq 0x110(%rsp), %r8
movl 0x4(%r8,%rdi), %ecx
testl %ecx, %ecx
je 0x818d5
cmpw $0x0, 0x132(%rsp)
jne 0x818d5
movl 0x30(%rsp), %eax
subl %r10d, %eax
cltq
imulq 0xb8(%rsp), %rax
testq %rax, %rax
js 0x8189c
addq 0x80(%rsp), %rax
xorl %edx, %edx
divq 0x88(%rsp)
testl %ecx, %ecx
jle 0x818cd
movl $0x1, %edx
shll %cl, %edx
leal -0x1(%rdx), %ecx
cmpl %eax, %edx
cmovgl %eax, %ecx
movl %ecx, %eax
jmp 0x818cd
movq 0x80(%rsp), %rdx
subq %rax, %rdx
movq %rdx, %rax
xorl %edx, %edx
divq 0x88(%rsp)
movq %rax, %rdx
movl $0x1, %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 0x8(%r8,%rdi), %ecx
testl %ecx, %ecx
je 0x8195d
cmpw $0x0, 0x140(%rsp)
jne 0x8195d
movl 0xc(%rsp), %eax
subl 0x10(%rsp), %eax
cltq
imulq 0xb8(%rsp), %rax
testq %rax, %rax
js 0x81927
addq 0x78(%rsp), %rax
xorl %edx, %edx
divq 0x90(%rsp)
testl %ecx, %ecx
jle 0x81955
movl $0x1, %edx
shll %cl, %edx
leal -0x1(%rdx), %ecx
cmpl %eax, %edx
cmovgl %eax, %ecx
movl %ecx, %eax
jmp 0x81955
movq 0x78(%rsp), %rdx
subq %rax, %rdx
movq %rdx, %rax
xorl %edx, %edx
divq 0x90(%rsp)
movq %rax, %rdx
movl $0x1, %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 0xc(%r8,%rdi), %ecx
testl %ecx, %ecx
je 0x819f0
cmpw $0x0, 0x150(%rsp)
jne 0x819f0
movl 0xc(%rsp), %edx
subl %r14d, %edx
subl %r14d, %edx
addl 0x10(%rsp), %edx
movslq %edx, %rax
imulq 0xb0(%rsp), %rax
testq %rax, %rax
js 0x819ba
addq 0x70(%rsp), %rax
xorl %edx, %edx
divq 0x98(%rsp)
testl %ecx, %ecx
jle 0x819e8
movl $0x1, %edx
shll %cl, %edx
leal -0x1(%rdx), %ecx
cmpl %eax, %edx
cmovgl %eax, %ecx
movl %ecx, %eax
jmp 0x819e8
movq 0x70(%rsp), %rdx
subq %rax, %rdx
movq %rdx, %rax
xorl %edx, %edx
divq 0x98(%rsp)
movq %rax, %rdx
movl $0x1, %esi
shll %cl, %esi
leal -0x1(%rsi), %eax
cmpl %edx, %esi
cmovgl %edx, %eax
testl %ecx, %ecx
cmovlel %edx, %eax
negl %eax
movw %ax, 0x150(%rsp)
movl 0x10(%r8,%rdi), %ecx
testl %ecx, %ecx
je 0x81a83
cmpw $0x0, 0x142(%rsp)
jne 0x81a83
movl 0x14(%rsp), %eax
addl 0x1c(%rsp), %eax
subl %eax, %ebx
addl 0x18(%rsp), %ebx
movslq %ebx, %rax
imulq 0xf8(%rsp), %rax
testq %rax, %rax
js 0x81a4d
addq 0x68(%rsp), %rax
xorl %edx, %edx
divq 0xa0(%rsp)
testl %ecx, %ecx
jle 0x81a7b
movl $0x1, %edx
shll %cl, %edx
leal -0x1(%rdx), %ecx
cmpl %eax, %edx
cmovgl %eax, %ecx
movl %ecx, %eax
jmp 0x81a7b
movq 0x68(%rsp), %rdx
subq %rax, %rdx
movq %rdx, %rax
xorl %edx, %edx
divq 0xa0(%rsp)
movq %rax, %rdx
movl $0x1, %esi
shll %cl, %esi
leal -0x1(%rsi), %eax
cmpl %edx, %esi
cmovgl %edx, %eax
testl %ecx, %ecx
cmovlel %edx, %eax
negl %eax
movw %ax, 0x142(%rsp)
movq %rbp, 0x128(%rsp)
movl %r13d, 0x14(%rsp)
movl 0x14(%r8,%rdi), %ecx
testl %ecx, %ecx
movl 0x34(%rsp), %r15d
je 0x81b2c
cmpw $0x0, 0x134(%rsp)
jne 0x81b2c
movl 0x30(%rsp), %edx
subl %r14d, %edx
subl %r14d, %edx
addl %r10d, %edx
movslq %edx, %rax
imulq 0xb0(%rsp), %rax
testq %rax, %rax
js 0x81af1
addq 0x60(%rsp), %rax
xorl %edx, %edx
divq 0xa8(%rsp)
testl %ecx, %ecx
jle 0x81b1f
movl $0x1, %edx
shll %cl, %edx
leal -0x1(%rdx), %ecx
cmpl %eax, %edx
cmovgl %eax, %ecx
movl %ecx, %eax
jmp 0x81b1f
movq 0x60(%rsp), %rdx
subq %rax, %rdx
movq %rdx, %rax
xorl %edx, %edx
divq 0xa8(%rsp)
movq %rax, %rdx
movl $0x1, %esi
shll %cl, %esi
leal -0x1(%rsi), %eax
cmpl %edx, %esi
cmovgl %edx, %eax
testl %ecx, %ecx
cmovlel %edx, %eax
negl %eax
movw %ax, 0x134(%rsp)
movl 0x34(%rsp), %r15d
movq 0x108(%rsp), %rbp
movq %rbp, %rdi
movq 0xc0(%rsp), %rbx
movq %rbx, %rsi
leaq 0x130(%rsp), %r12
movq %r12, %rdx
movq 0x50(%rsp), %rcx
movl %r15d, %r8d
movl %r10d, %r13d
callq *0x120(%rsp)
movq %rbp, %rdi
movl %r13d, %esi
addl 0x24(%rbx), %r15d
movl 0x14(%rsp), %r13d
incl %r13d
movq 0x128(%rsp), %rbp
subq $-0x80, %rbp
movl 0x5c(%rsp), %eax
cmpl %eax, %r13d
jbe 0x817b7
movq 0xc0(%rsp), %r14
movslq 0x24(%r14), %rax
movq 0x50(%rsp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, 0x50(%rsp)
movq 0xf0(%rsp), %rcx
incq %rcx
cmpq 0xd8(%rsp), %rcx
movq 0xe8(%rsp), %r13
movq 0xe0(%rsp), %rsi
jne 0x81735
movq 0x20(%rsp), %rdx
incq %rdx
addq $0x60, %r14
movslq 0x38(%rdi), %rax
movq %rdx, 0x20(%rsp)
cmpq %rax, %rdx
jl 0x8154f
movl 0xb8(%rdi), %eax
incl %eax
movl %eax, 0xb8(%rdi)
cmpl 0x1a4(%rdi), %eax
movl $0x4, %eax
sbbl $0x0, %eax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)