// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
movq %rdx, (%rsp)
movq %rdi, %r14
movl 0x50(%rsp), %r15d
movq 0x260(%rdi), %rbp
movl 0xb8(%rbp), %edx
movl 0x19c(%rdi), %eax
cmpl %eax, %edx
jl 0x7648f
movq %rsi, %r13
movq %r8, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq 0x130(%r14), %r12
leaq 0x18(%rbp), %r15
xorl %ebx, %ebx
movslq 0x38(%r14), %rax
cmpq %rax, %rbx
jge 0x76470
movl 0xc0(%rbp,%rbx,4), %edx
movq (%rsp), %rax
imull (%rax), %edx
shlq $0x3, %rdx
addq (%r13,%rbx,8), %rdx
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rcx
callq *0x68(%rbp,%rbx,8)
incq %rbx
addq $0x60, %r12
addq $0x8, %r15
jmp 0x76436
andl $0x0, 0xb8(%rbp)
movl 0x19c(%r14), %eax
xorl %edx, %edx
movq 0x10(%rsp), %rbx
movl 0x50(%rsp), %r15d
movq 0x8(%rsp), %r8
subl %edx, %eax
movl 0xbc(%rbp), %ecx
cmpl %ecx, %eax
cmovael %ecx, %eax
movl (%rbx), %ecx
subl %ecx, %r15d
cmpl %r15d, %eax
cmovbl %eax, %r15d
movq 0x268(%r14), %rax
leaq 0x18(%rbp), %rsi
leaq (%r8,%rcx,8), %rcx
movq %r14, %rdi
movl %r15d, %r8d
callq *0x8(%rax)
addl %r15d, (%rbx)
subl %r15d, 0xbc(%rbp)
addl 0xb8(%rbp), %r15d
movl %r15d, 0xb8(%rbp)
cmpl 0x19c(%r14), %r15d
jl 0x764e7
movq (%rsp), %rax
incl (%rax)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq