// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/jpeg/jdsample.c
// Function: sep_upsample
METHODDEF(void)
sep_upsample (j_decompress_ptr cinfo,
	      JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
	      JDIMENSION in_row_groups_avail,
	      JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
	      JDIMENSION out_rows_avail)
{
  my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
  int ci;
  jpeg_component_info * compptr;
  JDIMENSION num_rows;

  /* Fill the conversion buffer, if it's empty */
  if (upsample->next_row_out >= cinfo->max_v_samp_factor) {
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
	 ci++, compptr++) {
      /* Invoke per-component upsample method.  Notice we pass a POINTER
       * to color_buf[ci], so that fullsize_upsample can change it.
       */
      (*upsample->methods[ci]) (cinfo, compptr,
	input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]),
	upsample->color_buf + ci);
    }
    upsample->next_row_out = 0;
  }

  /* Color-convert and emit rows */

  /* How many we have in the buffer: */
  num_rows = (JDIMENSION) (cinfo->max_v_samp_factor - upsample->next_row_out);
  /* Not more than the distance to the end of the image.  Need this test
   * in case the image height is not a multiple of max_v_samp_factor:
   */
  if (num_rows > upsample->rows_to_go) 
    num_rows = upsample->rows_to_go;
  /* And not more than what the client can accept: */
  out_rows_avail -= *out_row_ctr;
  if (num_rows > out_rows_avail)
    num_rows = out_rows_avail;

  (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf,
				     (JDIMENSION) upsample->next_row_out,
				     output_buf + *out_row_ctr,
				     (int) num_rows);

  /* Adjust counts */
  *out_row_ctr += num_rows;
  upsample->rows_to_go -= num_rows;
  upsample->next_row_out += num_rows;
  /* When the buffer is emptied, declare this input row group consumed */
  if (upsample->next_row_out >= cinfo->max_v_samp_factor)
    (*in_row_group_ctr)++;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r12
movq %rdx, %r15
movq %rdi, %r13
movl 0x50(%rsp), %ebp
movq 0x260(%rdi), %r14
movl 0xb8(%r14), %eax
cmpl 0x19c(%rdi), %eax
jl 0x83893
movq %r8, (%rsp)
movq %r12, 0x8(%rsp)
cmpl $0x0, 0x38(%r13)
movq %r15, %rax
jle 0x83878
movq 0x130(%r13), %r12
leaq 0x18(%r14), %r15
xorl %ebp, %ebp
movq %rax, 0x10(%rsp)
movl 0xc0(%r14,%rbp,4), %edx
imull (%rax), %edx
shlq $0x3, %rdx
addq (%rsi,%rbp,8), %rdx
movq %r13, %rdi
movq %r13, %rbx
movq %rsi, %r13
movq %r12, %rsi
movq %r15, %rcx
callq *0x68(%r14,%rbp,8)
movq %r13, %rsi
movq %rbx, %r13
incq %rbp
addq $0x60, %r12
movslq 0x38(%rbx), %rax
addq $0x8, %r15
cmpq %rax, %rbp
movq 0x10(%rsp), %rax
jl 0x83832
movl $0x0, 0xb8(%r14)
movq %rax, %r15
movq 0x8(%rsp), %r12
movl 0x50(%rsp), %ebp
movq (%rsp), %r8
movl 0x19c(%r13), %eax
movl 0xb8(%r14), %edx
movl 0xbc(%r14), %ecx
subl %edx, %eax
cmpl %ecx, %eax
cmovael %ecx, %eax
movl (%r12), %ecx
subl %ecx, %ebp
cmpl %ebp, %eax
cmovbl %eax, %ebp
movq 0x268(%r13), %rax
leaq 0x18(%r14), %rsi
leaq (%r8,%rcx,8), %rcx
movq %r13, %rdi
movl %ebp, %r8d
callq *0x8(%rax)
addl %ebp, (%r12)
subl %ebp, 0xbc(%r14)
addl 0xb8(%r14), %ebp
movl %ebp, 0xb8(%r14)
cmpl 0x19c(%r13), %ebp
jl 0x838f7
incl (%r15)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq