// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/jpeg/jdmaster.c
// Function: prepare_for_output_pass
METHODDEF(void)
prepare_for_output_pass (j_decompress_ptr cinfo)
{
  my_master_ptr master = (my_master_ptr) cinfo->master;

  if (master->pub.is_dummy_pass) {
#ifdef QUANT_2PASS_SUPPORTED
    /* Final pass of 2-pass quantization */
    master->pub.is_dummy_pass = FALSE;
    (*cinfo->cquantize->start_pass) (cinfo, FALSE);
    (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST);
    (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST);
#else
    ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif /* QUANT_2PASS_SUPPORTED */
  } else {
    if (cinfo->quantize_colors && cinfo->colormap == NULL) {
      /* Select new quantization method */
      if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) {
	cinfo->cquantize = master->quantizer_2pass;
	master->pub.is_dummy_pass = TRUE;
      } else if (cinfo->enable_1pass_quant) {
	cinfo->cquantize = master->quantizer_1pass;
      } else {
	ERREXIT(cinfo, JERR_MODE_CHANGE);
      }
    }
    (*cinfo->idct->start_pass) (cinfo);
    (*cinfo->coef->start_output_pass) (cinfo);
    if (! cinfo->raw_data_out) {
      if (! master->using_merged_upsample)
	(*cinfo->cconvert->start_pass) (cinfo);
      (*cinfo->upsample->start_pass) (cinfo);
      if (cinfo->quantize_colors)
	(*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass);
      (*cinfo->post->start_pass) (cinfo,
	    (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
      (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
    }
  }

  /* Set up progress monitor's pass info if present */
  if (cinfo->progress != NULL) {
    cinfo->progress->completed_passes = master->pass_number;
    cinfo->progress->total_passes = master->pass_number +
				    (master->pub.is_dummy_pass ? 2 : 1);
    /* In buffered-image mode, we assume one more output pass if EOI not
     * yet reached, but no more passes if EOI has been reached.
     */
    if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) {
      cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x220(%rdi), %r14
cmpl $0x0, 0x10(%r14)
je 0x6fa34
andl $0x0, 0x10(%r14)
movq 0x270(%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
callq *(%rax)
movq 0x238(%rbx), %rax
pushq $0x2
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq *(%rax)
movq 0x228(%rbx), %rax
movq %rbx, %rdi
movl %ebp, %esi
callq *(%rax)
jmp 0x6fa67
cmpl $0x0, 0x6c(%rbx)
je 0x6fa48
cmpq $0x0, 0xa0(%rbx)
je 0x6fb02
movq 0x258(%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movq 0x230(%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
cmpl $0x0, 0x5c(%rbx)
je 0x6faad
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x6faa8
movl 0x18(%r14), %ecx
movl %ecx, 0x18(%rax)
cmpl $0x1, 0x10(%r14)
sbbl $0x0, %ecx
addl $0x2, %ecx
movl %ecx, 0x1c(%rax)
cmpl $0x0, 0x58(%rbx)
je 0x6faa8
movq 0x240(%rbx), %rdx
cmpl $0x0, 0x24(%rdx)
jne 0x6faa8
cmpl $0x1, 0x84(%rbx)
sbbl $0x0, %ecx
addl $0x2, %ecx
movl %ecx, 0x1c(%rax)
popq %rbx
popq %r14
popq %rbp
retq
cmpl $0x0, 0x1c(%r14)
jne 0x6fac0
movq 0x268(%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movq 0x260(%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
cmpl $0x0, 0x6c(%rbx)
je 0x6fae2
movq 0x270(%rbx), %rax
movl 0x10(%r14), %esi
movq %rbx, %rdi
callq *(%rax)
movq 0x238(%rbx), %rax
xorl %ecx, %ecx
cmpl $0x0, 0x10(%r14)
setne %cl
leal (%rcx,%rcx,2), %esi
movq %rbx, %rdi
callq *(%rax)
xorl %ebp, %ebp
jmp 0x6fa24
cmpl $0x0, 0x74(%rbx)
je 0x6fb29
cmpl $0x0, 0x84(%rbx)
je 0x6fb29
movq 0x28(%r14), %rax
movq %rax, 0x270(%rbx)
movl $0x1, 0x10(%r14)
jmp 0x6fa48
cmpl $0x0, 0x7c(%rbx)
je 0x6fb3f
movq 0x20(%r14), %rax
movq %rax, 0x270(%rbx)
jmp 0x6fa48
movq (%rbx), %rax
movl $0x2e, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
jmp 0x6fa48