// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/jpeg/jdcoefct.c
// Function: consume_data
METHODDEF(int)
consume_data (j_decompress_ptr cinfo)
{
  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
  JDIMENSION MCU_col_num;	/* index of current MCU within row */
  int blkn, ci, xindex, yindex, yoffset;
  JDIMENSION start_col;
  JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
  JBLOCKROW buffer_ptr;
  jpeg_component_info *compptr;

  /* Align the virtual buffers for the components used in this scan. */
  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
    compptr = cinfo->cur_comp_info[ci];
    buffer[ci] = (*cinfo->mem->access_virt_barray)
      ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
       cinfo->input_iMCU_row * compptr->v_samp_factor,
       (JDIMENSION) compptr->v_samp_factor, TRUE);
    /* Note: entropy decoder expects buffer to be zeroed,
     * but this is handled automatically by the memory manager
     * because we requested a pre-zeroed array.
     */
  }

  /* Loop to process 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 < cinfo->MCUs_per_row;
	 MCU_col_num++) {
      /* Construct list of pointers to DCT blocks belonging to this MCU */
      blkn = 0;			/* index of current DCT block within MCU */
      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
	compptr = cinfo->cur_comp_info[ci];
	start_col = MCU_col_num * compptr->MCU_width;
	for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
	  buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
	  for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
	    coef->MCU_buffer[blkn++] = buffer_ptr++;
	  }
	}
      }
      /* Try to fetch the MCU. */
      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;
      }
    }
    /* Completed an MCU row, but perhaps not an iMCU row */
    coef->MCU_ctr = 0;
  }
  /* Completed the iMCU row, advance counters for next one */
  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 $0x38, %rsp
movq %rdi, %rbx
movq 0x230(%rdi), %r15
cmpl $0x0, 0x1b0(%rdi)
jle 0x80ecc
xorl %r14d, %r14d
movq 0x1b8(%rbx,%r14,8), %rax
movq 0x8(%rbx), %r9
movslq 0x4(%rax), %rcx
movq 0x88(%r15,%rcx,8), %rsi
movl 0xc(%rax), %ecx
movl 0xb0(%rbx), %edx
imull %ecx, %edx
movq %rbx, %rdi
movl $0x1, %r8d
callq *0x40(%r9)
movq %rax, 0x10(%rsp,%r14,8)
incq %r14
movslq 0x1b0(%rbx), %rax
cmpq %rax, %r14
jl 0x80e87
movslq 0x2c(%r15), %rcx
movq %rcx, (%rsp)
cmpl 0x30(%r15), %ecx
jge 0x80fbc
leaq 0x38(%r15), %r14
movq %r15, 0x8(%rsp)
movl 0x28(%r15), %ebp
cmpl 0x1d8(%rbx), %ebp
jae 0x80f97
movq (%rsp), %rax
leaq (,%rax,8), %r13
movslq 0x1b0(%rbx), %rax
testq %rax, %rax
jle 0x80f75
xorl %ecx, %ecx
xorl %edx, %edx
movq 0x1b8(%rbx,%rcx,8), %rdi
movslq 0x38(%rdi), %rsi
testq %rsi, %rsi
jle 0x80f6d
movl 0x34(%rdi), %edi
movl %edi, %r8d
imull %ebp, %r8d
movq 0x10(%rsp,%rcx,8), %r9
addq %r13, %r9
shlq $0x7, %r8
xorl %r10d, %r10d
testl %edi, %edi
jle 0x80f65
movq (%r9,%r10,8), %r11
addq %r8, %r11
movslq %edx, %r15
leaq (%r14,%r15,8), %r15
xorl %r12d, %r12d
movq %r11, (%r15,%r12,8)
subq $-0x80, %r11
incq %r12
cmpl %r12d, %edi
jne 0x80f52
addl %r12d, %edx
incq %r10
cmpq %rsi, %r10
jne 0x80f3d
incq %rcx
cmpq %rax, %rcx
jne 0x80f13
movq 0x250(%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x8(%rax)
testl %eax, %eax
je 0x80fe1
incl %ebp
cmpl 0x1d8(%rbx), %ebp
jb 0x80f03
movq 0x8(%rsp), %r15
movl $0x0, 0x28(%r15)
movq (%rsp), %rdx
incq %rdx
movslq 0x30(%r15), %rax
movq %rdx, (%rsp)
cmpq %rax, %rdx
jl 0x80ee7
movl 0xb0(%rbx), %eax
incl %eax
movl %eax, 0xb0(%rbx)
cmpl 0x1a4(%rbx), %eax
jae 0x80ff4
movq %rbx, %rdi
callq 0x8146c
movl $0x3, %eax
jmp 0x81006
movq 0x8(%rsp), %rax
movq (%rsp), %rcx
movl %ecx, 0x2c(%rax)
movl %ebp, 0x28(%rax)
xorl %eax, %eax
jmp 0x81006
movq 0x240(%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
movl $0x4, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq