// File: /workspace/github_cpp_makefile_star2_O1/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, %r15
movq 0x230(%rdi), %rax
movl 0x2c(%rax), %edx
movq %rdx, 0x10(%rsp)
cmpl 0x30(%rax), %edx
jge 0x81404
movl 0x1a4(%r15), %ecx
movl 0x1d8(%r15), %edx
decl %edx
movl %edx, 0xc(%rsp)
decl %ecx
movl %ecx, 0x24(%rsp)
leaq 0x38(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq %rax, 0x28(%rsp)
movl 0x28(%rax), %eax
movl %eax, 0x8(%rsp)
cmpl 0xc(%rsp), %eax
ja 0x813e3
movslq 0x10(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x30(%rsp), %r14
movq (%r14), %rdi
movslq 0x1e0(%r15), %rsi
shlq $0x7, %rsi
callq 0x86b1f
movq 0x250(%r15), %rax
movq %r15, %rdi
movq %r14, %rsi
callq *0x8(%rax)
testl %eax, %eax
je 0x81433
cmpl $0x0, 0x1b0(%r15)
jle 0x813cf
xorl %ecx, %ecx
movl $0x0, 0x4(%rsp)
movq 0x1b8(%r15,%rcx,8), %rbx
cmpl $0x0, 0x30(%rbx)
movq %rcx, 0x48(%rsp)
je 0x813ac
cmpl $0x0, 0x38(%rbx)
jle 0x813b7
movq 0x258(%r15), %rax
movslq 0x4(%rbx), %rcx
movq 0x8(%rax,%rcx,8), %r13
movl 0x40(%rbx), %eax
movl 0x8(%rsp), %edx
imull %edx, %eax
movl %eax, 0x20(%rsp)
xorl %eax, %eax
cmpl 0xc(%rsp), %edx
setae %al
shll $0x4, %eax
movl 0x34(%rax,%rbx), %edx
movslq 0x24(%rbx), %r12
imulq 0x38(%rsp), %r12
shlq $0x3, %r12
movq 0x40(%rsp), %rax
addq (%rax,%rcx,8), %r12
cmpl $0x2, %edx
movl $0x1, %edi
movl %edx, 0x1c(%rsp)
cmovgel %edx, %edi
xorl %ecx, %ecx
movq %rdi, 0x58(%rsp)
movl 0x24(%rsp), %eax
cmpl %eax, 0xb0(%r15)
movq %rcx, 0x50(%rsp)
jb 0x8133e
movq 0x10(%rsp), %rax
addl %ecx, %eax
cmpl 0x48(%rbx), %eax
jge 0x81387
cmpl $0x0, 0x1c(%rsp)
jle 0x81387
movslq 0x4(%rsp), %rax
movq 0x30(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, 0x60(%rsp)
xorl %r14d, %r14d
movl 0x20(%rsp), %ebp
movq 0x60(%rsp), %rax
movq (%rax,%r14,8), %rdx
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rcx
movl %ebp, %r8d
callq *%r13
movq 0x58(%rsp), %rdi
addl 0x24(%rbx), %ebp
incq %r14
cmpq %r14, %rdi
jne 0x8135f
movl 0x4(%rsp), %eax
addl 0x34(%rbx), %eax
movl %eax, 0x4(%rsp)
movslq 0x24(%rbx), %rax
leaq (%r12,%rax,8), %r12
movq 0x50(%rsp), %rcx
incl %ecx
cmpl 0x38(%rbx), %ecx
jl 0x81320
jmp 0x813b7
movl 0x4(%rsp), %eax
addl 0x3c(%rbx), %eax
movl %eax, 0x4(%rsp)
movq 0x48(%rsp), %rcx
incq %rcx
movslq 0x1b0(%r15), %rax
cmpq %rax, %rcx
jl 0x812a4
movl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x8(%rsp)
cmpl 0xc(%rsp), %eax
jbe 0x8125c
movq 0x28(%rsp), %rax
movl $0x0, 0x28(%rax)
movq 0x10(%rsp), %rdx
incl %edx
movq %rdx, 0x10(%rsp)
cmpl 0x30(%rax), %edx
jl 0x81241
incl 0xb8(%r15)
movl 0xb0(%r15), %eax
incl %eax
movl %eax, 0xb0(%r15)
cmpl 0x1a4(%r15), %eax
jae 0x8144b
movq %r15, %rdi
callq 0x8146c
movl $0x3, %eax
jmp 0x8145d
movq 0x28(%rsp), %rax
movq 0x10(%rsp), %rcx
movl %ecx, 0x2c(%rax)
movl 0x8(%rsp), %ecx
movl %ecx, 0x28(%rax)
xorl %eax, %eax
jmp 0x8145d
movq 0x240(%r15), %rax
movq %r15, %rdi
callq *0x18(%rax)
movl $0x4, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq