// File: /workspace/github_cpp_makefile_star2_O2/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), %rdi
movq %rdi, -0x10(%rsp)
movq 0x30(%r9), %r11
movq 0x38(%r9), %r9
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), %r14
movq (%rcx), %rcx
movq %r8, -0x8(%rsp)
movl 0x88(%r8), %r15d
shrl %r15d
xorl %esi, %esi
cmpl %esi, %r15d
je 0x7906f
movzbl (%rbx,%rsi), %r12d
movzbl (%r14,%rsi), %r13d
movslq (%r10,%r13,4), %rbp
movq (%r11,%r13,8), %r13
addq (%r9,%r12,8), %r13
shrq $0x10, %r13
movq -0x10(%rsp), %rdi
movslq (%rdi,%r12,4), %r12
movzbl (%rdx,%rsi,2), %r8d
leaq (%r8,%rbp), %rdi
movb (%rax,%rdi), %dil
movb %dil, (%rcx)
movslq %r13d, %rdi
leaq (%r8,%rdi), %r13
movb (%rax,%r13), %r13b
movb %r13b, 0x1(%rcx)
addq %r12, %r8
movb (%rax,%r8), %r8b
movb %r8b, 0x2(%rcx)
movzbl 0x1(%rdx,%rsi,2), %r8d
addq %r8, %rbp
movb (%rax,%rbp), %bpl
movb %bpl, 0x3(%rcx)
addq %r8, %rdi
movb (%rax,%rdi), %dil
movb %dil, 0x4(%rcx)
addq %r8, %r12
movb (%rax,%r12), %dil
movb %dil, 0x5(%rcx)
addq $0x6, %rcx
incq %rsi
jmp 0x78fe6
movq -0x8(%rsp), %rdi
testb $0x1, 0x88(%rdi)
je 0x790c4
movzbl (%rbx,%rsi), %edi
movzbl (%r14,%rsi), %r8d
movslq (%r10,%r8,4), %r10
movq (%r11,%r8,8), %r8
addq (%r9,%rdi,8), %r8
shrq $0x10, %r8
movq -0x10(%rsp), %r9
movslq (%r9,%rdi,4), %rdi
movzbl (%rdx,%rsi,2), %edx
addq %rdx, %r10
movb (%rax,%r10), %sil
movb %sil, (%rcx)
movslq %r8d, %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
nop