// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/jpeg/jcmaster.c
// Function: prepare_for_pass
METHODDEF(void)
prepare_for_pass (j_compress_ptr cinfo)
{
  my_master_ptr master = (my_master_ptr) cinfo->master;

  switch (master->pass_type) {
  case main_pass:
    /* Initial pass: will collect input data, and do either Huffman
     * optimization or data output for the first scan.
     */
    select_scan_parameters(cinfo);
    per_scan_setup(cinfo);
    if (! cinfo->raw_data_in) {
      (*cinfo->cconvert->start_pass) (cinfo);
      (*cinfo->downsample->start_pass) (cinfo);
      (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU);
    }
    (*cinfo->fdct->start_pass) (cinfo);
    (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding);
    (*cinfo->coef->start_pass) (cinfo,
				(master->total_passes > 1 ?
				 JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
    (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
    if (cinfo->optimize_coding) {
      /* No immediate data output; postpone writing frame/scan headers */
      master->pub.call_pass_startup = FALSE;
    } else {
      /* Will write frame/scan headers at first jpeg_write_scanlines call */
      master->pub.call_pass_startup = TRUE;
    }
    break;
#ifdef ENTROPY_OPT_SUPPORTED
  case huff_opt_pass:
    /* Do Huffman optimization for a scan after the first one. */
    select_scan_parameters(cinfo);
    per_scan_setup(cinfo);
    if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code) {
      (*cinfo->entropy->start_pass) (cinfo, TRUE);
      (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
      master->pub.call_pass_startup = FALSE;
      break;
    }
    /* Special case: Huffman DC refinement scans need no Huffman table
     * and therefore we can skip the optimization pass for them.
     */
    master->pass_type = output_pass;
    master->pass_number++;
    /*FALLTHROUGH*/
#endif
  case output_pass:
    /* Do a data-output pass. */
    /* We need not repeat per-scan setup if prior optimization pass did it. */
    if (! cinfo->optimize_coding) {
      select_scan_parameters(cinfo);
      per_scan_setup(cinfo);
    }
    (*cinfo->entropy->start_pass) (cinfo, FALSE);
    (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
    /* We emit frame/scan headers now */
    if (master->scan_number == 0)
      (*cinfo->marker->write_frame_header) (cinfo);
    (*cinfo->marker->write_scan_header) (cinfo);
    master->pub.call_pass_startup = FALSE;
    break;
  default:
    ERREXIT(cinfo, JERR_NOT_COMPILED);
  }

  master->pub.is_last_pass = (master->pass_number == master->total_passes-1);

  /* 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->total_passes;
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x1b0(%rdi), %r14
movl 0x20(%r14), %eax
cmpl $0x2, %eax
je 0x745af
cmpl $0x1, %eax
je 0x74540
testl %eax, %eax
jne 0x74580
movq %rbx, %rdi
callq 0x746d0
movq %rbx, %rdi
callq 0x74846
cmpl $0x0, 0x100(%rbx)
jne 0x744e1
movq 0x1d8(%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movq 0x1e0(%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movq 0x1c0(%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
callq *(%rax)
movq 0x1e8(%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movq 0x1f0(%rbx), %rax
movl 0x108(%rbx), %esi
movq %rbx, %rdi
callq *(%rax)
movq 0x1c8(%rbx), %rax
xorl %ecx, %ecx
cmpl $0x2, 0x28(%r14)
setge %cl
leal (%rcx,%rcx,2), %esi
movq %rbx, %rdi
callq *(%rax)
movq 0x1b8(%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
callq *(%rax)
cmpl $0x0, 0x108(%rbx)
jne 0x74608
movl $0x1, 0x18(%r14)
jmp 0x74610
movq %rbx, %rdi
callq 0x746d0
movq %rbx, %rdi
callq 0x74846
cmpl $0x0, 0x19c(%rbx)
je 0x74591
movq 0x1f0(%rbx), %rax
movq %rbx, %rdi
movl $0x1, %esi
callq *(%rax)
movq 0x1c8(%rbx), %rax
movq %rbx, %rdi
movl $0x2, %esi
callq *(%rax)
jmp 0x74608
movq (%rbx), %rax
movl $0x30, 0x28(%rax)
movq %rbx, %rdi
callq *(%rax)
jmp 0x74610
cmpl $0x0, 0x1a4(%rbx)
je 0x74559
cmpl $0x0, 0x104(%rbx)
jne 0x74559
movl $0x2, 0x20(%r14)
incl 0x24(%r14)
cmpl $0x0, 0x108(%rbx)
jne 0x745c8
movq %rbx, %rdi
callq 0x746d0
movq %rbx, %rdi
callq 0x74846
movq 0x1f0(%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
callq *(%rax)
movq 0x1c8(%rbx), %rax
movq %rbx, %rdi
movl $0x2, %esi
callq *(%rax)
cmpl $0x0, 0x2c(%r14)
jne 0x745fb
movq 0x1d0(%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movq 0x1d0(%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movl $0x0, 0x18(%r14)
movl 0x24(%r14), %eax
movl 0x28(%r14), %ecx
leal -0x1(%rcx), %edx
xorl %esi, %esi
cmpl %edx, %eax
sete %sil
movl %esi, 0x1c(%r14)
movq 0x10(%rbx), %rdx
testq %rdx, %rdx
je 0x74636
movl %eax, 0x18(%rdx)
movl %ecx, 0x1c(%rdx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq