// File: /workspace/github_cpp_makefile_star2_O3/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 $0x48, %rsp
movq %rsi, 0x40(%rsp)
movq %rdx, 0x30(%rsp)
movl (%rdx), %eax
cmpl %ecx, %eax
jae 0x74d9a
movq %r9, %r12
movq %r8, %r13
movl %ecx, %r15d
movq %rdi, %rbp
movl 0x80(%rsp), %r14d
movq 0x1c0(%rdi), %rbx
leaq 0x10(%rbx), %rcx
movq %rcx, 0x28(%rsp)
movq %r9, 0x20(%rsp)
movq %r8, 0x18(%rsp)
movq %rdi, 0x38(%rsp)
movl %r15d, 0x14(%rsp)
movq %rbx, 0x8(%rsp)
cmpl %r14d, (%r12)
jae 0x74d9a
movl %r15d, %edx
subl %eax, %edx
movl 0x13c(%rbp), %ebx
movq 0x8(%rsp), %rcx
movl 0x64(%rcx), %ecx
subl %ecx, %ebx
cmpl %edx, %ebx
cmovael %edx, %ebx
movq 0x1d8(%rbp), %r9
movl %eax, %eax
movq 0x40(%rsp), %rdx
leaq (%rdx,%rax,8), %rsi
movq %rbp, %rdi
movq 0x28(%rsp), %rdx
movl %ebx, %r8d
callq *0x8(%r9)
movq 0x30(%rsp), %rax
addl %ebx, (%rax)
movq 0x8(%rsp), %rax
movl 0x64(%rax), %eax
addl %ebx, %eax
movq 0x8(%rsp), %rcx
movl %eax, 0x64(%rcx)
movq 0x8(%rsp), %rcx
subl %ebx, 0x60(%rcx)
movq 0x8(%rsp), %rbx
sete %dl
movl 0x13c(%rbp), %ecx
cmpl %ecx, %eax
setl %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x74ca7
movl 0x4c(%rbp), %eax
testl %eax, %eax
jle 0x74ca2
xorl %r15d, %r15d
movl 0x13c(%rbp), %r12d
movl 0x64(%rbx), %r13d
cmpl %r12d, %r13d
jge 0x74c7a
movq 0x10(%rbx,%r15,8), %r14
movl 0x30(%rbp), %ebx
leal -0x1(%r13), %ebp
movq %r14, %rdi
movl %ebp, %esi
movq %r14, %rdx
movl %r13d, %ecx
movl $0x1, %r8d
movl %ebx, %r9d
callq 0x85cb7
incl %r13d
cmpl %r13d, %r12d
jne 0x74c4c
movq 0x38(%rsp), %rbp
movl 0x4c(%rbp), %eax
movq 0x8(%rsp), %rbx
incq %r15
movslq %eax, %rcx
cmpq %rcx, %r15
jl 0x74c30
movl 0x13c(%rbp), %ecx
movq 0x20(%rsp), %r12
movq 0x18(%rsp), %r13
movl 0x80(%rsp), %r14d
movl 0x14(%rsp), %r15d
movl %ecx, 0x64(%rbx)
jmp 0x74cab
cmpl %ecx, %eax
jne 0x74cd1
movq 0x1e0(%rbp), %rax
movl (%r12), %r8d
movq %rbp, %rdi
movq 0x28(%rsp), %rsi
xorl %edx, %edx
movq %r13, %rcx
callq *0x8(%rax)
movl $0x0, 0x64(%rbx)
incl (%r12)
cmpl $0x0, 0x60(%rbx)
jne 0x74cdd
cmpl %r14d, (%r12)
jb 0x74cf2
movq 0x30(%rsp), %rax
movl (%rax), %eax
cmpl %r15d, %eax
jb 0x74b9f
jmp 0x74d9a
movl 0x4c(%rbp), %eax
testl %eax, %eax
jle 0x74d8f
movq 0x58(%rbp), %rsi
xorl %ebx, %ebx
movl 0xc(%rsi), %r15d
movl (%r12), %ecx
movl %r15d, %r14d
imull %ecx, %r14d
movl %r15d, %edx
imull 0x80(%rsp), %edx
cmpl %edx, %r14d
jge 0x74d7c
movq (%r13,%rbx,8), %r12
movq %rsi, 0x8(%rsp)
movl 0x1c(%rsi), %ebp
shll $0x3, %ebp
leal -0x1(%r14), %r13d
movl 0x80(%rsp), %eax
subl %ecx, %eax
imull %eax, %r15d
movq %r12, %rdi
movl %r13d, %esi
movq %r12, %rdx
movl %r14d, %ecx
movl $0x1, %r8d
movl %ebp, %r9d
callq 0x85cb7
incl %r14d
decl %r15d
jne 0x74d43
movq 0x38(%rsp), %rax
movl 0x4c(%rax), %eax
movq 0x20(%rsp), %r12
movq 0x18(%rsp), %r13
movq 0x8(%rsp), %rsi
incq %rbx
addq $0x60, %rsi
movslq %eax, %rcx
cmpq %rcx, %rbx
jl 0x74d03
movl 0x80(%rsp), %eax
movl %eax, (%r12)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)