// File: /workspace/github_cpp_makefile_star2_O1/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 0x806e6
testl %esi, %esi
jne 0x806f2
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x260(%rdi), %rax
cmpl $0x0, 0x10(%rax)
je 0x806fe
leaq 0x1d4(%rip), %rax       # 0x8071c
movq %rax, 0x8(%rcx)
movslq 0x38(%rdi), %rsi
testq %rsi, %rsi
jle 0x806d2
movl 0x1a0(%rdi), %r8d
movq 0x130(%rdi), %rdi
leal 0x2(%r8), %r9d
leal -0x2(%r8), %eax
movl %eax, -0x4(%rsp)
xorl %r11d, %r11d
movdqa 0x21d02(%rip), %xmm0    # 0xa2280
movdqa 0x21d0a(%rip), %xmm1    # 0xa2290
pcmpeqd %xmm2, %xmm2
movdqa 0x21d0e(%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 0x805d5
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 0x805c1
testl %eax, %eax
jle 0x806c2
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 0x80614
testl %eax, %eax
jle 0x806c2
movl %eax, %ebx
incl %eax
leaq -0x1(%rbx), %r14
movq %r14, %xmm4
pshufd $0x44, %xmm4, %xmm4     # xmm4 = xmm4[0,1,0,1]
shlq $0x3, %rbx
movq %rdx, %r14
subq %rbx, %r14
addq $0x8, %r14
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
movq (%rdx), %r12
movd %xmm6, %ebx
notl %ebx
testb $0x1, %bl
je 0x806a3
movq %r12, -0x8(%r14,%r15)
pxor %xmm2, %xmm6
pextrw $0x4, %xmm6, %ebx
testb $0x1, %bl
je 0x806b5
movq %r12, (%r14,%r15)
paddq %xmm3, %xmm5
addq $0x10, %r15
cmpq %r15, %rax
jne 0x80667
incq %r11
addq $0x60, %rdi
cmpq %rsi, %r11
jne 0x80592
movq $0x0, 0x78(%rcx)
movl $0x0, 0x84(%rcx)
jmp 0x80709
leaq 0x47d(%rip), %rax       # 0x80b6a
movq %rax, 0x8(%rcx)
retq
movq (%rdi), %rax
movl $0x4, 0x28(%rax)
jmpq *(%rax)
leaq 0x3df(%rip), %rax       # 0x80ae4
movq %rax, 0x8(%rcx)
movq $0x0, 0x60(%rcx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq