// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/jpeg/jcprepct.c
// Function: pre_process_data
METHODDEF(void)
pre_process_data (j_compress_ptr cinfo,
		  JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
		  JDIMENSION in_rows_avail,
		  JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr,
		  JDIMENSION out_row_groups_avail)
{
  my_prep_ptr prep = (my_prep_ptr) cinfo->prep;
  int numrows, ci;
  JDIMENSION inrows;
  jpeg_component_info * compptr;

  while (*in_row_ctr < in_rows_avail &&
	 *out_row_group_ctr < out_row_groups_avail) {
    /* Do color conversion to fill the conversion buffer. */
    inrows = in_rows_avail - *in_row_ctr;
    numrows = cinfo->max_v_samp_factor - prep->next_buf_row;
    numrows = (int) MIN((JDIMENSION) numrows, inrows);
    (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr,
				       prep->color_buf,
				       (JDIMENSION) prep->next_buf_row,
				       numrows);
    *in_row_ctr += numrows;
    prep->next_buf_row += numrows;
    prep->rows_to_go -= numrows;
    /* If at bottom of image, pad to fill the conversion buffer. */
    if (prep->rows_to_go == 0 &&
	prep->next_buf_row < cinfo->max_v_samp_factor) {
      for (ci = 0; ci < cinfo->num_components; ci++) {
	expand_bottom_edge(prep->color_buf[ci], cinfo->image_width,
			   prep->next_buf_row, cinfo->max_v_samp_factor);
      }
      prep->next_buf_row = cinfo->max_v_samp_factor;
    }
    /* If we've filled the conversion buffer, empty it. */
    if (prep->next_buf_row == cinfo->max_v_samp_factor) {
      (*cinfo->downsample->downsample) (cinfo,
					prep->color_buf, (JDIMENSION) 0,
					output_buf, *out_row_group_ctr);
      prep->next_buf_row = 0;
      (*out_row_group_ctr)++;
    }
    /* If at bottom of image, pad the output to a full iMCU height.
     * Note we assume the caller is providing a one-iMCU-height output buffer!
     */
    if (prep->rows_to_go == 0 &&
	*out_row_group_ctr < out_row_groups_avail) {
      for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
	   ci++, compptr++) {
	expand_bottom_edge(output_buf[ci],
			   compptr->width_in_blocks * DCTSIZE,
			   (int) (*out_row_group_ctr * compptr->v_samp_factor),
			   (int) (out_row_groups_avail * compptr->v_samp_factor));
      }
      *out_row_group_ctr = out_row_groups_avail;
      break;			/* can exit outer loop without test */
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %rbx
movq %r8, (%rsp)
movl %ecx, %ebp
movq %rdx, %r12
movq %rsi, 0x10(%rsp)
movq %rdi, %r15
movq 0x1c0(%rdi), %r14
leaq 0x10(%r14), %rax
movq %rax, 0x8(%rsp)
movl (%r12), %eax
cmpl %eax, %ebp
jbe 0x6adb9
movl 0x50(%rsp), %ecx
cmpl %ecx, (%rbx)
jae 0x6adb9
movl %ebp, %edx
subl %eax, %edx
movl 0x13c(%r15), %r13d
movl 0x64(%r14), %ecx
subl %ecx, %r13d
cmpl %edx, %r13d
cmovael %edx, %r13d
movq 0x1d8(%r15), %r9
movq 0x10(%rsp), %rdx
leaq (%rdx,%rax,8), %rsi
movq %r15, %rdi
movq 0x8(%rsp), %rdx
movl %r13d, %r8d
callq *0x8(%r9)
addl %r13d, (%r12)
movl 0x64(%r14), %eax
addl %r13d, %eax
movl %eax, 0x64(%r14)
subl %r13d, 0x60(%r14)
sete %dl
movl 0x13c(%r15), %ecx
cmpl %ecx, %eax
setl %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x6ad38
xorl %r13d, %r13d
movslq 0x4c(%r15), %rax
cmpq %rax, %r13
jge 0x6ad2b
movq 0x10(%r14,%r13,8), %rdi
movl 0x64(%r14), %edx
movl 0x30(%r15), %esi
movl 0x13c(%r15), %ecx
callq 0x6adc8
incq %r13
jmp 0x6ad04
movl 0x13c(%r15), %eax
movl %eax, 0x64(%r14)
jmp 0x6ad3c
cmpl %ecx, %eax
jne 0x6ad5e
movq 0x1e0(%r15), %rax
movl (%rbx), %r8d
movq %r15, %rdi
movq 0x8(%rsp), %rsi
xorl %edx, %edx
movq (%rsp), %rcx
callq *0x8(%rax)
andl $0x0, 0x64(%r14)
incl (%rbx)
cmpl $0x0, 0x60(%r14)
jne 0x6ac85
movl 0x50(%rsp), %eax
cmpl %eax, (%rbx)
jae 0x6ac85
movq 0x58(%r15), %r14
addq $0x1c, %r14
xorl %r12d, %r12d
movslq 0x4c(%r15), %rax
cmpq %rax, %r12
jge 0x6adb3
movq (%rsp), %rax
movq (%rax,%r12,8), %rdi
movl -0x10(%r14), %ecx
movl (%r14), %esi
shll $0x3, %esi
movl (%rbx), %edx
imull %ecx, %edx
imull 0x50(%rsp), %ecx
callq 0x6adc8
incq %r12
addq $0x60, %r14
jmp 0x6ad80
movl 0x50(%rsp), %eax
movl %eax, (%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq