// File: /workspace/github_cpp_makefile_star2_O3/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
movl $0x100, %edx            # imm = 0x100
movl $0x1, %esi
callq *(%rax)
movq %rax, %r14
movq %rax, 0x260(%rbx)
leaq 0x1e2(%rip), %rax       # 0x829cc
movq %rax, (%r14)
leaq 0x1f8(%rip), %rax       # 0x829ec
movq %rax, 0x8(%r14)
movl $0x0, 0x10(%r14)
cmpl $0x0, 0x188(%rbx)
je 0x82818
movq (%rbx), %rax
movl $0x19, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
cmpl $0x0, 0x64(%rbx)
je 0x8282e
cmpl $0x2, 0x1a0(%rbx)
setge %al
movl %eax, 0xc(%rsp)
jmp 0x82836
movl $0x0, 0xc(%rsp)
cmpl $0x0, 0x38(%rbx)
jle 0x829bd
movq 0x130(%rbx), %r15
leaq 0x68(%r14), %r12
movq %r14, %rax
addq $0x18, %rax
movq %rax, 0x10(%rsp)
addq $0x30, %r15
xorl %ebp, %ebp
leaq 0x2a1(%rip), %r9        # 0x82b05
movl -0xc(%r15), %ecx
movl -0x28(%r15), %eax
imull %ecx, %eax
movl 0x1a0(%rbx), %edi
cltd
idivl %edi
movl %eax, %esi
imull -0x24(%r15), %ecx
movl %ecx, %eax
cltd
idivl %edi
movl %eax, %ecx
movl 0x198(%rbx), %eax
movl 0x19c(%rbx), %edi
movl %ecx, 0xc0(%r14,%rbp,4)
cmpl $0x0, (%r15)
movq %r12, %r8
movq %r9, %rdx
je 0x82985
cmpl %eax, %esi
jne 0x828c0
movq %r12, %r8
leaq 0x255(%rip), %rdx       # 0x82b0d
cmpl %edi, %ecx
je 0x82985
leal (%rsi,%rsi), %edx
cmpl %eax, %edx
jne 0x828e2
cmpl %edi, %ecx
jne 0x828e2
cmpb $0x0, 0xc(%rsp)
je 0x82911
cmpl $0x3, -0x8(%r15)
jb 0x82911
leaq 0x231(%rip), %rax       # 0x82b11
jmp 0x82944
cmpl %eax, %edx
jne 0x8291a
leal (%rcx,%rcx), %edx
cmpl %edi, %edx
jne 0x8291a
cmpb $0x0, 0xc(%rsp)
je 0x8293d
cmpl $0x3, -0x8(%r15)
jb 0x8293d
leaq 0x323(%rip), %rax       # 0x82c25
movq %rax, 0x68(%r14,%rbp,8)
movl $0x1, 0x10(%r14)
jmp 0x82949
leaq 0x2b4(%rip), %rax       # 0x82bcc
jmp 0x82944
cltd
idivl %esi
testl %edx, %edx
jne 0x8292c
movl %eax, %esi
movl %edi, %eax
cltd
idivl %ecx
testl %edx, %edx
je 0x8299f
movq (%rbx), %rax
movl $0x26, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
jmp 0x82949
leaq 0x422(%rip), %rax       # 0x82d66
movq %rax, 0x68(%r14,%rbp,8)
movq 0x8(%rbx), %rax
movq 0x10(%rax), %r13
movl 0x88(%rbx), %edi
movslq 0x198(%rbx), %rsi
callq 0x85ca1
movl 0x19c(%rbx), %ecx
movq %rbx, %rdi
movl $0x1, %esi
movl %eax, %edx
callq *%r13
movq %rax, %rdx
movq 0x10(%rsp), %r8
leaq 0x180(%rip), %r9        # 0x82b05
movq %rdx, (%r8,%rbp,8)
incq %rbp
movslq 0x38(%rbx), %rax
addq $0x60, %r15
cmpq %rax, %rbp
jl 0x82864
jmp 0x829bd
leaq 0x45b(%rip), %rcx       # 0x82e01
movq %rcx, 0x68(%r14,%rbp,8)
movb %sil, 0xe8(%r14,%rbp)
movb %al, 0xf2(%r14,%rbp)
jmp 0x82949
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq