// File: tomfunkhouser[P]gaps/pkgs/jpeg/jccolor.c
// Function: cmyk_ycck_convert
METHODDEF(void)
cmyk_ycck_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, outptr3;
  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];
    outptr3 = output_buf[3][output_row];
    output_row++;
    for (col = 0; col < num_cols; col++) {
      r = MAXJSAMPLE - GETJSAMPLE(inptr[0]);
      g = MAXJSAMPLE - GETJSAMPLE(inptr[1]);
      b = MAXJSAMPLE - GETJSAMPLE(inptr[2]);
      /* K passes through as-is */
      outptr3[col] = inptr[3];	/* don't need GETJSAMPLE here */
      inptr += 4;
      /* 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, -0x70(%rsp)
movl -0x20(%rsp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rsp)
cmpl $0x0, %eax
jl 0xdc273
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)
movq -0x18(%rsp), %rax
movq 0x18(%rax), %rax
movl -0x1c(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x68(%rsp)
movl -0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rsp)
movl $0x0, -0x6c(%rsp)
movl -0x6c(%rsp), %eax
cmpl -0x70(%rsp), %eax
jae 0xdc26e
movq -0x48(%rsp), %rax
movzbl (%rax), %ecx
movl $0xff, %eax
subl %ecx, %eax
movl %eax, -0x2c(%rsp)
movq -0x48(%rsp), %rax
movzbl 0x1(%rax), %ecx
movl $0xff, %eax
subl %ecx, %eax
movl %eax, -0x30(%rsp)
movq -0x48(%rsp), %rax
movzbl 0x2(%rax), %ecx
movl $0xff, %eax
subl %ecx, %eax
movl %eax, -0x34(%rsp)
movq -0x48(%rsp), %rax
movb 0x3(%rax), %dl
movq -0x68(%rsp), %rax
movl -0x6c(%rsp), %ecx
movb %dl, (%rax,%rcx)
movq -0x48(%rsp), %rax
addq $0x4, %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 -0x6c(%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 -0x6c(%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 -0x6c(%rsp), %ecx
movb %dl, (%rax,%rcx)
movl -0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rsp)
jmp 0xdc0fa
jmp 0xdc063
retq
nopw %cs:(%rax,%rax)
nop