// File: tomfunkhouser[P]gaps/pkgs/jpeg/jdmainct.c
// Function: alloc_funny_pointers
LOCAL(void)
alloc_funny_pointers (j_decompress_ptr cinfo)
/* Allocate space for the funny pointer lists.
 * This is done only once, not once per pass.
 */
{
  my_main_ptr mainp = (my_main_ptr) cinfo->main;
  int ci, rgroup;
  int M = cinfo->min_DCT_scaled_size;
  jpeg_component_info *compptr;
  JSAMPARRAY xbuf;

  /* Get top-level space for component array pointers.
   * We alloc both arrays with one call to save a few cycles.
   */
  mainp->xbuffer[0] = (JSAMPIMAGE)
    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
				cinfo->num_components * 2 * SIZEOF(JSAMPARRAY));
  mainp->xbuffer[1] = mainp->xbuffer[0] + cinfo->num_components;

  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
       ci++, compptr++) {
    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /
      cinfo->min_DCT_scaled_size; /* height of a row group of component */
    /* Get space for pointer lists --- M+4 row groups in each list.
     * We alloc both pointer lists with one call to save a few cycles.
     */
    xbuf = (JSAMPARRAY)
      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
				  2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW));
    xbuf += rgroup;		/* want one row group at negative offsets */
    mainp->xbuffer[0][ci] = xbuf;
    xbuf += rgroup * (M + 4);
    mainp->xbuffer[1][ci] = xbuf;
  }
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq 0x228(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x30(%rsp), %rax
movl 0x1a0(%rax), %eax
movl %eax, 0x1c(%rsp)
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x30(%rsp), %rdi
movq 0x30(%rsp), %rcx
movl 0x38(%rcx), %ecx
shll %ecx
movslq %ecx, %rdx
shlq $0x3, %rdx
movl $0x1, %esi
callq *%rax
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x68(%rax)
movq 0x28(%rsp), %rax
movq 0x68(%rax), %rcx
movq 0x30(%rsp), %rax
movslq 0x38(%rax), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x70(%rax)
movl $0x0, 0x24(%rsp)
movq 0x30(%rsp), %rax
movq 0x130(%rax), %rax
movq %rax, 0x10(%rsp)
movl 0x24(%rsp), %eax
movq 0x30(%rsp), %rcx
cmpl 0x38(%rcx), %eax
jge 0xec846
movq 0x10(%rsp), %rax
movl 0xc(%rax), %eax
movq 0x10(%rsp), %rcx
imull 0x24(%rcx), %eax
movq 0x30(%rsp), %rcx
cltd
idivl 0x1a0(%rcx)
movl %eax, 0x20(%rsp)
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x30(%rsp), %rdi
movl 0x20(%rsp), %ecx
movl 0x1c(%rsp), %edx
addl $0x4, %edx
imull %edx, %ecx
shll %ecx
movslq %ecx, %rdx
shlq $0x3, %rdx
movl $0x1, %esi
callq *%rax
movq %rax, 0x8(%rsp)
movl 0x20(%rsp), %ecx
movq 0x8(%rsp), %rax
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rdx
movq 0x28(%rsp), %rax
movq 0x68(%rax), %rax
movslq 0x24(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0x20(%rsp), %ecx
movl 0x1c(%rsp), %eax
addl $0x4, %eax
imull %eax, %ecx
movq 0x8(%rsp), %rax
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rdx
movq 0x28(%rsp), %rax
movq 0x70(%rax), %rax
movslq 0x24(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
movq 0x10(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x10(%rsp)
jmp 0xec759
addq $0x38, %rsp
retq
nopl (%rax,%rax)