// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/jpeg/jdcoefct.c
// Function: decompress_data
METHODDEF(int)
decompress_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;
  int ci, block_row, block_rows;
  JBLOCKARRAY buffer;
  JBLOCKROW buffer_ptr;
  JSAMPARRAY output_ptr;
  JDIMENSION output_col;
  jpeg_component_info *compptr;
  inverse_DCT_method_ptr inverse_DCT;

  /* Force some input to be done if we are getting ahead of the input. */
  while (cinfo->input_scan_number < cinfo->output_scan_number ||
	 (cinfo->input_scan_number == cinfo->output_scan_number &&
	  cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {
    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;
    /* Align the virtual buffer for this component. */
    buffer = (*cinfo->mem->access_virt_barray)
      ((j_common_ptr) cinfo, coef->whole_image[ci],
       cinfo->output_iMCU_row * compptr->v_samp_factor,
       (JDIMENSION) compptr->v_samp_factor, FALSE);
    /* Count non-dummy DCT block rows in this iMCU row. */
    if (cinfo->output_iMCU_row < last_iMCU_row)
      block_rows = compptr->v_samp_factor;
    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;
    }
    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];
      output_col = 0;
      for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) {
	(*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr,
			output_ptr, output_col);
	buffer_ptr++;
	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 $0x48, %rsp
movq %rsi, 0x20(%rsp)
movq %rdi, %rbx
movq 0x230(%rdi), %rax
movq %rax, 0x28(%rsp)
movl 0x1a4(%rdi), %eax
decl %eax
movl %eax, 0x1c(%rsp)
movl 0xb4(%rbx), %eax
cmpl %eax, 0xac(%rbx)
jl 0x81061
jne 0x81078
movl 0xb0(%rbx), %eax
cmpl 0xb8(%rbx), %eax
ja 0x81078
movq 0x240(%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
testl %eax, %eax
jne 0x81043
xorl %eax, %eax
jmp 0x811d9
cmpl $0x0, 0x38(%rbx)
jle 0x811bd
movq 0x130(%rbx), %r13
movq $0x0, (%rsp)
movq %rbx, 0x8(%rsp)
movq 0x8(%rsp), %r15
cmpl $0x0, 0x30(%r13)
je 0x8119c
movq 0x8(%rsp), %rbx
movq 0x8(%rbx), %rax
movq 0x28(%rsp), %rcx
movq (%rsp), %rdx
movq 0x88(%rcx,%rdx,8), %rsi
movl 0xc(%r13), %ecx
movl 0xb8(%rbx), %edx
imull %ecx, %edx
movq %rbx, %rdi
xorl %r8d, %r8d
callq *0x40(%rax)
movq %rax, 0x30(%rsp)
movl 0x1c(%rsp), %eax
cmpl %eax, 0xb8(%rbx)
jae 0x810ed
movl 0xc(%r13), %edx
jmp 0x810fe
movl 0xc(%r13), %ecx
movl 0x20(%r13), %eax
xorl %edx, %edx
divl %ecx
testl %edx, %edx
cmovel %ecx, %edx
testl %edx, %edx
jle 0x8119c
movq 0x8(%rsp), %rax
movq 0x258(%rax), %rax
movq (%rsp), %rcx
movq 0x8(%rax,%rcx,8), %r9
movq 0x20(%rsp), %rax
movq (%rax,%rcx,8), %r12
movl %edx, %eax
movq %rax, 0x38(%rsp)
movq $0x0, 0x10(%rsp)
movq %r13, 0x40(%rsp)
cmpl $0x0, 0x1c(%r13)
je 0x81180
movq 0x30(%rsp), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rbp
xorl %r14d, %r14d
xorl %ebx, %ebx
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %rcx
movl %r14d, %r8d
movq %r9, %r13
callq *%r9
movq %r13, %r9
movq 0x40(%rsp), %r13
addl 0x24(%r13), %r14d
subq $-0x80, %rbp
incl %ebx
cmpl 0x1c(%r13), %ebx
jb 0x81153
movslq 0x24(%r13), %rax
leaq (%r12,%rax,8), %r12
movq 0x10(%rsp), %rcx
incq %rcx
movq %rcx, 0x10(%rsp)
cmpq 0x38(%rsp), %rcx
jne 0x81139
movq (%rsp), %rdx
incq %rdx
addq $0x60, %r13
movq 0x8(%rsp), %rbx
movslq 0x38(%rbx), %rax
movq %rdx, (%rsp)
cmpq %rax, %rdx
jl 0x8109b
movl 0xb8(%rbx), %eax
incl %eax
movl %eax, 0xb8(%rbx)
cmpl 0x1a4(%rbx), %eax
movl $0x4, %eax
sbbl $0x0, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq