// File: /workspace/github_cpp_makefile_star2_O3/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 0x161(%rip), %rax       # 0x762a0
movq %rax, (%r14)
leaq 0x158(%rip), %rax       # 0x762a1
movq %rax, 0x8(%r14)
movl $0x0, 0x10(%r14)
cmpl $0x0, 0x10c(%rbx)
je 0x7616d
movq (%rbx), %rax
movl $0x19, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
movl 0x4c(%rbx), %ecx
testl %ecx, %ecx
jle 0x7626e
movq 0x58(%rbx), %r15
addq $0xc, %r15
movl $0x1, %ebp
xorl %r12d, %r12d
leaq 0x3c9(%rip), %r13       # 0x76558
movl -0x4(%r15), %esi
movl 0x138(%rbx), %eax
cmpl %eax, %esi
jne 0x761ba
movl (%r15), %edx
cmpl 0x13c(%rbx), %edx
jne 0x761ba
cmpl $0x0, 0x110(%rbx)
je 0x76223
leaq 0x175(%rip), %rax       # 0x7632d
jmp 0x761eb
leal (%rsi,%rsi), %edx
cmpl %eax, %edx
jne 0x761fa
movl (%r15), %edx
movl 0x13c(%rbx), %edi
cmpl %edi, %edx
jne 0x761d5
movq %r13, 0x18(%r14,%r12,8)
jmp 0x76238
addl %edx, %edx
cmpl %edi, %edx
jne 0x761fa
cmpl $0x0, 0x110(%rbx)
je 0x7623c
leaq 0x442(%rip), %rax       # 0x7662d
movq %rax, 0x18(%r14,%r12,8)
movl $0x1, 0x10(%r14)
jmp 0x76248
cltd
idivl %esi
testl %edx, %edx
jne 0x7620f
movl 0x13c(%rbx), %eax
cltd
idivl (%r15)
testl %edx, %edx
je 0x7622c
movq (%rbx), %rax
movl $0x26, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
movl 0x4c(%rbx), %ecx
jmp 0x76248
leaq 0x2a5(%rip), %rax       # 0x764cf
jmp 0x76243
leaq 0x7b7(%rip), %rax       # 0x769ea
movq %rax, 0x18(%r14,%r12,8)
xorl %ebp, %ebp
jmp 0x76248
leaq 0x6ae(%rip), %rax       # 0x768f1
movq %rax, 0x18(%r14,%r12,8)
incq %r12
movslq %ecx, %rax
addq $0x60, %r15
cmpq %rax, %r12
jl 0x7618f
testl %ebp, %ebp
setne %al
cmpl $0x0, 0x110(%rbx)
sete %cl
orb %al, %cl
je 0x7627d
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