// File: /workspace/github_cpp_makefile_star2_O3/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 0x260(%rdi), %r8
movq 0x1a8(%rdi), %rax
movq 0x20(%r8), %rbx
movq 0x28(%r8), %r11
movq 0x30(%r8), %r12
movq 0x38(%r8), %r13
leal (%rdx,%rdx), %r14d
movq (%rsi), %r8
movq 0x8(%rsi), %r9
movq (%r8,%r14,8), %r10
movq 0x8(%r8,%r14,8), %r14
movl %edx, %edx
movq (%r9,%rdx,8), %r9
movq 0x10(%rsi), %rsi
movq (%rsi,%rdx,8), %rsi
movq (%rcx), %rdx
movq 0x8(%rcx), %rcx
movl 0x88(%rdi), %r8d
cmpq $0x2, %r8
jb 0x85a1d
movq %rdi, -0x18(%rsp)
shrl %r8d
xorl %r15d, %r15d
xorl %ebp, %ebp
movq %r14, -0x28(%rsp)
movq %r10, -0x30(%rsp)
movq %r12, -0x8(%rsp)
movq %r9, -0x20(%rsp)
movq %r13, -0x10(%rsp)
movq -0x20(%rsp), %rdi
movzbl (%rdi,%rbp), %edi
movzbl (%rsi,%rbp), %r10d
movslq (%rbx,%r10,4), %r9
movq (%r12,%r10,8), %r10
addq (%r13,%rdi,8), %r10
shrq $0x10, %r10
movslq (%r11,%rdi,4), %rdi
movq %r11, %r12
movq -0x30(%rsp), %r13
movzbl (%r13,%rbp,2), %r11d
movq %rbx, %r14
leaq (%r9,%r11), %rbx
movb (%rax,%rbx), %bl
movb %bl, (%rdx)
movslq %r10d, %r10
leaq (%r11,%r10), %rbx
movb (%rax,%rbx), %bl
movb %bl, 0x1(%rdx)
addq %rdi, %r11
movb (%rax,%r11), %r11b
movb %r11b, 0x2(%rdx)
movzbl 0x1(%r13,%rbp,2), %r11d
leaq (%r9,%r11), %rbx
movb (%rax,%rbx), %bl
movb %bl, 0x3(%rdx)
leaq (%r11,%r10), %rbx
movb (%rax,%rbx), %bl
movb %bl, 0x4(%rdx)
addq %rdi, %r11
movb (%rax,%r11), %r11b
movb %r11b, 0x5(%rdx)
movq -0x28(%rsp), %r13
movzbl (%r13,%rbp,2), %r11d
leaq (%r9,%r11), %rbx
movb (%rax,%rbx), %bl
movb %bl, (%rcx)
leaq (%r11,%r10), %rbx
movb (%rax,%rbx), %bl
movb %bl, 0x1(%rcx)
movq %r14, %rbx
addq %rdi, %r11
movb (%rax,%r11), %r11b
movb %r11b, 0x2(%rcx)
movzbl 0x1(%r13,%rbp,2), %r11d
addq %r11, %r9
addq %r11, %r10
addq %r11, %rdi
movq %r12, %r11
movq -0x10(%rsp), %r13
movq -0x8(%rsp), %r12
movb (%rax,%r9), %r9b
movb %r9b, 0x3(%rcx)
movb (%rax,%r10), %r9b
movb %r9b, 0x4(%rcx)
movb (%rax,%rdi), %dil
movb %dil, 0x5(%rcx)
movq -0x20(%rsp), %r9
addq $0x6, %rdx
addq $0x6, %rcx
incq %rbp
addq $-0x2, %r15
cmpl %ebp, %r8d
jne 0x85904
movq -0x18(%rsp), %rdi
movl 0x88(%rdi), %r8d
addq %rbp, %rsi
addq %rbp, %r9
movq -0x28(%rsp), %r14
subq %r15, %r14
movq -0x30(%rsp), %r10
subq %r15, %r10
testb $0x1, %r8b
je 0x85a8a
movzbl (%r9), %edi
movzbl (%rsi), %esi
movq (%r12,%rsi,8), %r9
addq (%r13,%rdi,8), %r9
movslq (%rbx,%rsi,4), %rsi
shrq $0x10, %r9
movslq (%r11,%rdi,4), %rdi
movzbl (%r10), %r10d
leaq (%rsi,%r10), %r11
movb (%rax,%r11), %r11b
movb %r11b, (%rdx)
movslq %r9d, %r9
leaq (%r10,%r9), %r11
movb (%rax,%r11), %r11b
movb %r11b, 0x1(%rdx)
addq %rdi, %r10
movb (%rax,%r10), %r10b
movb %r10b, 0x2(%rdx)
movzbl (%r14), %edx
addq %rdx, %rsi
movb (%rax,%rsi), %sil
movb %sil, (%rcx)
addq %rdx, %r9
movb (%rax,%r9), %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