// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/jpeg/jdsample.c
// Function: jinit_upsampler
GLOBAL(void)
jinit_upsampler (j_decompress_ptr cinfo)
{
  my_upsample_ptr upsample;
  int ci;
  jpeg_component_info * compptr;
  jboolean need_buffer, do_fancy;
  int h_in_group, v_in_group, h_out_group, v_out_group;

  upsample = (my_upsample_ptr)
    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
				SIZEOF(my_upsampler));
  cinfo->upsample = (struct jpeg_upsampler *) upsample;
  upsample->pub.start_pass = start_pass_upsample;
  upsample->pub.upsample = sep_upsample;
  upsample->pub.need_context_rows = FALSE; /* until we find out differently */

  if (cinfo->CCIR601_sampling)	/* this isn't supported */
    ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);

  /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1,
   * so don't ask for it.
   */
  do_fancy = cinfo->do_fancy_upsampling && cinfo->min_DCT_scaled_size > 1;

  /* Verify we can handle the sampling factors, select per-component methods,
   * and create storage as needed.
   */
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
       ci++, compptr++) {
    /* Compute size of an "input group" after IDCT scaling.  This many samples
     * are to be converted to max_h_samp_factor * max_v_samp_factor pixels.
     */
    h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) /
		 cinfo->min_DCT_scaled_size;
    v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) /
		 cinfo->min_DCT_scaled_size;
    h_out_group = cinfo->max_h_samp_factor;
    v_out_group = cinfo->max_v_samp_factor;
    upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
    need_buffer = TRUE;
    if (! compptr->component_needed) {
      /* Don't bother to upsample an uninteresting component. */
      upsample->methods[ci] = noop_upsample;
      need_buffer = FALSE;
    } else if (h_in_group == h_out_group && v_in_group == v_out_group) {
      /* Fullsize components can be processed without any work. */
      upsample->methods[ci] = fullsize_upsample;
      need_buffer = FALSE;
    } else if (h_in_group * 2 == h_out_group &&
	       v_in_group == v_out_group) {
      /* Special cases for 2h1v upsampling */
      if (do_fancy && compptr->downsampled_width > 2)
	upsample->methods[ci] = h2v1_fancy_upsample;
      else
	upsample->methods[ci] = h2v1_upsample;
    } else if (h_in_group * 2 == h_out_group &&
	       v_in_group * 2 == v_out_group) {
      /* Special cases for 2h2v upsampling */
      if (do_fancy && compptr->downsampled_width > 2) {
	upsample->methods[ci] = h2v2_fancy_upsample;
	upsample->pub.need_context_rows = TRUE;
      } else
	upsample->methods[ci] = h2v2_upsample;
    } else if ((h_out_group % h_in_group) == 0 &&
	       (v_out_group % v_in_group) == 0) {
      /* Generic integral-factors upsampling method */
      upsample->methods[ci] = int_upsample;
      upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group);
      upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group);
    } else
      ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
    if (need_buffer) {
      upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray)
	((j_common_ptr) cinfo, JPOOL_IMAGE,
	 (JDIMENSION) jround_up((long) cinfo->output_width,
				(long) cinfo->max_h_samp_factor),
	 (JDIMENSION) cinfo->max_v_samp_factor);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %rax
pushq $0x1
popq %rsi
movl $0x100, %edx            # imm = 0x100
callq *(%rax)
movq %rax, %r14
movq %rax, 0x260(%rbx)
leaq 0x1dc(%rip), %rax       # 0x763c8
movq %rax, (%r14)
leaq 0x1f2(%rip), %rax       # 0x763e8
movq %rax, 0x8(%r14)
andl $0x0, 0x10(%r14)
cmpl $0x0, 0x188(%rbx)
je 0x76217
movq (%rbx), %rax
movl $0x19, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
cmpl $0x0, 0x64(%rbx)
je 0x7622d
cmpl $0x2, 0x1a0(%rbx)
setge %al
movl %eax, 0xc(%rsp)
jmp 0x76235
movl $0x0, 0xc(%rsp)
movq 0x130(%rbx), %r12
leaq 0x68(%r14), %r13
movq %r14, %rax
addq $0x18, %rax
movq %rax, 0x10(%rsp)
addq $0x30, %r12
xorl %r15d, %r15d
leaq 0x29c(%rip), %r9        # 0x764f6
movslq 0x38(%rbx), %rax
cmpq %rax, %r15
jge 0x763b9
movl -0xc(%r12), %ecx
movl -0x28(%r12), %eax
imull %ecx, %eax
movl 0x1a0(%rbx), %edi
cltd
idivl %edi
movl %eax, %esi
imull -0x24(%r12), %ecx
movl %ecx, %eax
cltd
idivl %edi
movl %eax, %ecx
movl 0x198(%rbx), %eax
movl 0x19c(%rbx), %edi
movl %ecx, 0xc0(%r14,%r15,4)
cmpl $0x0, (%r12)
movq %r13, %r8
movq %r9, %rdx
je 0x7638b
cmpl %eax, %esi
jne 0x762c7
movq %r13, %r8
leaq 0x23c(%rip), %rdx       # 0x764fb
cmpl %edi, %ecx
je 0x7638b
leal (%rsi,%rsi), %edx
cmpl %eax, %edx
jne 0x762ea
cmpl %edi, %ecx
jne 0x762ea
cmpb $0x0, 0xc(%rsp)
je 0x7631a
cmpl $0x3, -0x8(%r12)
jb 0x7631a
leaq 0x217(%rip), %rax       # 0x764ff
jmp 0x7634d
cmpl %eax, %edx
jne 0x76323
leal (%rcx,%rcx), %edx
cmpl %edi, %edx
jne 0x76323
cmpb $0x0, 0xc(%rsp)
je 0x76346
cmpl $0x3, -0x8(%r12)
jb 0x76346
leaq 0x2ea(%rip), %rax       # 0x765f5
movq %rax, 0x68(%r14,%r15,8)
movl $0x1, 0x10(%r14)
jmp 0x76352
leaq 0x293(%rip), %rax       # 0x765b4
jmp 0x7634d
cltd
idivl %esi
testl %edx, %edx
jne 0x76335
movl %eax, %esi
movl %edi, %eax
cltd
idivl %ecx
testl %edx, %edx
je 0x7639b
movq (%rbx), %rax
movl $0x26, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
jmp 0x76352
leaq 0x3ce(%rip), %rax       # 0x7671b
movq %rax, 0x68(%r14,%r15,8)
movq 0x8(%rbx), %rax
movq 0x10(%rax), %rbp
movl 0x88(%rbx), %edi
movslq 0x198(%rbx), %rsi
callq 0x7915d
movl 0x19c(%rbx), %ecx
movq %rbx, %rdi
pushq $0x1
popq %rsi
movl %eax, %edx
callq *%rbp
movq %rax, %rdx
movq 0x10(%rsp), %r8
leaq 0x16b(%rip), %r9        # 0x764f6
movq %rdx, (%r8,%r15,8)
incq %r15
addq $0x60, %r12
jmp 0x7625a
leaq 0x402(%rip), %rcx       # 0x767a4
movq %rcx, 0x68(%r14,%r15,8)
movb %sil, 0xe8(%r14,%r15)
movb %al, 0xf2(%r14,%r15)
jmp 0x76352
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq