// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/jpeg/jdmainct.c
// Function: start_pass_main
METHODDEF(void)
start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
{
  my_main_ptr mainp = (my_main_ptr) cinfo->main;

  switch (pass_mode) {
  case JBUF_PASS_THRU:
    if (cinfo->upsample->need_context_rows) {
      mainp->pub.process_data = process_data_context_main;
      make_funny_pointers(cinfo); /* Create the xbuffer[] lists */
      mainp->whichptr = 0;	/* Read first iMCU row into xbuffer[0] */
      mainp->context_state = CTX_PREPARE_FOR_IMCU;
      mainp->iMCU_row_ctr = 0;
    } else {
      /* Simple case with no context needed */
      mainp->pub.process_data = process_data_simple_main;
    }
    mainp->buffer_full = FALSE;	/* Mark buffer empty */
    mainp->rowgroup_ctr = 0;
    break;
#ifdef QUANT_2PASS_SUPPORTED
  case JBUF_CRANK_DEST:
    /* For last pass of 2-pass quantization, just crank the postprocessor */
    mainp->pub.process_data = process_data_crank_post;
    break;
#endif
  default:
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
    break;
  }
}

// Assembly:
movq 0x228(%rdi), %rcx
cmpl $0x2, %esi
je 0x7f907
testl %esi, %esi
jne 0x7f913
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x260(%rdi), %rax
cmpl $0x0, 0x10(%rax)
je 0x7f91f
leaq 0x1cc(%rip), %rax       # 0x7f93d
movq %rax, 0x8(%rcx)
movslq 0x38(%rdi), %rsi
testq %rsi, %rsi
jle 0x7f8f3
movl 0x1a0(%rdi), %r8d
movq 0x130(%rdi), %rdi
leal 0x2(%r8), %r9d
leal -0x2(%r8), %eax
movl %eax, -0x4(%rsp)
xorl %r11d, %r11d
movdqa 0x22ad9(%rip), %xmm0    # 0xa2280
movdqa 0x22ae1(%rip), %xmm1    # 0xa2290
pcmpeqd %xmm2, %xmm2
movdqa 0x22ae5(%rip), %xmm3    # 0xa22a0
movl 0x24(%rdi), %eax
imull 0xc(%rdi), %eax
cltd
idivl %r8d
movq 0x68(%rcx), %rdx
movq 0x70(%rcx), %rbx
movq (%rdx,%r11,8), %rdx
movq (%rbx,%r11,8), %r14
movq 0x10(%rcx,%r11,8), %r15
movl %eax, %ebx
imull %r9d, %ebx
testl %ebx, %ebx
jle 0x7f7fe
movl %ebx, %r12d
xorl %ebx, %ebx
movq (%r15,%rbx,8), %r13
movq %r13, (%r14,%rbx,8)
movq %r13, (%rdx,%rbx,8)
incq %rbx
cmpq %rbx, %r12
jne 0x7f7ea
testl %eax, %eax
jle 0x7f8e3
leal (%rax,%rax), %r12d
movl %eax, %ebx
imull %r8d, %ebx
movl %eax, %ebp
imull -0x4(%rsp), %ebp
movslq %ebx, %rbx
movslq %ebp, %rbp
cmpl $0x2, %r12d
movl $0x1, %r10d
cmovll %r10d, %r12d
leaq (%r15,%rbp,8), %r13
leaq (%r14,%rbp,8), %rbp
leaq (%r14,%rbx,8), %r14
leaq (%r15,%rbx,8), %r15
xorl %ebx, %ebx
movq (%r15,%rbx,8), %r10
movq %r10, (%rbp,%rbx,8)
movq (%r13,%rbx,8), %r10
movq %r10, (%r14,%rbx,8)
incq %rbx
cmpq %rbx, %r12
jne 0x7f83d
movl %eax, %ebx
movq (%rdx), %r14
incl %eax
leaq -0x1(%rbx), %r15
movq %r15, %xmm4
pshufd $0x44, %xmm4, %xmm4     # xmm4 = xmm4[0,1,0,1]
shlq $0x3, %rbx
negq %rbx
addq %rbx, %rdx
addq $0x8, %rdx
shrl %eax
shlq $0x4, %rax
pxor %xmm1, %xmm4
xorl %r15d, %r15d
movdqa %xmm0, %xmm5
movdqa %xmm5, %xmm6
pxor %xmm1, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm4, %xmm7
pcmpeqd %xmm4, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %ebx
notl %ebx
testb $0x1, %bl
je 0x7f8c4
movq %r14, -0x8(%rdx,%r15)
pxor %xmm2, %xmm6
pextrw $0x4, %xmm6, %ebx
testb $0x1, %bl
je 0x7f8d6
movq %r14, (%rdx,%r15)
paddq %xmm3, %xmm5
addq $0x10, %r15
cmpq %r15, %rax
jne 0x7f88b
incq %r11
addq $0x60, %rdi
cmpq %rsi, %r11
jne 0x7f7bb
movq $0x0, 0x78(%rcx)
movl $0x0, 0x84(%rcx)
jmp 0x7f92a
leaq 0x43a(%rip), %rax       # 0x7fd48
movq %rax, 0x8(%rcx)
retq
movq (%rdi), %rax
movl $0x4, 0x28(%rax)
jmpq *(%rax)
leaq 0x39c(%rip), %rax       # 0x7fcc2
movq %rax, 0x8(%rcx)
movq $0x0, 0x60(%rcx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq