// File: /workspace/github_cpp_makefile_star2_O2/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
xorl %r14d, %r14d
movslq 0x144(%rbx), %rax
cmpq %rax, %r14
jge 0x6b4a4
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
jmp 0x6b465
movslq 0x18(%r15), %r12
leaq 0x20(%r15), %r14
movq %r15, 0x8(%rsp)
movslq 0x1c(%r15), %rax
cmpq %rax, %r12
jge 0x6b5a1
movl 0x14(%r15), %ebp
cmpl 0x168(%rbx), %ebp
jae 0x6b572
movl 0x144(%rbx), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
xorl %edx, %edx
cmpq %rax, %rcx
je 0x6b557
movq 0x148(%rbx,%rcx,8), %r8
movl 0x34(%r8), %esi
movl %esi, %edi
imull %ebp, %edi
testl %esi, %esi
movl $0x0, %r9d
cmovlel %r9d, %esi
movl 0x38(%r8), %r8d
testl %r8d, %r8d
cmovlel %r9d, %r8d
leal (%rdx,%rsi), %r9d
shlq $0x7, %rdi
xorl %r10d, %r10d
cmpq %r8, %r10
je 0x6b552
movslq %r9d, %r11
leaq (,%r10,8), %r15
addq 0x10(%rsp,%rcx,8), %r15
movq (%r15,%r12,8), %r15
addq %rdi, %r15
movslq %edx, %r13
leal (%rsi,%r13), %edx
cmpq %r13, %r11
je 0x6b54a
movq %r15, (%r14,%r13,8)
incq %r13
subq $-0x80, %r15
jmp 0x6b538
incq %r10
addl %esi, %r9d
jmp 0x6b515
incq %rcx
jmp 0x6b4dd
movq 0x1f0(%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x8(%rax)
testl %eax, %eax
je 0x6b584
incl %ebp
jmp 0x6b4c2
movq 0x8(%rsp), %r15
andl $0x0, 0x14(%r15)
incq %r12
jmp 0x6b4b1
movq 0x8(%rsp), %rax
movl %r12d, 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
incl 0x10(%r15)
movq %rbx, %rdi
callq 0x6af88
pushq $0x1
popq %rax
jmp 0x6b592
nop