// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/jpeg/jdcoefct.c
// Function: decompress_onepass
METHODDEF(int)
decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
{
  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
  JDIMENSION MCU_col_num;	/* index of current MCU within row */
  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
  int blkn, ci, xindex, yindex, yoffset, useful_width;
  JSAMPARRAY output_ptr;
  JDIMENSION start_col, output_col;
  jpeg_component_info *compptr;
  inverse_DCT_method_ptr inverse_DCT;

  /* Loop to process as much as one whole iMCU row */
  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
       yoffset++) {
    for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
	 MCU_col_num++) {
      /* Try to fetch an MCU.  Entropy decoder expects buffer to be zeroed. */
      jzero_far((void FAR *) coef->MCU_buffer[0],
		(size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK)));
      if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
	/* Suspension forced; update state counters and exit */
	coef->MCU_vert_offset = yoffset;
	coef->MCU_ctr = MCU_col_num;
	return JPEG_SUSPENDED;
      }
      /* Determine where data should go in output_buf and do the IDCT thing.
       * We skip dummy blocks at the right and bottom edges (but blkn gets
       * incremented past them!).  Note the inner loop relies on having
       * allocated the MCU_buffer[] blocks sequentially.
       */
      blkn = 0;			/* index of current DCT block within MCU */
      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
	compptr = cinfo->cur_comp_info[ci];
	/* Don't bother to IDCT an uninteresting component. */
	if (! compptr->component_needed) {
	  blkn += compptr->MCU_blocks;
	  continue;
	}
	inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index];
	useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
						    : compptr->last_col_width;
	output_ptr = output_buf[compptr->component_index] +
	  yoffset * compptr->DCT_scaled_size;
	start_col = MCU_col_num * compptr->MCU_sample_width;
	for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
	  if (cinfo->input_iMCU_row < last_iMCU_row ||
	      yoffset+yindex < compptr->last_row_height) {
	    output_col = start_col;
	    for (xindex = 0; xindex < useful_width; xindex++) {
	      (*inverse_DCT) (cinfo, compptr,
			      (JCOEFPTR) coef->MCU_buffer[blkn+xindex],
			      output_ptr, output_col);
	      output_col += compptr->DCT_scaled_size;
	    }
	  }
	  blkn += compptr->MCU_width;
	  output_ptr += compptr->DCT_scaled_size;
	}
      }
    }
    /* Completed an MCU row, but perhaps not an iMCU row */
    coef->MCU_ctr = 0;
  }
  /* Completed the iMCU row, advance counters for next one */
  cinfo->output_iMCU_row++;
  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
    start_iMCU_row(cinfo);
    return JPEG_ROW_COMPLETED;
  }
  /* Completed the scan */
  (*cinfo->inputctl->finish_input_pass) (cinfo);
  return JPEG_SCAN_COMPLETED;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, 0x40(%rsp)
movq %rdi, %rbx
movq 0x230(%rdi), %rcx
movl 0x1a4(%rdi), %ebp
movl 0x2c(%rcx), %esi
movl 0x30(%rcx), %eax
movq %rsi, 0x10(%rsp)
cmpl %eax, %esi
jge 0x80603
movl 0x1d8(%rbx), %edx
decl %edx
movl %edx, 0xc(%rsp)
decl %ebp
leaq 0x38(%rcx), %rdx
movq %rdx, 0x38(%rsp)
movl 0x28(%rcx), %r15d
movl %ebp, 0x24(%rsp)
movq %rcx, 0x30(%rsp)
cmpl 0xc(%rsp), %r15d
ja 0x805df
movq 0x38(%rsp), %r14
movq (%r14), %rdi
movslq 0x1e0(%rbx), %rsi
shlq $0x7, %rsi
callq 0x85d17
movq 0x250(%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x8(%rax)
testl %eax, %eax
je 0x8062a
movl 0x1b0(%rbx), %ecx
testl %ecx, %ecx
jle 0x805c9
xorl %edx, %edx
xorl %edi, %edi
movl %r15d, 0x20(%rsp)
movq 0x1b8(%rbx,%rdx,8), %r12
cmpl $0x0, 0x30(%r12)
je 0x805b5
movl 0x38(%r12), %eax
testl %eax, %eax
jle 0x805ba
movq %rdx, 0x48(%rsp)
movq 0x258(%rbx), %rcx
movslq 0x4(%r12), %rdx
movq 0x8(%rcx,%rdx,8), %r13
movl 0x40(%r12), %ecx
imull %r15d, %ecx
movl %ecx, 0x28(%rsp)
xorl %ecx, %ecx
cmpl 0xc(%rsp), %r15d
setae %cl
shll $0x4, %ecx
movl 0x34(%rcx,%r12), %r10d
movl 0x24(%r12), %ecx
movl %ecx, %esi
imull 0x10(%rsp), %esi
movslq %esi, %r11
shlq $0x3, %r11
movq 0x40(%rsp), %rsi
addq (%rsi,%rdx,8), %r11
cmpl $0x2, %r10d
movl $0x1, %esi
movl %r10d, 0x1c(%rsp)
cmovgel %r10d, %esi
xorl %r10d, %r10d
movq %rsi, 0x58(%rsp)
cmpl %ebp, 0xb0(%rbx)
jb 0x80513
movq 0x10(%rsp), %rdx
addl %r10d, %edx
cmpl 0x48(%r12), %edx
jge 0x8058b
cmpl $0x0, 0x1c(%rsp)
jle 0x8058b
movq %r10, 0x50(%rsp)
movl %edi, 0x2c(%rsp)
movslq %edi, %rax
movq 0x38(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, 0x60(%rsp)
xorl %r14d, %r14d
movl 0x28(%rsp), %ebp
movq 0x60(%rsp), %rax
movq (%rax,%r14,8), %rdx
movq %rbx, %rdi
movq %r12, %rsi
movq %r11, %rcx
movq %rbx, %r15
movl %ebp, %r8d
movq %r12, %rbx
movq %r11, %r12
callq *%r13
movq 0x58(%rsp), %rsi
movq %r12, %r11
movq %rbx, %r12
movq %r15, %rbx
movl 0x24(%r12), %ecx
addl %ecx, %ebp
incq %r14
cmpq %r14, %rsi
jne 0x8053b
movl 0x38(%r12), %eax
movl 0x24(%rsp), %ebp
movl 0x2c(%rsp), %edi
movq 0x50(%rsp), %r10
addl 0x34(%r12), %edi
movslq %ecx, %rdx
leaq (%r11,%rdx,8), %r11
incl %r10d
cmpl %eax, %r10d
jl 0x804fc
movl 0x1b0(%rbx), %ecx
movl 0x20(%rsp), %r15d
movq 0x48(%rsp), %rdx
jmp 0x805ba
addl 0x3c(%r12), %edi
incq %rdx
movslq %ecx, %rax
cmpq %rax, %rdx
jl 0x80470
incl %r15d
cmpl 0xc(%rsp), %r15d
jbe 0x80429
movq 0x30(%rsp), %rcx
movl 0x30(%rcx), %eax
movl $0x0, 0x28(%rcx)
movq 0x10(%rsp), %rsi
incl %esi
xorl %r15d, %r15d
movq %rsi, 0x10(%rsp)
cmpl %eax, %esi
jl 0x8041e
movl 0x1a4(%rbx), %ebp
incl 0xb8(%rbx)
movl 0xb0(%rbx), %eax
incl %eax
movl %eax, 0xb0(%rbx)
cmpl %ebp, %eax
jae 0x8063f
movq %rbx, %rdi
callq 0x80660
movl $0x3, %eax
jmp 0x80651
movq 0x30(%rsp), %rax
movq 0x10(%rsp), %rcx
movl %ecx, 0x2c(%rax)
movl %r15d, 0x28(%rax)
xorl %eax, %eax
jmp 0x80651
movq 0x240(%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
movl $0x4, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq