// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/jpeg/jcsample.c
// Function: jinit_downsampler
GLOBAL(void)
jinit_downsampler (j_compress_ptr cinfo)
{
  my_downsample_ptr downsample;
  int ci;
  jpeg_component_info * compptr;
  jboolean smoothok = TRUE;

  downsample = (my_downsample_ptr)
    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
				SIZEOF(my_downsampler));
  cinfo->downsample = (struct jpeg_downsampler *) downsample;
  downsample->pub.start_pass = start_pass_downsample;
  downsample->pub.downsample = sep_downsample;
  downsample->pub.need_context_rows = FALSE;

  if (cinfo->CCIR601_sampling)
    ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);

  /* Verify we can handle the sampling factors, and set up method pointers */
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
       ci++, compptr++) {
    if (compptr->h_samp_factor == cinfo->max_h_samp_factor &&
	compptr->v_samp_factor == cinfo->max_v_samp_factor) {
#ifdef INPUT_SMOOTHING_SUPPORTED
      if (cinfo->smoothing_factor) {
	downsample->methods[ci] = fullsize_smooth_downsample;
	downsample->pub.need_context_rows = TRUE;
      } else
#endif
	downsample->methods[ci] = fullsize_downsample;
    } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
	       compptr->v_samp_factor == cinfo->max_v_samp_factor) {
      smoothok = FALSE;
      downsample->methods[ci] = h2v1_downsample;
    } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
	       compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) {
#ifdef INPUT_SMOOTHING_SUPPORTED
      if (cinfo->smoothing_factor) {
	downsample->methods[ci] = h2v2_smooth_downsample;
	downsample->pub.need_context_rows = TRUE;
      } else
#endif
	downsample->methods[ci] = h2v2_downsample;
    } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 &&
	       (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) {
      smoothok = FALSE;
      downsample->methods[ci] = int_downsample;
    } else
      ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
  }

#ifdef INPUT_SMOOTHING_SUPPORTED
  if (cinfo->smoothing_factor && !smoothok)
    TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL);
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rax
pushq $0x1
popq %rbp
pushq $0x68
popq %rdx
movl %ebp, %esi
callq *(%rax)
movq %rax, %r14
movq %rax, 0x1e0(%rbx)
leaq 0x151(%rip), %rax       # 0x6bcc6
movq %rax, (%r14)
leaq 0x148(%rip), %rax       # 0x6bcc7
movq %rax, 0x8(%r14)
andl $0x0, 0x10(%r14)
cmpl $0x0, 0x10c(%rbx)
je 0x6bba0
movq (%rbx), %rax
movl $0x19, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
movq 0x58(%rbx), %r15
addq $0xc, %r15
xorl %r12d, %r12d
leaq 0x346(%rip), %r13       # 0x6bef8
movslq 0x4c(%rbx), %rax
cmpq %rax, %r12
jge 0x6bc81
movl -0x4(%r15), %ecx
movl 0x138(%rbx), %eax
cmpl %eax, %ecx
jne 0x6bbea
movl (%r15), %edx
cmpl 0x13c(%rbx), %edx
jne 0x6bbea
cmpl $0x0, 0x110(%rbx)
je 0x6bc50
leaq 0x15b(%rip), %rax       # 0x6bd43
jmp 0x6bc1b
leal (%rcx,%rcx), %edx
cmpl %eax, %edx
jne 0x6bc2a
movl (%r15), %edx
movl 0x13c(%rbx), %esi
cmpl %esi, %edx
jne 0x6bc05
movq %r13, 0x18(%r14,%r12,8)
jmp 0x6bc65
addl %edx, %edx
cmpl %esi, %edx
jne 0x6bc2a
cmpl $0x0, 0x110(%rbx)
je 0x6bc69
leaq 0x35a(%rip), %rax       # 0x6bf75
movq %rax, 0x18(%r14,%r12,8)
movl $0x1, 0x10(%r14)
jmp 0x6bc75
cltd
idivl %ecx
testl %edx, %edx
jne 0x6bc3f
movl 0x13c(%rbx), %eax
cltd
idivl (%r15)
testl %edx, %edx
je 0x6bc59
movq (%rbx), %rax
movl $0x26, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
jmp 0x6bc75
leaq 0x25a(%rip), %rax       # 0x6beb1
jmp 0x6bc70
leaq 0x635(%rip), %rax       # 0x6c295
movq %rax, 0x18(%r14,%r12,8)
xorl %ebp, %ebp
jmp 0x6bc75
leaq 0x57f(%rip), %rax       # 0x6c1ef
movq %rax, 0x18(%r14,%r12,8)
incq %r12
addq $0x60, %r15
jmp 0x6bbb2
cmpl $0x0, 0x110(%rbx)
sete %al
testl %ebp, %ebp
setne %cl
orb %al, %cl
je 0x6bca3
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rax
movl $0x63, 0x28(%rax)
movq 0x8(%rax), %rax
movq %rbx, %rdi
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax