// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/jpeg/jdmerge.c
// Function: h2v1_merged_upsample
METHODDEF(void)
h2v1_merged_upsample (j_decompress_ptr cinfo,
		      JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
		      JSAMPARRAY output_buf)
{
  my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
  register int y, cred, cgreen, cblue;
  int cb, cr;
  register JSAMPROW outptr;
  JSAMPROW inptr0, inptr1, inptr2;
  JDIMENSION col;
  /* copy these pointers into registers if possible */
  register JSAMPLE * range_limit = cinfo->sample_range_limit;
  int * Crrtab = upsample->Cr_r_tab;
  int * Cbbtab = upsample->Cb_b_tab;
  INT32 * Crgtab = upsample->Cr_g_tab;
  INT32 * Cbgtab = upsample->Cb_g_tab;
  SHIFT_TEMPS

  inptr0 = input_buf[0][in_row_group_ctr];
  inptr1 = input_buf[1][in_row_group_ctr];
  inptr2 = input_buf[2][in_row_group_ctr];
  outptr = output_buf[0];
  /* Loop for each pair of output pixels */
  for (col = cinfo->output_width >> 1; col > 0; col--) {
    /* Do the chroma part of the calculation */
    cb = GETJSAMPLE(*inptr1++);
    cr = GETJSAMPLE(*inptr2++);
    cred = Crrtab[cr];
    cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
    cblue = Cbbtab[cb];
    /* Fetch 2 Y values and emit 2 pixels */
    y  = GETJSAMPLE(*inptr0++);
    outptr[RGB_RED] =   range_limit[y + cred];
    outptr[RGB_GREEN] = range_limit[y + cgreen];
    outptr[RGB_BLUE] =  range_limit[y + cblue];
    outptr += RGB_PIXELSIZE;
    y  = GETJSAMPLE(*inptr0++);
    outptr[RGB_RED] =   range_limit[y + cred];
    outptr[RGB_GREEN] = range_limit[y + cgreen];
    outptr[RGB_BLUE] =  range_limit[y + cblue];
    outptr += RGB_PIXELSIZE;
  }
  /* If image width is odd, do the last output column separately */
  if (cinfo->output_width & 1) {
    cb = GETJSAMPLE(*inptr1);
    cr = GETJSAMPLE(*inptr2);
    cred = Crrtab[cr];
    cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
    cblue = Cbbtab[cb];
    y  = GETJSAMPLE(*inptr0);
    outptr[RGB_RED] =   range_limit[y + cred];
    outptr[RGB_GREEN] = range_limit[y + cgreen];
    outptr[RGB_BLUE] =  range_limit[y + cblue];
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %r8
movq 0x260(%rdi), %r9
movq 0x1a8(%rdi), %rax
movq 0x20(%r9), %r10
movq 0x28(%r9), %r13
movq 0x30(%r9), %r11
movq 0x38(%r9), %rdi
movl %edx, %r14d
movq (%rsi), %rdx
movq 0x8(%rsi), %rbx
movq (%rdx,%r14,8), %rdx
movq (%rbx,%r14,8), %rbx
movq 0x10(%rsi), %rsi
movq (%rsi,%r14,8), %rsi
movq (%rcx), %rcx
movl 0x88(%r8), %ebp
cmpl $0x2, %ebp
jb 0x869b4
movq %r8, -0x8(%rsp)
shrl %ebp
movzbl (%rbx), %r14d
incq %rbx
movzbl (%rsi), %r15d
incq %rsi
movslq (%r10,%r15,4), %r12
movq (%r11,%r15,8), %r15
addq (%rdi,%r14,8), %r15
shrq $0x10, %r15
movslq (%r13,%r14,4), %r14
movq %r13, %r9
movzbl (%rdx), %r13d
leaq (%r12,%r13), %r8
movb (%rax,%r8), %r8b
movb %r8b, (%rcx)
movslq %r15d, %r8
leaq (%r8,%r13), %r15
movb (%rax,%r15), %r15b
movb %r15b, 0x1(%rcx)
addq %r14, %r13
movb (%rax,%r13), %r15b
movq %r9, %r13
movb %r15b, 0x2(%rcx)
movzbl 0x1(%rdx), %r15d
addq $0x2, %rdx
addq %r15, %r12
movb (%rax,%r12), %r12b
movb %r12b, 0x3(%rcx)
addq %r15, %r8
movb (%rax,%r8), %r8b
movb %r8b, 0x4(%rcx)
addq %r15, %r14
movb (%rax,%r14), %r8b
movb %r8b, 0x5(%rcx)
addq $0x6, %rcx
decl %ebp
jne 0x86927
movq -0x8(%rsp), %r8
testb $0x1, 0x88(%r8)
je 0x869fe
movzbl (%rbx), %r8d
movzbl (%rsi), %esi
movslq (%r10,%rsi,4), %r10
movq (%r11,%rsi,8), %rsi
addq (%rdi,%r8,8), %rsi
shrq $0x10, %rsi
movslq (%r13,%r8,4), %rdi
movzbl (%rdx), %edx
addq %rdx, %r10
movb (%rax,%r10), %r8b
movb %r8b, (%rcx)
movslq %esi, %rsi
addq %rdx, %rsi
movb (%rax,%rsi), %sil
movb %sil, 0x1(%rcx)
addq %rdx, %rdi
movb (%rax,%rdi), %al
movb %al, 0x2(%rcx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)