// File: tomfunkhouser[P]gaps/pkgs/jpeg/jcapimin.c
// Function: jpeg_CreateCompress
GLOBAL(void)
jpeg_CreateCompress (j_compress_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_compress_struct))
    ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, 
	     (int) SIZEOF(struct jpeg_compress_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_compress_struct));
    cinfo->err = err;
    cinfo->client_data = client_data;
  }
  cinfo->is_decompressor = FALSE;

  /* 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->dest = NULL;

  cinfo->comp_info = 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;
  }

  cinfo->script_space = NULL;

  cinfo->input_gamma = 1.0;	/* in case application forgets */

  /* OK, I'm ready */
  cinfo->global_state = CSTATE_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 0xd5165
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 $0x208, 0x20(%rsp)      # imm = 0x208
je 0xd51b2
movq 0x30(%rsp), %rax
movq (%rax), %rax
movl $0x15, 0x28(%rax)
movq 0x30(%rsp), %rax
movq (%rax), %rax
movl $0x208, 0x2c(%rax)      # imm = 0x208
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 $0x208, %edx            # imm = 0x208
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 $0x0, 0x20(%rax)
movq 0x30(%rsp), %rdi
callq 0xf9890
movq 0x30(%rsp), %rax
movq $0x0, 0x10(%rax)
movq 0x30(%rsp), %rax
movq $0x0, 0x28(%rax)
movq 0x30(%rsp), %rax
movq $0x0, 0x58(%rax)
movl $0x0, 0x1c(%rsp)
cmpl $0x4, 0x1c(%rsp)
jge 0xd5265
movq 0x30(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq $0x0, 0x60(%rax,%rcx,8)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0xd523e
movl $0x0, 0x1c(%rsp)
cmpl $0x4, 0x1c(%rsp)
jge 0xd52ad
movq 0x30(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq $0x0, 0x80(%rax,%rcx,8)
movq 0x30(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq $0x0, 0xa0(%rax,%rcx,8)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0xd526d
movq 0x30(%rsp), %rax
movq $0x0, 0x1f8(%rax)
movq 0x30(%rsp), %rax
movsd 0x5dd3e(%rip), %xmm0    # 0x133008
movsd %xmm0, 0x40(%rax)
movq 0x30(%rsp), %rax
movl $0x64, 0x24(%rax)
addq $0x38, %rsp
retq