// File: tomfunkhouser[P]gaps/pkgs/jpeg/jccoefct.c
// Function: jinit_c_coef_controller
GLOBAL(void)
jinit_c_coef_controller (j_compress_ptr cinfo, jboolean need_full_buffer)
{
  my_coef_ptr coef;

  coef = (my_coef_ptr)
    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
				SIZEOF(my_coef_controller));
  cinfo->coef = (struct jpeg_c_coef_controller *) coef;
  coef->pub.start_pass = start_pass_coef;

  /* Create the coefficient buffer. */
  if (need_full_buffer) {
#ifdef FULL_COEF_BUFFER_SUPPORTED
    /* Allocate a full-image virtual array for each component, */
    /* padded to a multiple of samp_factor DCT blocks in each direction. */
    int ci;
    jpeg_component_info *compptr;

    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
	 ci++, compptr++) {
      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
	((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
	 (JDIMENSION) jround_up((long) compptr->width_in_blocks,
				(long) compptr->h_samp_factor),
	 (JDIMENSION) jround_up((long) compptr->height_in_blocks,
				(long) compptr->v_samp_factor),
	 (JDIMENSION) compptr->v_samp_factor);
    }
#else
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
#endif
  } else {
    /* We only need a single-MCU buffer. */
    JBLOCKROW buffer;
    int i;

    buffer = (JBLOCKROW)
      (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
				  C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
    for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
      coef->MCU_buffer[i] = buffer + i;
    }
    coef->whole_image[0] = NULL; /* flag for no virtual arrays */
  }
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movl %esi, 0x4c(%rsp)
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x50(%rsp), %rdi
movl $0x1, %esi
movl $0xc0, %edx
callq *%rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rcx
movq 0x50(%rsp), %rax
movq %rcx, 0x1c8(%rax)
movq 0x40(%rsp), %rax
leaq 0x154(%rip), %rcx       # 0xda930
movq %rcx, (%rax)
cmpl $0x0, 0x4c(%rsp)
je 0xda8ba
movl $0x0, 0x3c(%rsp)
movq 0x50(%rsp), %rax
movq 0x58(%rax), %rax
movq %rax, 0x30(%rsp)
movl 0x3c(%rsp), %eax
movq 0x50(%rsp), %rcx
cmpl 0x4c(%rcx), %eax
jge 0xda8b8
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rax
movl 0x1c(%rax), %eax
movl %eax, %edi
movq 0x30(%rsp), %rax
movslq 0x8(%rax), %rsi
callq 0xf9330
movl %eax, 0x14(%rsp)
movq 0x30(%rsp), %rax
movl 0x20(%rax), %eax
movl %eax, %edi
movq 0x30(%rsp), %rax
movslq 0xc(%rax), %rsi
callq 0xf9330
movq 0x8(%rsp), %rdi
movl 0x14(%rsp), %ecx
movq %rax, %rdx
movq 0x18(%rsp), %rax
movl %edx, %r8d
movq 0x30(%rsp), %rdx
movl 0xc(%rdx), %r9d
movl $0x1, %esi
xorl %edx, %edx
callq *%rax
movq %rax, %rdx
movq 0x40(%rsp), %rax
movslq 0x3c(%rsp), %rcx
movq %rdx, 0x70(%rax,%rcx,8)
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
movq 0x30(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x30(%rsp)
jmp 0xda800
jmp 0xda926
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq 0x50(%rsp), %rdi
movl $0x1, %esi
movl $0x500, %edx            # imm = 0x500
callq *%rax
movq %rax, 0x28(%rsp)
movl $0x0, 0x24(%rsp)
cmpl $0xa, 0x24(%rsp)
jge 0xda919
movq 0x28(%rsp), %rdx
movslq 0x24(%rsp), %rax
shlq $0x7, %rax
addq %rax, %rdx
movq 0x40(%rsp), %rax
movslq 0x24(%rsp), %rcx
movq %rdx, 0x20(%rax,%rcx,8)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0xda8e5
movq 0x40(%rsp), %rax
movq $0x0, 0x70(%rax)
addq $0x58, %rsp
retq
nopl (%rax,%rax)