// File: tomfunkhouser[P]gaps/pkgs/jpeg/jccolor.c
// Function: rgb_ycc_convert
METHODDEF(void)
rgb_ycc_convert (j_compress_ptr cinfo,
		 JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
		 JDIMENSION output_row, int num_rows)
{
  my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
  register int r, g, b;
  register INT32 * ctab = cconvert->rgb_ycc_tab;
  register JSAMPROW inptr;
  register JSAMPROW outptr0, outptr1, outptr2;
  register JDIMENSION col;
  JDIMENSION num_cols = cinfo->image_width;

  while (--num_rows >= 0) {
    inptr = *input_buf++;
    outptr0 = output_buf[0][output_row];
    outptr1 = output_buf[1][output_row];
    outptr2 = output_buf[2][output_row];
    output_row++;
    for (col = 0; col < num_cols; col++) {
      r = GETJSAMPLE(inptr[RGB_RED]);
      g = GETJSAMPLE(inptr[RGB_GREEN]);
      b = GETJSAMPLE(inptr[RGB_BLUE]);
      inptr += RGB_PIXELSIZE;
      /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations
       * must be too; we do not need an explicit range-limiting operation.
       * Hence the value being shifted is never negative, and we don't
       * need the general RIGHT_SHIFT macro.
       */
      /* Y */
      outptr0[col] = (JSAMPLE)
		((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
		 >> SCALEBITS);
      /* Cb */
      outptr1[col] = (JSAMPLE)
		((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF])
		 >> SCALEBITS);
      /* Cr */
      outptr2[col] = (JSAMPLE)
		((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF])
		 >> SCALEBITS);
    }
  }
}

// Assembly:
movq %rdi, -0x8(%rsp)
movq %rsi, -0x10(%rsp)
movq %rdx, -0x18(%rsp)
movl %ecx, -0x1c(%rsp)
movl %r8d, -0x20(%rsp)
movq -0x8(%rsp), %rax
movq 0x1d8(%rax), %rax
movq %rax, -0x28(%rsp)
movq -0x28(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rsp)
movq -0x8(%rsp), %rax
movl 0x30(%rax), %eax
movl %eax, -0x68(%rsp)
movl -0x20(%rsp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rsp)
cmpl $0x0, %eax
jl 0xdc014
movq -0x10(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x10(%rsp)
movq (%rax), %rax
movq %rax, -0x48(%rsp)
movq -0x18(%rsp), %rax
movq (%rax), %rax
movl -0x1c(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rsp)
movq -0x18(%rsp), %rax
movq 0x8(%rax), %rax
movl -0x1c(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rsp)
movq -0x18(%rsp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x60(%rsp)
movl -0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rsp)
movl $0x0, -0x64(%rsp)
movl -0x64(%rsp), %eax
cmpl -0x68(%rsp), %eax
jae 0xdc00f
movq -0x48(%rsp), %rax
movzbl (%rax), %eax
movl %eax, -0x2c(%rsp)
movq -0x48(%rsp), %rax
movzbl 0x1(%rax), %eax
movl %eax, -0x30(%rsp)
movq -0x48(%rsp), %rax
movzbl 0x2(%rax), %eax
movl %eax, -0x34(%rsp)
movq -0x48(%rsp), %rax
addq $0x3, %rax
movq %rax, -0x48(%rsp)
movq -0x40(%rsp), %rax
movl -0x2c(%rsp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq -0x40(%rsp), %rcx
movl -0x30(%rsp), %edx
addl $0x100, %edx            # imm = 0x100
movslq %edx, %rdx
addq (%rcx,%rdx,8), %rax
movq -0x40(%rsp), %rcx
movl -0x34(%rsp), %edx
addl $0x200, %edx            # imm = 0x200
movslq %edx, %rdx
addq (%rcx,%rdx,8), %rax
sarq $0x10, %rax
movb %al, %dl
movq -0x50(%rsp), %rax
movl -0x64(%rsp), %ecx
movb %dl, (%rax,%rcx)
movq -0x40(%rsp), %rax
movl -0x2c(%rsp), %ecx
addl $0x300, %ecx            # imm = 0x300
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq -0x40(%rsp), %rcx
movl -0x30(%rsp), %edx
addl $0x400, %edx            # imm = 0x400
movslq %edx, %rdx
addq (%rcx,%rdx,8), %rax
movq -0x40(%rsp), %rcx
movl -0x34(%rsp), %edx
addl $0x500, %edx            # imm = 0x500
movslq %edx, %rdx
addq (%rcx,%rdx,8), %rax
sarq $0x10, %rax
movb %al, %dl
movq -0x58(%rsp), %rax
movl -0x64(%rsp), %ecx
movb %dl, (%rax,%rcx)
movq -0x40(%rsp), %rax
movl -0x2c(%rsp), %ecx
addl $0x500, %ecx            # imm = 0x500
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq -0x40(%rsp), %rcx
movl -0x30(%rsp), %edx
addl $0x600, %edx            # imm = 0x600
movslq %edx, %rdx
addq (%rcx,%rdx,8), %rax
movq -0x40(%rsp), %rcx
movl -0x34(%rsp), %edx
addl $0x700, %edx            # imm = 0x700
movslq %edx, %rdx
addq (%rcx,%rdx,8), %rax
sarq $0x10, %rax
movb %al, %dl
movq -0x60(%rsp), %rax
movl -0x64(%rsp), %ecx
movb %dl, (%rax,%rcx)
movl -0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rsp)
jmp 0xdbec4
jmp 0xdbe43
retq
nopw %cs:(%rax,%rax)