// File: tomfunkhouser[P]gaps/pkgs/jpeg/jdpostct.c
// Function: start_pass_dpost
METHODDEF(void)
start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
{
  my_post_ptr post = (my_post_ptr) cinfo->post;

  switch (pass_mode) {
  case JBUF_PASS_THRU:
    if (cinfo->quantize_colors) {
      /* Single-pass processing with color quantization. */
      post->pub.post_process_data = post_process_1pass;
      /* We could be doing buffered-image output before starting a 2-pass
       * color quantization; in that case, jinit_d_post_controller did not
       * allocate a strip buffer.  Use the virtual-array buffer as workspace.
       */
      if (post->buffer == NULL) {
	post->buffer = (*cinfo->mem->access_virt_sarray)
	  ((j_common_ptr) cinfo, post->whole_image,
	   (JDIMENSION) 0, post->strip_height, TRUE);
      }
    } else {
      /* For single-pass processing without color quantization,
       * I have no work to do; just call the upsampler directly.
       */
      post->pub.post_process_data = cinfo->upsample->upsample;
    }
    break;
#ifdef QUANT_2PASS_SUPPORTED
  case JBUF_SAVE_AND_PASS:
    /* First pass of 2-pass quantization */
    if (post->whole_image == NULL)
      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
    post->pub.post_process_data = post_process_prepass;
    break;
  case JBUF_CRANK_DEST:
    /* Second pass of 2-pass quantization */
    if (post->whole_image == NULL)
      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
    post->pub.post_process_data = post_process_2pass;
    break;
#endif /* QUANT_2PASS_SUPPORTED */
  default:
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
    break;
  }
  post->starting_row = post->next_row = 0;
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movl %esi, 0x1c(%rsp)
movq 0x20(%rsp), %rax
movq 0x238(%rax), %rax
movq %rax, 0x10(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0xc(%rsp)
testl %eax, %eax
je 0xeedbd
jmp 0xeed9c
movl 0xc(%rsp), %eax
subl $0x2, %eax
je 0xeee7c
jmp 0xeedab
movl 0xc(%rsp), %eax
subl $0x3, %eax
je 0xeee3d
jmp 0xeeebb
movq 0x20(%rsp), %rax
cmpl $0x0, 0x6c(%rax)
je 0xeee1f
movq 0x10(%rsp), %rax
leaq 0x12c(%rip), %rcx       # 0xeef00
movq %rcx, 0x8(%rax)
movq 0x10(%rsp), %rax
cmpq $0x0, 0x18(%rax)
jne 0xeee1d
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x38(%rax), %rax
movq 0x20(%rsp), %rdi
movq 0x10(%rsp), %rcx
movq 0x10(%rcx), %rsi
movq 0x10(%rsp), %rcx
movl 0x20(%rcx), %ecx
xorl %edx, %edx
movl $0x1, %r8d
callq *%rax
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x18(%rax)
jmp 0xeee38
movq 0x20(%rsp), %rax
movq 0x260(%rax), %rax
movq 0x8(%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x8(%rax)
jmp 0xeeedc
movq 0x10(%rsp), %rax
cmpq $0x0, 0x10(%rax)
jne 0xeee6a
movq 0x20(%rsp), %rax
movq (%rax), %rax
movl $0x4, 0x28(%rax)
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rdi
callq *%rax
movq 0x10(%rsp), %rax
leaq 0x17a(%rip), %rcx       # 0xeeff0
movq %rcx, 0x8(%rax)
jmp 0xeeedc
movq 0x10(%rsp), %rax
cmpq $0x0, 0x10(%rax)
jne 0xeeea9
movq 0x20(%rsp), %rax
movq (%rax), %rax
movl $0x4, 0x28(%rax)
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rdi
callq *%rax
movq 0x10(%rsp), %rax
leaq 0x2ab(%rip), %rcx       # 0xef160
movq %rcx, 0x8(%rax)
jmp 0xeeedc
movq 0x20(%rsp), %rax
movq (%rax), %rax
movl $0x4, 0x28(%rax)
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rdi
callq *%rax
movq 0x10(%rsp), %rax
movl $0x0, 0x28(%rax)
movq 0x10(%rsp), %rax
movl $0x0, 0x24(%rax)
addq $0x28, %rsp
retq
nopl (%rax)