// File: tomfunkhouser[P]gaps/pkgs/jpeg/jdapistd.c
// Function: output_pass_setup
LOCAL(jboolean)
output_pass_setup (j_decompress_ptr cinfo)
{
  if (cinfo->global_state != DSTATE_PRESCAN) {
    /* First call: do pass setup */
    (*cinfo->master->prepare_for_output_pass) (cinfo);
    cinfo->output_scanline = 0;
    cinfo->global_state = DSTATE_PRESCAN;
  }
  /* Loop over any required dummy passes */
  while (cinfo->master->is_dummy_pass) {
#ifdef QUANT_2PASS_SUPPORTED
    /* Crank through the dummy pass */
    while (cinfo->output_scanline < cinfo->output_height) {
      JDIMENSION last_scanline;
      /* Call progress monitor hook if present */
      if (cinfo->progress != NULL) {
	cinfo->progress->pass_counter = (long) cinfo->output_scanline;
	cinfo->progress->pass_limit = (long) cinfo->output_height;
	(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
      }
      /* Process some data */
      last_scanline = cinfo->output_scanline;
      (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL,
				    &cinfo->output_scanline, (JDIMENSION) 0);
      if (cinfo->output_scanline == last_scanline)
	return FALSE;		/* No progress made, must suspend */
    }
    /* Finish up dummy pass, and set up for another one */
    (*cinfo->master->finish_output_pass) (cinfo);
    (*cinfo->master->prepare_for_output_pass) (cinfo);
    cinfo->output_scanline = 0;
#else
    ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif /* QUANT_2PASS_SUPPORTED */
  }
  /* Ready for application to drive output pass through
   * jpeg_read_scanlines or jpeg_read_raw_data.
   */
  cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING;
  return TRUE;
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x8(%rsp)
movq 0x8(%rsp), %rax
cmpl $0xcc, 0x24(%rax)
je 0xe2f38
movq 0x8(%rsp), %rax
movq 0x220(%rax), %rax
movq (%rax), %rax
movq 0x8(%rsp), %rdi
callq *%rax
movq 0x8(%rsp), %rax
movl $0x0, 0xa8(%rax)
movq 0x8(%rsp), %rax
movl $0xcc, 0x24(%rax)
jmp 0xe2f3a
movq 0x8(%rsp), %rax
movq 0x220(%rax), %rax
cmpl $0x0, 0x10(%rax)
je 0xe305a
jmp 0xe2f52
movq 0x8(%rsp), %rax
movl 0xa8(%rax), %eax
movq 0x8(%rsp), %rcx
cmpl 0x8c(%rcx), %eax
jae 0xe3019
movq 0x8(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0xe2fc1
movq 0x8(%rsp), %rax
movl 0xa8(%rax), %eax
movl %eax, %ecx
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x8(%rax)
movq 0x8(%rsp), %rax
movl 0x8c(%rax), %eax
movl %eax, %ecx
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x10(%rax)
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq 0x8(%rsp), %rdi
callq *%rax
movq 0x8(%rsp), %rax
movl 0xa8(%rax), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rax
movq 0x228(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rsp), %rdi
movq 0x8(%rsp), %rdx
addq $0xa8, %rdx
xorl %ecx, %ecx
movl %ecx, %esi
xorl %ecx, %ecx
callq *%rax
movq 0x8(%rsp), %rax
movl 0xa8(%rax), %eax
cmpl 0x4(%rsp), %eax
jne 0xe3014
movl $0x0, 0x14(%rsp)
jmp 0xe3082
jmp 0xe2f52
movq 0x8(%rsp), %rax
movq 0x220(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rsp), %rdi
callq *%rax
movq 0x8(%rsp), %rax
movq 0x220(%rax), %rax
movq (%rax), %rax
movq 0x8(%rsp), %rdi
callq *%rax
movq 0x8(%rsp), %rax
movl $0x0, 0xa8(%rax)
jmp 0xe2f3a
movq 0x8(%rsp), %rax
movl 0x5c(%rax), %edx
movl $0xcd, %ecx
movl $0xce, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0x24(%rax)
movl $0x1, 0x14(%rsp)
movl 0x14(%rsp), %eax
addq $0x18, %rsp
retq
nopl (%rax,%rax)