// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/jpeg/jdmerge.c
// Function: h2v2_merged_upsample
METHODDEF(void)
h2v2_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 outptr0, outptr1;
  JSAMPROW inptr00, inptr01, 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

  inptr00 = input_buf[0][in_row_group_ctr*2];
  inptr01 = input_buf[0][in_row_group_ctr*2 + 1];
  inptr1 = input_buf[1][in_row_group_ctr];
  inptr2 = input_buf[2][in_row_group_ctr];
  outptr0 = output_buf[0];
  outptr1 = output_buf[1];
  /* Loop for each group 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 4 Y values and emit 4 pixels */
    y  = GETJSAMPLE(*inptr00++);
    outptr0[RGB_RED] =   range_limit[y + cred];
    outptr0[RGB_GREEN] = range_limit[y + cgreen];
    outptr0[RGB_BLUE] =  range_limit[y + cblue];
    outptr0 += RGB_PIXELSIZE;
    y  = GETJSAMPLE(*inptr00++);
    outptr0[RGB_RED] =   range_limit[y + cred];
    outptr0[RGB_GREEN] = range_limit[y + cgreen];
    outptr0[RGB_BLUE] =  range_limit[y + cblue];
    outptr0 += RGB_PIXELSIZE;
    y  = GETJSAMPLE(*inptr01++);
    outptr1[RGB_RED] =   range_limit[y + cred];
    outptr1[RGB_GREEN] = range_limit[y + cgreen];
    outptr1[RGB_BLUE] =  range_limit[y + cblue];
    outptr1 += RGB_PIXELSIZE;
    y  = GETJSAMPLE(*inptr01++);
    outptr1[RGB_RED] =   range_limit[y + cred];
    outptr1[RGB_GREEN] = range_limit[y + cgreen];
    outptr1[RGB_BLUE] =  range_limit[y + cblue];
    outptr1 += 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(*inptr00);
    outptr0[RGB_RED] =   range_limit[y + cred];
    outptr0[RGB_GREEN] = range_limit[y + cgreen];
    outptr0[RGB_BLUE] =  range_limit[y + cblue];
    y  = GETJSAMPLE(*inptr01);
    outptr1[RGB_RED] =   range_limit[y + cred];
    outptr1[RGB_GREEN] = range_limit[y + cgreen];
    outptr1[RGB_BLUE] =  range_limit[y + cblue];
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %r10
movq 0x260(%rdi), %rdi
movq 0x1a8(%r10), %rax
movq 0x20(%rdi), %r8
movq %r8, -0x18(%rsp)
movq 0x28(%rdi), %r8
movq %r8, -0x10(%rsp)
movq 0x30(%rdi), %r8
movq %r8, -0x28(%rsp)
movq 0x38(%rdi), %rdi
movq %rdi, -0x20(%rsp)
leal (%rdx,%rdx), %edi
movq (%rsi), %r8
movq 0x8(%rsi), %r9
movq (%r8,%rdi,8), %r15
movq 0x8(%r8,%rdi,8), %r8
movl %edx, %edx
movq (%r9,%rdx,8), %r12
movq 0x10(%rsi), %rsi
movq (%rsi,%rdx,8), %r13
movq (%rcx), %rsi
movq 0x8(%rcx), %rcx
movq %r10, -0x8(%rsp)
movl 0x88(%r10), %ebp
shrl %ebp
xorl %ebx, %ebx
xorl %edx, %edx
cmpl %ebx, %ebp
je 0x78ebb
movzbl (%r12,%rbx), %edi
movzbl (%r13,%rbx), %r10d
movq -0x18(%rsp), %r9
movslq (%r9,%r10,4), %r9
movq -0x28(%rsp), %r11
movq (%r11,%r10,8), %r10
movq -0x20(%rsp), %r11
addq (%r11,%rdi,8), %r10
shrq $0x10, %r10
movq -0x10(%rsp), %r11
movslq (%r11,%rdi,4), %rdi
movzbl (%r15,%rbx,2), %r11d
leaq (%r9,%r11), %r14
movb (%rax,%r14), %r14b
movb %r14b, (%rsi,%rdx)
movslq %r10d, %r10
leaq (%r11,%r10), %r14
movb (%rax,%r14), %r14b
movb %r14b, 0x1(%rsi,%rdx)
addq %rdi, %r11
movb (%rax,%r11), %r11b
movb %r11b, 0x2(%rsi,%rdx)
movzbl 0x1(%r15,%rbx,2), %r11d
leaq (%r9,%r11), %r14
movb (%rax,%r14), %r14b
movb %r14b, 0x3(%rsi,%rdx)
leaq (%r11,%r10), %r14
movb (%rax,%r14), %r14b
movb %r14b, 0x4(%rsi,%rdx)
addq %rdi, %r11
movb (%rax,%r11), %r11b
movb %r11b, 0x5(%rsi,%rdx)
movzbl (%r8,%rbx,2), %r11d
leaq (%r9,%r11), %r14
movb (%rax,%r14), %r14b
movb %r14b, (%rcx,%rdx)
leaq (%r11,%r10), %r14
movb (%rax,%r14), %r14b
movb %r14b, 0x1(%rcx,%rdx)
addq %rdi, %r11
movb (%rax,%r11), %r11b
movb %r11b, 0x2(%rcx,%rdx)
movzbl 0x1(%r8,%rbx,2), %r11d
addq %r11, %r9
addq %r11, %r10
addq %r11, %rdi
movb (%rax,%r9), %r9b
movb %r9b, 0x3(%rcx,%rdx)
movb (%rax,%r10), %r9b
movb %r9b, 0x4(%rcx,%rdx)
movb (%rax,%rdi), %dil
movb %dil, 0x5(%rcx,%rdx)
addq $0x6, %rdx
incq %rbx
jmp 0x78dc7
movq -0x8(%rsp), %rdi
testb $0x1, 0x88(%rdi)
je 0x78f53
movzbl (%r12,%rbx), %edi
movzbl (%r13,%rbx), %r9d
movq -0x28(%rsp), %r10
movq (%r10,%r9,8), %r10
movq -0x20(%rsp), %r11
addq (%r11,%rdi,8), %r10
movq -0x18(%rsp), %r11
movslq (%r11,%r9,4), %r9
shrq $0x10, %r10
movq -0x10(%rsp), %r11
movslq (%r11,%rdi,4), %rdi
movzbl (%r15,%rbx,2), %r11d
leaq (%r9,%r11), %r14
movb (%rax,%r14), %bpl
movb %bpl, (%rsi,%rdx)
movslq %r10d, %r10
leaq (%r11,%r10), %r14
movb (%rax,%r14), %bpl
movb %bpl, 0x1(%rsi,%rdx)
addq %rdi, %r11
movb (%rax,%r11), %r11b
movb %r11b, 0x2(%rsi,%rdx)
movzbl (%r8,%rbx,2), %esi
addq %rsi, %r9
movb (%rax,%r9), %r8b
movb %r8b, (%rcx,%rdx)
addq %rsi, %r10
movb (%rax,%r10), %r8b
movb %r8b, 0x1(%rcx,%rdx)
addq %rsi, %rdi
movb (%rax,%rdi), %al
movb %al, 0x2(%rcx,%rdx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq