// File: /workspace/github_cpp_makefile_star2_O1/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 0x7696c
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 0x7692f
movslq 0x18(%r15), %rcx
movq %rcx, (%rsp)
cmpl 0x1c(%r15), %ecx
jge 0x76a5c
leaq 0x20(%r15), %r14
movq %r15, 0x8(%rsp)
movl 0x14(%r15), %ebp
cmpl 0x168(%rbx), %ebp
jae 0x76a37
movq (%rsp), %rax
leaq (,%rax,8), %r13
movslq 0x144(%rbx), %rax
testq %rax, %rax
jle 0x76a15
xorl %ecx, %ecx
xorl %edx, %edx
movq 0x148(%rbx,%rcx,8), %rdi
movslq 0x38(%rdi), %rsi
testq %rsi, %rsi
jle 0x76a0d
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 0x76a05
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 0x769f2
addl %r12d, %edx
incq %r10
cmpq %rsi, %r10
jne 0x769dd
incq %rcx
cmpq %rax, %rcx
jne 0x769b3
movq 0x1f0(%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x8(%rax)
testl %eax, %eax
je 0x76a6f
incl %ebp
cmpl 0x168(%rbx), %ebp
jb 0x769a3
movq 0x8(%rsp), %r15
movl $0x0, 0x14(%r15)
movq (%rsp), %rdx
incq %rdx
movslq 0x1c(%r15), %rax
movq %rdx, (%rsp)
cmpq %rax, %rdx
jl 0x76987
incl 0x10(%r15)
movq %rbx, %rdi
callq 0x75eb4
movl $0x1, %eax
jmp 0x76a80
movq 0x8(%rsp), %rax
movq (%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