// File: tomfunkhouser[P]gaps/pkgs/jpeg/jdcolor.c
// Function: ycc_rgb_convert
METHODDEF(void)
ycc_rgb_convert (j_decompress_ptr cinfo,
		 JSAMPIMAGE input_buf, JDIMENSION input_row,
		 JSAMPARRAY output_buf, int num_rows)
{
  my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
  register int y, cb, cr;
  register JSAMPROW outptr;
  register JSAMPROW inptr0, inptr1, inptr2;
  register JDIMENSION col;
  JDIMENSION num_cols = cinfo->output_width;
  /* copy these pointers into registers if possible */
  register JSAMPLE * range_limit = cinfo->sample_range_limit;
  register int * Crrtab = cconvert->Cr_r_tab;
  register int * Cbbtab = cconvert->Cb_b_tab;
  register INT32 * Crgtab = cconvert->Cr_g_tab;
  register INT32 * Cbgtab = cconvert->Cb_g_tab;
  SHIFT_TEMPS

  while (--num_rows >= 0) {
    inptr0 = input_buf[0][input_row];
    inptr1 = input_buf[1][input_row];
    inptr2 = input_buf[2][input_row];
    input_row++;
    outptr = *output_buf++;
    for (col = 0; col < num_cols; col++) {
      y  = GETJSAMPLE(inptr0[col]);
      cb = GETJSAMPLE(inptr1[col]);
      cr = GETJSAMPLE(inptr2[col]);
      /* Range-limiting is essential due to noise introduced by DCT losses. */
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
      outptr[RGB_GREEN] = range_limit[y +
			      ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
						 SCALEBITS))];
      outptr[RGB_BLUE] =  range_limit[y + Cbbtab[cb]];
      outptr += RGB_PIXELSIZE;
    }
  }
}

// Assembly:
subq $0x10, %rsp
movq %rdi, 0x8(%rsp)
movq %rsi, (%rsp)
movl %edx, -0x4(%rsp)
movq %rcx, -0x10(%rsp)
movl %r8d, -0x14(%rsp)
movq 0x8(%rsp), %rax
movq 0x268(%rax), %rax
movq %rax, -0x20(%rsp)
movq 0x8(%rsp), %rax
movl 0x88(%rax), %eax
movl %eax, -0x58(%rsp)
movq 0x8(%rsp), %rax
movq 0x1a8(%rax), %rax
movq %rax, -0x60(%rsp)
movq -0x20(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rsp)
movq -0x20(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x70(%rsp)
movq -0x20(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x78(%rsp)
movq -0x20(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x80(%rsp)
movl -0x14(%rsp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rsp)
cmpl $0x0, %eax
jl 0xf3d06
movq (%rsp), %rax
movq (%rax), %rax
movl -0x4(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rsp)
movq (%rsp), %rax
movq 0x8(%rax), %rax
movl -0x4(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rsp)
movq (%rsp), %rax
movq 0x10(%rax), %rax
movl -0x4(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rsp)
movl -0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rsp)
movq -0x10(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x10(%rsp)
movq (%rax), %rax
movq %rax, -0x38(%rsp)
movl $0x0, -0x54(%rsp)
movl -0x54(%rsp), %eax
cmpl -0x58(%rsp), %eax
jae 0xf3d01
movq -0x40(%rsp), %rax
movl -0x54(%rsp), %ecx
movzbl (%rax,%rcx), %eax
movl %eax, -0x24(%rsp)
movq -0x48(%rsp), %rax
movl -0x54(%rsp), %ecx
movzbl (%rax,%rcx), %eax
movl %eax, -0x28(%rsp)
movq -0x50(%rsp), %rax
movl -0x54(%rsp), %ecx
movzbl (%rax,%rcx), %eax
movl %eax, -0x2c(%rsp)
movq -0x60(%rsp), %rax
movl -0x24(%rsp), %ecx
movq -0x68(%rsp), %rdx
movslq -0x2c(%rsp), %rsi
addl (%rdx,%rsi,4), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %cl
movq -0x38(%rsp), %rax
movb %cl, (%rax)
movq -0x60(%rsp), %rax
movl -0x24(%rsp), %ecx
movq -0x80(%rsp), %rdx
movslq -0x28(%rsp), %rsi
movq (%rdx,%rsi,8), %rdx
movq -0x78(%rsp), %rsi
movslq -0x2c(%rsp), %rdi
addq (%rsi,%rdi,8), %rdx
sarq $0x10, %rdx
addl %edx, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %cl
movq -0x38(%rsp), %rax
movb %cl, 0x1(%rax)
movq -0x60(%rsp), %rax
movl -0x24(%rsp), %ecx
movq -0x70(%rsp), %rdx
movslq -0x28(%rsp), %rsi
addl (%rdx,%rsi,4), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %cl
movq -0x38(%rsp), %rax
movb %cl, 0x2(%rax)
movq -0x38(%rsp), %rax
addq $0x3, %rax
movq %rax, -0x38(%rsp)
movl -0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rsp)
jmp 0xf3c22
jmp 0xf3ba4
addq $0x10, %rsp
retq
nopl (%rax,%rax)