// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/jpeg/jdmainct.c
// Function: process_data_context_main
METHODDEF(void)
process_data_context_main (j_decompress_ptr cinfo,
			   JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
			   JDIMENSION out_rows_avail)
{
  my_main_ptr mainp = (my_main_ptr) cinfo->main;

  /* Read input data if we haven't filled the main buffer yet */
  if (! mainp->buffer_full) {
    if (! (*cinfo->coef->decompress_data) (cinfo,
					   mainp->xbuffer[mainp->whichptr]))
      return;			/* suspension forced, can do nothing more */
    mainp->buffer_full = TRUE;	/* OK, we have an iMCU row to work with */
    mainp->iMCU_row_ctr++;	/* count rows received */
  }

  /* Postprocessor typically will not swallow all the input data it is handed
   * in one call (due to filling the output buffer first).  Must be prepared
   * to exit and restart.  This switch lets us keep track of how far we got.
   * Note that each case falls through to the next on successful completion.
   */
  switch (mainp->context_state) {
  case CTX_POSTPONED_ROW:
    /* Call postprocessor using previously set pointers for postponed row */
    (*cinfo->post->post_process_data) (cinfo, mainp->xbuffer[mainp->whichptr],
			&mainp->rowgroup_ctr, mainp->rowgroups_avail,
			output_buf, out_row_ctr, out_rows_avail);
    if (mainp->rowgroup_ctr < mainp->rowgroups_avail)
      return;			/* Need to suspend */
    mainp->context_state = CTX_PREPARE_FOR_IMCU;
    if (*out_row_ctr >= out_rows_avail)
      return;			/* Postprocessor exactly filled output buf */
    /*FALLTHROUGH*/
  case CTX_PREPARE_FOR_IMCU:
    /* Prepare to process first M-1 row groups of this iMCU row */
    mainp->rowgroup_ctr = 0;
    mainp->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1);
    /* Check for bottom of image: if so, tweak pointers to "duplicate"
     * the last sample row, and adjust rowgroups_avail to ignore padding rows.
     */
    if (mainp->iMCU_row_ctr == cinfo->total_iMCU_rows)
      set_bottom_pointers(cinfo);
    mainp->context_state = CTX_PROCESS_IMCU;
    /*FALLTHROUGH*/
  case CTX_PROCESS_IMCU:
    /* Call postprocessor using previously set pointers */
    (*cinfo->post->post_process_data) (cinfo, mainp->xbuffer[mainp->whichptr],
			&mainp->rowgroup_ctr, mainp->rowgroups_avail,
			output_buf, out_row_ctr, out_rows_avail);
    if (mainp->rowgroup_ctr < mainp->rowgroups_avail)
      return;			/* Need to suspend */
    /* After the first iMCU, change wraparound pointers to normal state */
    if (mainp->iMCU_row_ctr == 1)
      set_wraparound_pointers(cinfo);
    /* Prepare to load new iMCU row using other xbuffer list */
    mainp->whichptr ^= 1;	/* 0=>1 or 1=>0 */
    mainp->buffer_full = FALSE;
    /* Still need to process last row group of this iMCU row, */
    /* which is saved at index M+1 of the other xbuffer */
    mainp->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1);
    mainp->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2);
    mainp->context_state = CTX_POSTPONED_ROW;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq 0x228(%rdi), %r12
cmpl $0x0, 0x60(%r12)
jne 0x7f995
movq 0x230(%rbx), %rax
movslq 0x78(%r12), %rcx
movq 0x68(%r12,%rcx,8), %rsi
movq %rbx, %rdi
callq *0x18(%rax)
testl %eax, %eax
je 0x7fcb3
movl $0x1, 0x60(%r12)
incl 0x84(%r12)
movl 0x7c(%r12), %eax
testl %eax, %eax
je 0x7fa02
cmpl $0x1, %eax
je 0x7fb70
cmpl $0x2, %eax
jne 0x7fcb3
movq 0x238(%rbx), %rax
movslq 0x78(%r12), %rcx
movq 0x68(%r12,%rcx,8), %rsi
leaq 0x64(%r12), %rdx
movl 0x80(%r12), %ecx
movl %ebp, (%rsp)
movq %rbx, %rdi
movq %r15, %r8
movq %r14, %r9
callq *0x8(%rax)
movl 0x64(%r12), %eax
cmpl 0x80(%r12), %eax
jb 0x7fcb3
movl $0x0, 0x7c(%r12)
cmpl %ebp, (%r14)
jae 0x7fcb3
movq %r15, 0x10(%rsp)
movl $0x0, 0x64(%r12)
movl 0x1a0(%rbx), %r8d
leal -0x1(%r8), %eax
movl %eax, 0x80(%r12)
movl 0x84(%r12), %eax
cmpl 0x1a4(%rbx), %eax
jne 0x7fb62
movslq 0x38(%rbx), %r9
testq %r9, %r9
jle 0x7fb62
movq 0x130(%rbx), %r10
movq 0x228(%rbx), %r11
movslq 0x78(%r11), %r13
xorl %r15d, %r15d
movdqa 0x2281f(%rip), %xmm0    # 0xa2280
movdqa 0x22827(%rip), %xmm1    # 0xa2290
pcmpeqd %xmm2, %xmm2
movdqa 0x2282b(%rip), %xmm3    # 0xa22a0
movl 0x24(%r10), %esi
movl 0x2c(%r10), %edi
imull 0xc(%r10), %esi
movl %esi, %eax
cltd
idivl %r8d
movl %eax, %ecx
movl %edi, %eax
xorl %edx, %edx
divl %esi
testl %edx, %edx
cmovnel %edx, %esi
testq %r15, %r15
jne 0x7faa9
leal -0x1(%rsi), %eax
cltd
idivl %ecx
incl %eax
movl %eax, 0x80(%r11)
testl %ecx, %ecx
jle 0x7fb52
movq 0x68(%r11,%r13,8), %rax
movq (%rax,%r15,8), %rax
movslq %esi, %rdx
leaq (%rax,%rdx,8), %rax
addq $0x8, %rax
movq -0x10(%rax), %rdx
addl %ecx, %ecx
cmpl $0x2, %ecx
movl $0x1, %esi
cmovll %esi, %ecx
movl %ecx, %esi
incl %esi
decq %rcx
movq %rcx, %xmm4
pshufd $0x44, %xmm4, %xmm4     # xmm4 = xmm4[0,1,0,1]
andl $-0x2, %esi
shlq $0x3, %rsi
pxor %xmm1, %xmm4
xorl %ecx, %ecx
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, %edi
notl %edi
testb $0x1, %dil
je 0x7fb32
movq %rdx, -0x8(%rax,%rcx)
pxor %xmm2, %xmm6
pextrw $0x4, %xmm6, %edi
testb $0x1, %dil
je 0x7fb45
movq %rdx, (%rax,%rcx)
paddq %xmm3, %xmm5
addq $0x10, %rcx
cmpq %rcx, %rsi
jne 0x7faf8
incq %r15
addq $0x60, %r10
cmpq %r9, %r15
jne 0x7fa75
movl $0x1, 0x7c(%r12)
movq 0x10(%rsp), %r15
movq 0x238(%rbx), %rax
movslq 0x78(%r12), %rcx
movq 0x68(%r12,%rcx,8), %rsi
leaq 0x64(%r12), %rdx
movl 0x80(%r12), %ecx
movl %ebp, (%rsp)
movq %rbx, %rdi
movq %r15, %r8
movq %r14, %r9
callq *0x8(%rax)
movl 0x64(%r12), %eax
cmpl 0x80(%r12), %eax
jb 0x7fcb3
movq %r12, 0x20(%rsp)
cmpl $0x1, 0x84(%r12)
movl 0x1a0(%rbx), %ecx
jne 0x7fc8d
movslq 0x38(%rbx), %rax
movq %rax, 0x10(%rsp)
testq %rax, %rax
jle 0x7fc8d
movq 0x130(%rbx), %rdi
movq 0x228(%rbx), %r8
leal 0x1(%rcx), %eax
movl %eax, 0x1c(%rsp)
leal 0x2(%rcx), %eax
movl %eax, 0x18(%rsp)
xorl %r11d, %r11d
movl 0x24(%rdi), %eax
imull 0xc(%rdi), %eax
cltd
idivl %ecx
testl %eax, %eax
jle 0x7fc7b
movq 0x68(%r8), %rdx
movq 0x70(%r8), %rsi
movq (%rdx,%r11,8), %rdx
movq (%rsi,%r11,8), %rbx
movl %eax, %esi
imull 0x1c(%rsp), %esi
movslq %esi, %rsi
movl %eax, %r14d
imull 0x18(%rsp), %eax
movslq %eax, %r9
shlq $0x3, %r14
leaq (%rbx,%r9,8), %rax
leaq (%rdx,%r9,8), %r15
movq %rbx, %r13
subq %r14, %r13
movq %rdx, %rbp
subq %r14, %rbp
leaq (%rbx,%rsi,8), %r9
leaq (%rdx,%rsi,8), %r10
xorl %esi, %esi
movq (%r10,%rsi), %r12
movq %r12, (%rbp,%rsi)
movq (%r9,%rsi), %r12
movq %r12, (%r13,%rsi)
movq (%rdx,%rsi), %r12
movq %r12, (%r15,%rsi)
movq (%rbx,%rsi), %r12
movq %r12, (%rax,%rsi)
addq $0x8, %rsi
cmpq %rsi, %r14
jne 0x7fc50
incq %r11
addq $0x60, %rdi
cmpq 0x10(%rsp), %r11
jne 0x7fbfb
movq 0x20(%rsp), %rdx
xorb $0x1, 0x78(%rdx)
movl $0x0, 0x60(%rdx)
leal 0x1(%rcx), %eax
movl %eax, 0x64(%rdx)
addl $0x2, %ecx
movl %ecx, 0x80(%rdx)
movl $0x2, 0x7c(%rdx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq