// File: tomfunkhouser[P]gaps/pkgs/jpeg/jdapistd.c
// Function: jpeg_start_decompress
GLOBAL(jboolean)
jpeg_start_decompress (j_decompress_ptr cinfo)
{
  if (cinfo->global_state == DSTATE_READY) {
    /* First call: initialize master control, select active modules */
    jinit_master_decompress(cinfo);
    if (cinfo->buffered_image) {
      /* No more work here; expecting jpeg_start_output next */
      cinfo->global_state = DSTATE_BUFIMAGE;
      return TRUE;
    }
    cinfo->global_state = DSTATE_PRELOAD;
  }
  if (cinfo->global_state == DSTATE_PRELOAD) {
    /* If file has multiple scans, absorb them all into the coef buffer */
    if (cinfo->inputctl->has_multiple_scans) {
#ifdef D_MULTISCAN_FILES_SUPPORTED
      for (;;) {
	int retcode;
	/* Call progress monitor hook if present */
	if (cinfo->progress != NULL)
	  (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
	/* Absorb some more input */
	retcode = (*cinfo->inputctl->consume_input) (cinfo);
	if (retcode == JPEG_SUSPENDED)
	  return FALSE;
	if (retcode == JPEG_REACHED_EOI)
	  break;
	/* Advance progress counter if appropriate */
	if (cinfo->progress != NULL &&
	    (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
	  if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
	    /* jdmaster underestimated number of scans; ratchet up one scan */
	    cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
	  }
	}
      }
#else
      ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif /* D_MULTISCAN_FILES_SUPPORTED */
    }
    cinfo->output_scan_number = cinfo->input_scan_number;
  } else if (cinfo->global_state != DSTATE_PRESCAN)
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  /* Perform any dummy output passes, and set up for the final pass */
  return output_pass_setup(cinfo);
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x8(%rsp)
movq 0x8(%rsp), %rax
cmpl $0xca, 0x24(%rax)
jne 0xe2d91
movq 0x8(%rsp), %rdi
callq 0xe3ea0
movq 0x8(%rsp), %rax
cmpl $0x0, 0x58(%rax)
je 0xe2d85
movq 0x8(%rsp), %rax
movl $0xcf, 0x24(%rax)
movl $0x1, 0x14(%rsp)
jmp 0xe2ee0
movq 0x8(%rsp), %rax
movl $0xcb, 0x24(%rax)
movq 0x8(%rsp), %rax
cmpl $0xcb, 0x24(%rax)
jne 0xe2e8e
movq 0x8(%rsp), %rax
movq 0x240(%rax), %rax
cmpl $0x0, 0x20(%rax)
je 0xe2e76
jmp 0xe2dbb
movq 0x8(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0xe2dda
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq 0x8(%rsp), %rdi
callq *%rax
movq 0x8(%rsp), %rax
movq 0x240(%rax), %rax
movq (%rax), %rax
movq 0x8(%rsp), %rdi
callq *%rax
movl %eax, 0x4(%rsp)
cmpl $0x0, 0x4(%rsp)
jne 0xe2e08
movl $0x0, 0x14(%rsp)
jmp 0xe2ee0
cmpl $0x2, 0x4(%rsp)
jne 0xe2e11
jmp 0xe2e74
movq 0x8(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0xe2e6f
cmpl $0x3, 0x4(%rsp)
je 0xe2e2b
cmpl $0x1, 0x4(%rsp)
jne 0xe2e6f
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0x8(%rcx), %rax
addq $0x1, %rax
movq %rax, 0x8(%rcx)
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rcx
cmpq 0x10(%rcx), %rax
jl 0xe2e6d
movq 0x8(%rsp), %rax
movl 0x1a4(%rax), %eax
movl %eax, %ecx
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
jmp 0xe2e6f
jmp 0xe2dbb
jmp 0xe2e76
movq 0x8(%rsp), %rax
movl 0xac(%rax), %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0xb4(%rax)
jmp 0xe2ed2
movq 0x8(%rsp), %rax
cmpl $0xcc, 0x24(%rax)
je 0xe2ed0
movq 0x8(%rsp), %rax
movq (%rax), %rax
movl $0x14, 0x28(%rax)
movq 0x8(%rsp), %rax
movl 0x24(%rax), %ecx
movq 0x8(%rsp), %rax
movq (%rax), %rax
movl %ecx, 0x2c(%rax)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq 0x8(%rsp), %rdi
callq *%rax
jmp 0xe2ed2
movq 0x8(%rsp), %rdi
callq 0xe2ef0
movl %eax, 0x14(%rsp)
movl 0x14(%rsp), %eax
addq $0x18, %rsp
retq
nopl (%rax)