// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/jpeg/jdsample.c
// Function: h2v2_fancy_upsample
METHODDEF(void)
h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
		     JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
{
  JSAMPARRAY output_data = *output_data_ptr;
  register JSAMPROW inptr0, inptr1, outptr;
#if BITS_IN_JSAMPLE == 8
  register int thiscolsum, lastcolsum, nextcolsum;
#else
  register INT32 thiscolsum, lastcolsum, nextcolsum;
#endif
  register JDIMENSION colctr;
  int inrow, outrow, v;

  inrow = outrow = 0;
  while (outrow < cinfo->max_v_samp_factor) {
    for (v = 0; v < 2; v++) {
      /* inptr0 points to nearest input row, inptr1 points to next nearest */
      inptr0 = input_data[inrow];
      if (v == 0)		/* next nearest is row above */
	inptr1 = input_data[inrow-1];
      else			/* next nearest is row below */
	inptr1 = input_data[inrow+1];
      outptr = output_data[outrow++];

      /* Special case for first column */
      thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
      nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
      *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 8) >> 4);
      *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4);
      lastcolsum = thiscolsum; thiscolsum = nextcolsum;

      for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {
	/* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */
	/* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */
	nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
	*outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4);
	*outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4);
	lastcolsum = thiscolsum; thiscolsum = nextcolsum;
      }

      /* Special case for last column */
      *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4);
      *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 7) >> 4);
    }
    inrow++;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, -0x8(%rsp)
movq %rdi, -0x10(%rsp)
cmpl $0x0, 0x19c(%rdi)
jle 0x82d5b
movq (%rcx), %rax
xorl %edi, %edi
xorl %r8d, %r8d
movq -0x8(%rsp), %rcx
leaq (%rcx,%rdi,8), %r9
movslq %r8d, %r8
movb $0x1, %r10b
movq (%r9), %rbx
movl %r10d, %ecx
notb %cl
movzbl %cl, %ecx
andl $0x1, %ecx
shll $0x4, %ecx
movq -0x8(%rcx,%r9), %r14
movq (%rax,%r8,8), %r12
movzbl (%rbx), %ecx
leal (%rcx,%rcx,2), %ecx
movzbl (%r14), %r13d
addl %ecx, %r13d
movzbl 0x1(%rbx), %ecx
leal (%rcx,%rcx,2), %ecx
movzbl 0x1(%r14), %r11d
addl %ecx, %r11d
leal 0x8(,%r13,4), %ecx
shrl $0x4, %ecx
movb %cl, (%r12)
leal (%r13,%r13,2), %ecx
addl %r11d, %ecx
addl $0x7, %ecx
shrl $0x4, %ecx
movb %cl, 0x1(%r12)
movl 0x28(%rsi), %ecx
leaq 0x2(%r12), %r15
cmpq $0x2, %rcx
je 0x82d11
movl $0x2, %r12d
movl %r11d, %ebp
movzbl (%rbx,%r12), %r11d
leal (%r11,%r11,2), %edx
movzbl (%r14,%r12), %r11d
addl %edx, %r11d
leal (%rbp,%rbp,2), %edx
addl %edx, %r13d
addl $0x8, %r13d
shrl $0x4, %r13d
movb %r13b, (%r15)
addl %r11d, %edx
addl $0x7, %edx
shrl $0x4, %edx
movb %dl, 0x1(%r15)
addq $0x2, %r15
incq %r12
movl %ebp, %r13d
cmpl %r12d, %ecx
jne 0x82cc9
leaq -0x2(%r15), %r12
jmp 0x82d14
movl %r13d, %ebp
incq %r8
leal (%r11,%r11,2), %ecx
addl %ebp, %ecx
addl $0x8, %ecx
shrl $0x4, %ecx
movb %cl, (%r15)
leal 0x7(,%r11,4), %ecx
shrl $0x4, %ecx
movb %cl, 0x3(%r12)
testb $0x1, %r10b
movl $0x0, %r10d
jne 0x82c5d
incq %rdi
movq -0x10(%rsp), %rcx
cmpl %r8d, 0x19c(%rcx)
jg 0x82c4e
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq