// File: /workspace/github_cpp_makefile_star2_O1/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
movl $0x68, %edx
movl $0x1, %esi
callq *(%rax)
movq %rax, %r14
movq %rax, 0x1e0(%rbx)
leaq 0x170(%rip), %rax       # 0x771e7
movq %rax, (%r14)
leaq 0x167(%rip), %rax       # 0x771e8
movq %rax, 0x8(%r14)
movl $0x0, 0x10(%r14)
cmpl $0x0, 0x10c(%rbx)
je 0x770a5
movq (%rbx), %rax
movl $0x19, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
cmpl $0x0, 0x4c(%rbx)
jle 0x771a2
movq 0x58(%rbx), %r15
addq $0xc, %r15
movl $0x1, %ebp
xorl %r12d, %r12d
leaq 0x3d6(%rip), %r13       # 0x7749c
movl -0x4(%r15), %ecx
movl 0x138(%rbx), %eax
cmpl %eax, %ecx
jne 0x770fe
movl (%r15), %edx
cmpl 0x13c(%rbx), %edx
jne 0x770fe
cmpl $0x0, 0x110(%rbx)
je 0x77160
leaq 0x185(%rip), %rax       # 0x77274
movq %rax, 0x18(%r14,%r12,8)
movl $0x1, 0x10(%r14)
jmp 0x7717c
leal (%rcx,%rcx), %edx
cmpl %eax, %edx
jne 0x7713a
movl (%r15), %esi
cmpl 0x13c(%rbx), %esi
jne 0x77117
movq %r13, 0x18(%r14,%r12,8)
jmp 0x7717a
cmpl %eax, %edx
jne 0x7713a
movl (%r15), %edx
addl %edx, %edx
cmpl 0x13c(%rbx), %edx
jne 0x7713a
cmpl $0x0, 0x110(%rbx)
je 0x77192
leaq 0x436(%rip), %rax       # 0x7756e
jmp 0x770ef
cltd
idivl %ecx
testl %edx, %edx
jne 0x7714f
movl 0x13c(%rbx), %eax
cltd
idivl (%r15)
testl %edx, %edx
je 0x7716e
movq (%rbx), %rax
movl $0x26, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
jmp 0x7717c
leaq 0x2ac(%rip), %rax       # 0x77413
movq %rax, 0x18(%r14,%r12,8)
jmp 0x7717c
leaq 0x7b2(%rip), %rax       # 0x77927
movq %rax, 0x18(%r14,%r12,8)
xorl %ebp, %ebp
incq %r12
movslq 0x4c(%rbx), %rax
addq $0x60, %r15
cmpq %rax, %r12
jl 0x770c6
jmp 0x7719b
leaq 0x699(%rip), %rax       # 0x77832
jmp 0x77167
testl %ebp, %ebp
setne %al
jmp 0x771a4
movb $0x1, %al
cmpl $0x0, 0x110(%rbx)
sete %cl
orb %al, %cl
testb $0x1, %cl
je 0x771c4
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