// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/jpeg/jccoefct.c
// Function: compress_output
METHODDEF(jboolean)
compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
{
  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.
   * NB: during first pass, this is safe only because the buffers will
   * already be aligned properly, so jmemmgr.c won't need to do any I/O.
   */
  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],
       coef->iMCU_row_num * compptr->v_samp_factor,
       (JDIMENSION) compptr->v_samp_factor, FALSE);
  }

  /* 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 write the MCU. */
      if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
	/* Suspension forced; update state counters and exit */
	coef->MCU_vert_offset = yoffset;
	coef->mcu_ctr = MCU_col_num;
	return FALSE;
      }
    }
    /* Completed an MCU row, but perhaps not an iMCU row */
    coef->mcu_ctr = 0;
  }
  /* Completed the iMCU row, advance counters for next one */
  coef->iMCU_row_num++;
  start_iMCU_row(cinfo);
  return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movq 0x1c8(%rdi), %r15
cmpl $0x0, 0x144(%rdi)
jle 0x75a28
xorl %r14d, %r14d
movq 0x148(%rbx,%r14,8), %rax
movq 0x8(%rbx), %r9
movslq 0x4(%rax), %rcx
movq 0x70(%r15,%rcx,8), %rsi
movl 0xc(%rax), %ecx
movl 0x10(%r15), %edx
imull %ecx, %edx
movq %rbx, %rdi
xorl %r8d, %r8d
callq *0x40(%r9)
movq %rax, 0x10(%rsp,%r14,8)
incq %r14
movslq 0x144(%rbx), %rax
cmpq %rax, %r14
jl 0x759eb
movslq 0x18(%r15), %rsi
movl 0x1c(%r15), %eax
cmpl %eax, %esi
jge 0x75b1b
leaq 0x20(%r15), %r14
movl 0x14(%r15), %ebp
movl 0x168(%rbx), %ecx
movq %r15, (%rsp)
cmpl %ecx, %ebp
jae 0x75b02
movq %rsi, 0x8(%rsp)
leaq (,%rsi,8), %r13
movslq 0x144(%rbx), %rax
testq %rax, %rax
jle 0x75ad1
xorl %ecx, %ecx
xorl %edx, %edx
movq 0x148(%rbx,%rcx,8), %rdi
movslq 0x38(%rdi), %rsi
testq %rsi, %rsi
jle 0x75ac9
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 0x75ac1
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 0x75aae
addl %r12d, %edx
incq %r10
cmpq %rsi, %r10
jne 0x75a99
incq %rcx
cmpq %rax, %rcx
jne 0x75a6f
movq 0x1f0(%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x8(%rax)
testl %eax, %eax
je 0x75b2e
incl %ebp
movl 0x168(%rbx), %ecx
cmpl %ecx, %ebp
jb 0x75a5f
movq (%rsp), %r15
movl 0x1c(%r15), %eax
movq 0x8(%rsp), %rsi
movl $0x0, 0x14(%r15)
incq %rsi
movslq %eax, %rdx
xorl %ebp, %ebp
cmpq %rdx, %rsi
jl 0x75a4a
incl 0x10(%r15)
movq %rbx, %rdi
callq 0x74f5c
movl $0x1, %eax
jmp 0x75b3f
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
movl %ecx, 0x18(%rax)
movl %ebp, 0x14(%rax)
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop