// File: tomfunkhouser[P]gaps/pkgs/jpeg/jdapimin.c
// Function: jpeg_CreateDecompress
GLOBAL(void)
jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
{
  int i;

  /* Guard against version mismatches between library and caller. */
  cinfo->mem = NULL;		/* so jpeg_destroy knows mem mgr not called */
  if (version != JPEG_LIB_VERSION)
    ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
  if (structsize != SIZEOF(struct jpeg_decompress_struct))
    ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, 
	     (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize);

  /* For debugging purposes, we zero the whole master structure.
   * But the application has already set the err pointer, and may have set
   * client_data, so we have to save and restore those fields.
   * Note: if application hasn't set client_data, tools like Purify may
   * complain here.
   */
  {
    struct jpeg_error_mgr * err = cinfo->err;
    void * client_data = cinfo->client_data; /* ignore Purify complaint here */
    MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct));
    cinfo->err = err;
    cinfo->client_data = client_data;
  }
  cinfo->is_decompressor = TRUE;

  /* Initialize a memory manager instance for this object */
  jinit_memory_mgr((j_common_ptr) cinfo);

  /* Zero out pointers to permanent structures. */
  cinfo->progress = NULL;
  cinfo->src = NULL;

  for (i = 0; i < NUM_QUANT_TBLS; i++)
    cinfo->quant_tbl_ptrs[i] = NULL;

  for (i = 0; i < NUM_HUFF_TBLS; i++) {
    cinfo->dc_huff_tbl_ptrs[i] = NULL;
    cinfo->ac_huff_tbl_ptrs[i] = NULL;
  }

  /* Initialize marker processor so application can override methods
   * for COM, APPn markers before calling jpeg_read_header.
   */
  cinfo->marker_list = NULL;
  jinit_marker_reader(cinfo);

  /* And initialize the overall input controller. */
  jinit_input_controller(cinfo);

  /* OK, I'm ready */
  cinfo->global_state = DSTATE_START;
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movl %esi, 0x2c(%rsp)
movq %rdx, 0x20(%rsp)
movq 0x30(%rsp), %rax
movq $0x0, 0x8(%rax)
cmpl $0x3e, 0x2c(%rsp)
je 0xe23b5
movq 0x30(%rsp), %rax
movq (%rax), %rax
movl $0xc, 0x28(%rax)
movq 0x30(%rsp), %rax
movq (%rax), %rax
movl $0x3e, 0x2c(%rax)
movl 0x2c(%rsp), %ecx
movq 0x30(%rsp), %rax
movq (%rax), %rax
movl %ecx, 0x30(%rax)
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq 0x30(%rsp), %rdi
callq *%rax
cmpq $0x278, 0x20(%rsp)      # imm = 0x278
je 0xe2402
movq 0x30(%rsp), %rax
movq (%rax), %rax
movl $0x15, 0x28(%rax)
movq 0x30(%rsp), %rax
movq (%rax), %rax
movl $0x278, 0x2c(%rax)      # imm = 0x278
movq 0x20(%rsp), %rax
movl %eax, %ecx
movq 0x30(%rsp), %rax
movq (%rax), %rax
movl %ecx, 0x30(%rax)
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq 0x30(%rsp), %rdi
callq *%rax
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rdi
xorl %esi, %esi
movl $0x278, %edx            # imm = 0x278
callq 0xf280
movq 0x10(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, (%rax)
movq 0x8(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x30(%rsp), %rax
movl $0x1, 0x20(%rax)
movq 0x30(%rsp), %rdi
callq 0xf9890
movq 0x30(%rsp), %rax
movq $0x0, 0x10(%rax)
movq 0x30(%rsp), %rax
movq $0x0, 0x28(%rax)
movl $0x0, 0x1c(%rsp)
cmpl $0x4, 0x1c(%rsp)
jge 0xe24ab
movq 0x30(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq $0x0, 0xc8(%rax,%rcx,8)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0xe2481
movl $0x0, 0x1c(%rsp)
cmpl $0x4, 0x1c(%rsp)
jge 0xe24f3
movq 0x30(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq $0x0, 0xe8(%rax,%rcx,8)
movq 0x30(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq $0x0, 0x108(%rax,%rcx,8)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0xe24b3
movq 0x30(%rsp), %rax
movq $0x0, 0x190(%rax)
movq 0x30(%rsp), %rdi
callq 0xe57c0
movq 0x30(%rsp), %rdi
callq 0xe4790
movq 0x30(%rsp), %rax
movl $0xc8, 0x24(%rax)
addq $0x38, %rsp
retq
nopl (%rax,%rax)