// File: /workspace/github_cpp_makefile_star2_O1/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, 0x10(%rsp)
movl (%rdx), %eax
cmpl %ecx, %eax
jae 0x75cf2
movq %r9, %r15
movq %r8, %r14
movl %ecx, %r13d
movq %rdi, %r12
movl 0x80(%rsp), %ebp
movq 0x1c0(%rdi), %rcx
leaq 0x10(%rcx), %rdx
movq %rdx, 0x30(%rsp)
movq %r8, 0x28(%rsp)
movq %rdi, 0x18(%rsp)
movq %r9, 0x38(%rsp)
movl %r13d, 0x24(%rsp)
movq %rcx, 0x8(%rsp)
cmpl %ebp, (%r15)
jae 0x75cf2
movl %r13d, %edx
subl %eax, %edx
movl 0x13c(%r12), %ebx
movq 0x8(%rsp), %rcx
movl 0x64(%rcx), %ecx
subl %ecx, %ebx
cmpl %edx, %ebx
cmovael %edx, %ebx
movq 0x1d8(%r12), %r9
movl %eax, %eax
movq 0x40(%rsp), %rdx
leaq (%rdx,%rax,8), %rsi
movq %r12, %rdi
movq 0x30(%rsp), %rdx
movl %ebx, %r8d
callq *0x8(%r9)
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rax
addl %ebx, (%rax)
movl 0x64(%rcx), %eax
addl %ebx, %eax
movl %eax, 0x64(%rcx)
subl %ebx, 0x60(%rcx)
jne 0x75be9
cmpl 0x13c(%r12), %eax
jge 0x75be9
cmpl $0x0, 0x4c(%r12)
jle 0x75bc8
xorl %r15d, %r15d
movl 0x13c(%r12), %r12d
movl 0x64(%rcx), %r13d
cmpl %r12d, %r13d
jge 0x75bb1
movq 0x8(%rsp), %rax
movq 0x10(%rax,%r15,8), %r14
movq 0x18(%rsp), %rax
movl 0x30(%rax), %ebx
leal -0x1(%r13), %ebp
movq %r14, %rdi
movl %ebp, %esi
movq %r14, %rdx
movl %r13d, %ecx
movl $0x1, %r8d
movl %ebx, %r9d
callq 0x86abf
incl %r13d
cmpl %r13d, %r12d
jne 0x75b90
incq %r15
movq 0x18(%rsp), %r12
movslq 0x4c(%r12), %rax
cmpq %rax, %r15
movq 0x8(%rsp), %rcx
jl 0x75b69
movl 0x13c(%r12), %eax
movl %eax, 0x64(%rcx)
movq 0x38(%rsp), %r15
movq 0x28(%rsp), %r14
movl 0x80(%rsp), %ebp
movl 0x24(%rsp), %r13d
movl 0x64(%rcx), %eax
cmpl 0x13c(%r12), %eax
jne 0x75c20
movq 0x1e0(%r12), %rax
movl (%r15), %r8d
movq %r12, %rdi
movq 0x30(%rsp), %rsi
xorl %edx, %edx
movq %r14, %rcx
callq *0x8(%rax)
movq 0x8(%rsp), %rcx
movl $0x0, 0x64(%rcx)
incl (%r15)
cmpl $0x0, 0x60(%rcx)
jne 0x75c2b
cmpl %ebp, (%r15)
jb 0x75c40
movq 0x10(%rsp), %rax
movl (%rax), %eax
cmpl %r13d, %eax
jb 0x75aec
jmp 0x75cf2
cmpl $0x0, 0x4c(%r12)
jle 0x75cef
movq 0x58(%r12), %rcx
movq $0x0, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
movl 0xc(%rcx), %ebx
movl (%r15), %eax
movl %ebx, %r14d
imull %eax, %r14d
movl %ebx, %ecx
imull %ebp, %ecx
cmpl %ecx, %r14d
jge 0x75cc0
movq 0x28(%rsp), %rcx
movq 0x8(%rsp), %rdx
movq (%rcx,%rdx,8), %r12
movq 0x10(%rsp), %rcx
movl 0x1c(%rcx), %ebp
shll $0x3, %ebp
leal -0x1(%r14), %r13d
movl 0x80(%rsp), %ecx
subl %eax, %ecx
imull %ecx, %ebx
movq %r12, %rdi
movl %r13d, %esi
movq %r12, %rdx
movl %r14d, %ecx
movl $0x1, %r8d
movl %ebp, %r9d
callq 0x86abf
incl %r14d
decl %ebx
jne 0x75c9f
movq 0x8(%rsp), %rsi
incq %rsi
movq 0x10(%rsp), %rcx
addq $0x60, %rcx
movq 0x18(%rsp), %rax
movslq 0x4c(%rax), %rax
movq %rsi, 0x8(%rsp)
cmpq %rax, %rsi
movl 0x80(%rsp), %ebp
jl 0x75c5a
movl %ebp, (%r15)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)