// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/jpeg/jdcolor.c
// Function: jinit_color_deconverter
GLOBAL(void)
jinit_color_deconverter (j_decompress_ptr cinfo)
{
  my_cconvert_ptr cconvert;
  int ci;

  cconvert = (my_cconvert_ptr)
    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
				SIZEOF(my_color_deconverter));
  cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert;
  cconvert->pub.start_pass = start_pass_dcolor;

  /* Make sure num_components agrees with jpeg_color_space */
  switch (cinfo->jpeg_color_space) {
  case JCS_GRAYSCALE:
    if (cinfo->num_components != 1)
      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
    break;

  case JCS_RGB:
  case JCS_YCbCr:
    if (cinfo->num_components != 3)
      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
    break;

  case JCS_CMYK:
  case JCS_YCCK:
    if (cinfo->num_components != 4)
      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
    break;

  default:			/* JCS_UNKNOWN can be anything */
    if (cinfo->num_components < 1)
      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
    break;
  }

  /* Set out_color_components and conversion method based on requested space.
   * Also clear the component_needed flags for any unused components,
   * so that earlier pipeline stages can avoid useless computation.
   */

  switch (cinfo->out_color_space) {
  case JCS_GRAYSCALE:
    cinfo->out_color_components = 1;
    if (cinfo->jpeg_color_space == JCS_GRAYSCALE ||
	cinfo->jpeg_color_space == JCS_YCbCr) {
      cconvert->pub.color_convert = grayscale_convert;
      /* For color->grayscale conversion, only the Y (0) component is needed */
      for (ci = 1; ci < cinfo->num_components; ci++)
	cinfo->comp_info[ci].component_needed = FALSE;
    } else
      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
    break;

  case JCS_RGB:
    cinfo->out_color_components = RGB_PIXELSIZE;
    if (cinfo->jpeg_color_space == JCS_YCbCr) {
      cconvert->pub.color_convert = ycc_rgb_convert;
      build_ycc_rgb_table(cinfo);
    } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) {
      cconvert->pub.color_convert = gray_rgb_convert;
    } else if (cinfo->jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) {
      cconvert->pub.color_convert = null_convert;
    } else
      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
    break;

  case JCS_CMYK:
    cinfo->out_color_components = 4;
    if (cinfo->jpeg_color_space == JCS_YCCK) {
      cconvert->pub.color_convert = ycck_cmyk_convert;
      build_ycc_rgb_table(cinfo);
    } else if (cinfo->jpeg_color_space == JCS_CMYK) {
      cconvert->pub.color_convert = null_convert;
    } else
      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
    break;

  default:
    /* Permit null conversion to same output space */
    if (cinfo->out_color_space == cinfo->jpeg_color_space) {
      cinfo->out_color_components = cinfo->num_components;
      cconvert->pub.color_convert = null_convert;
    } else			/* unsupported non-null conversion */
      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
    break;
  }

  if (cinfo->quantize_colors)
    cinfo->output_components = 1; /* single colormapped output component */
  else
    cinfo->output_components = cinfo->out_color_components;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rax
movl $0x30, %edx
movl $0x1, %esi
callq *(%rax)
movq %rax, %r14
movq %rax, 0x268(%rbx)
leaq 0x263(%rip), %rax       # 0x83193
movq %rax, (%r14)
movl 0x3c(%rbx), %eax
leal -0x2(%rax), %ecx
cmpl $0x2, %ecx
jb 0x82f52
leal -0x4(%rax), %ecx
cmpl $0x2, %ecx
jae 0x830c5
cmpl $0x4, 0x38(%rbx)
jne 0x82f58
jmp 0x82f67
cmpl $0x3, 0x38(%rbx)
je 0x82f67
movq (%rbx), %rax
movl $0xa, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
movl 0x40(%rbx), %eax
cmpl $0x4, %eax
je 0x83106
cmpl $0x2, %eax
je 0x830dd
cmpl $0x1, %eax
jne 0x83132
movl $0x1, 0x90(%rbx)
movl 0x3c(%rbx), %eax
orl $0x2, %eax
cmpl $0x3, %eax
jne 0x8314d
leaq 0x1ef(%rip), %rax       # 0x83194
movq %rax, 0x8(%r14)
movslq 0x38(%rbx), %rcx
cmpq $0x2, %rcx
jl 0x8315c
leal 0x2(%rcx), %eax
andl $-0x4, %eax
addq $-0x2, %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movl $0x90, %ecx
addq 0x130(%rbx), %rcx
xorl %edx, %edx
movdqa 0x2753f(%rip), %xmm1    # 0xaa520
movdqa 0x1f297(%rip), %xmm2    # 0xa2280
movdqa 0x1f29f(%rip), %xmm3    # 0xa2290
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movq %rdx, %xmm5
pshufd $0x44, %xmm5, %xmm5     # xmm5 = xmm5[0,1,0,1]
movdqa %xmm5, %xmm6
por %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %esi
notl %esi
testb $0x1, %sil
je 0x83042
movl $0x0, (%rcx)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %esi
testb $0x1, %sil
je 0x83058
movl $0x0, 0x60(%rcx)
por %xmm1, %xmm5
pxor %xmm3, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
pxor %xmm4, %xmm5
pextrw $0x0, %xmm5, %esi
testb $0x1, %sil
je 0x83097
movl $0x0, 0xc0(%rcx)
pextrw $0x4, %xmm5, %esi
testb $0x1, %sil
je 0x830ac
movl $0x0, 0x120(%rcx)
addq $0x4, %rdx
addq $0x180, %rcx            # imm = 0x180
cmpq %rdx, %rax
jne 0x82ff9
jmp 0x8315c
cmpl $0x1, %eax
jne 0x8317b
cmpl $0x1, 0x38(%rbx)
jne 0x82f58
jmp 0x82f67
movl $0x3, 0x90(%rbx)
movl 0x3c(%rbx), %eax
cmpl $0x1, %eax
je 0x8318a
cmpl $0x2, %eax
je 0x83140
cmpl $0x3, %eax
jne 0x8314d
leaq 0xa9(%rip), %rax        # 0x831ad
jmp 0x83124
movl $0x4, 0x90(%rbx)
movl 0x3c(%rbx), %eax
cmpl $0x4, %eax
je 0x83140
cmpl $0x5, %eax
jne 0x8314d
leaq 0x31a(%rip), %rax       # 0x8343e
movq %rax, 0x8(%r14)
movq %rbx, %rdi
callq 0x832a1
jmp 0x8315c
cmpl 0x3c(%rbx), %eax
jne 0x8314d
movl 0x38(%rbx), %eax
movl %eax, 0x90(%rbx)
leaq 0x28c(%rip), %rax       # 0x833d3
movq %rax, 0x8(%r14)
jmp 0x8315c
movq (%rbx), %rax
movl $0x1b, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
movl $0x1, %eax
cmpl $0x0, 0x6c(%rbx)
jne 0x8316d
movl 0x90(%rbx), %eax
movl %eax, 0x94(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
cmpl $0x0, 0x38(%rbx)
jg 0x82f67
jmp 0x82f58
leaq 0x1ef(%rip), %rax       # 0x83380
jmp 0x83147