// File: /workspace/github_cpp_makefile_star2_O1/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 0x80774
movq 0x230(%rbx), %rax
movslq 0x78(%r12), %rcx
movq 0x68(%r12,%rcx,8), %rsi
movq %rbx, %rdi
callq *0x18(%rax)
testl %eax, %eax
je 0x80ad5
movl $0x1, 0x60(%r12)
incl 0x84(%r12)
movl 0x7c(%r12), %eax
testl %eax, %eax
je 0x807e1
cmpl $0x1, %eax
je 0x80971
cmpl $0x2, %eax
jne 0x80ad5
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 0x80ad5
movl $0x0, 0x7c(%r12)
cmpl %ebp, (%r14)
jae 0x80ad5
movq %r15, 0x10(%rsp)
movq %r14, 0x18(%rsp)
movl $0x0, 0x64(%r12)
movl 0x1a0(%rbx), %r8d
leal -0x1(%r8), %eax
movl %eax, 0x80(%r12)
movl 0x84(%r12), %eax
movq %rbx, 0x8(%rsp)
cmpl 0x1a4(%rbx), %eax
jne 0x80959
movq 0x8(%rsp), %rax
movslq 0x38(%rax), %r9
testq %r9, %r9
jle 0x80959
movq 0x8(%rsp), %rax
movq 0x130(%rax), %r10
movq 0x228(%rax), %r11
movslq 0x78(%r11), %r13
xorl %r15d, %r15d
movdqa 0x21a2c(%rip), %xmm0    # 0xa2280
movdqa 0x21a34(%rip), %xmm1    # 0xa2290
pcmpeqd %xmm2, %xmm2
movdqa 0x21a38(%rip), %xmm3    # 0xa22a0
movl 0x24(%r10), %ecx
movl 0x2c(%r10), %edi
imull 0xc(%r10), %ecx
movl %ecx, %eax
cltd
idivl %r8d
movl %eax, %esi
movl %edi, %eax
xorl %edx, %edx
divl %ecx
testl %edx, %edx
cmovnel %edx, %ecx
testq %r15, %r15
jne 0x8089c
leal -0x1(%rcx), %eax
cltd
idivl %esi
incl %eax
movl %eax, 0x80(%r11)
testl %esi, %esi
jle 0x80949
movq 0x68(%r11,%r13,8), %rax
movq (%rax,%r15,8), %rax
addl %esi, %esi
cmpl $0x2, %esi
movl $0x1, %edx
cmovll %edx, %esi
movslq %ecx, %rcx
movl %esi, %edx
incl %edx
decq %rsi
movq %rsi, %xmm4
pshufd $0x44, %xmm4, %xmm4     # xmm4 = xmm4[0,1,0,1]
leaq (%rax,%rcx,8), %rsi
addq $0x8, %rsi
andl $-0x2, %edx
shlq $0x3, %rdx
pxor %xmm1, %xmm4
xorl %edi, %edi
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 -0x8(%rax,%rcx,8), %rbx
movd %xmm6, %r14d
notl %r14d
testb $0x1, %r14b
je 0x80928
movq %rbx, -0x8(%rsi,%rdi)
pxor %xmm2, %xmm6
pextrw $0x4, %xmm6, %r14d
testb $0x1, %r14b
je 0x8093c
movq %rbx, (%rsi,%rdi)
paddq %xmm3, %xmm5
addq $0x10, %rdi
cmpq %rdi, %rdx
jne 0x808e7
incq %r15
addq $0x60, %r10
cmpq %r9, %r15
jne 0x80868
movl $0x1, 0x7c(%r12)
movq 0x8(%rsp), %rbx
movq 0x18(%rsp), %r14
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 0x80ad5
movq %rbx, 0x8(%rsp)
cmpl $0x1, 0x84(%r12)
jne 0x80a9f
movq 0x8(%rsp), %rax
movslq 0x38(%rax), %rax
movq %rax, 0x18(%rsp)
testq %rax, %rax
jle 0x80a9f
movq 0x8(%rsp), %rax
movl 0x1a0(%rax), %ecx
movq 0x130(%rax), %rdi
movq 0x228(%rax), %r8
leal 0x1(%rcx), %eax
movl %eax, 0x24(%rsp)
movq %rcx, 0x10(%rsp)
leal 0x2(%rcx), %eax
movl %eax, 0x20(%rsp)
xorl %r11d, %r11d
movl 0x24(%rdi), %eax
imull 0xc(%rdi), %eax
cltd
idivl 0x10(%rsp)
testl %eax, %eax
jle 0x80a8d
movq 0x68(%r8), %rcx
movq 0x70(%r8), %rdx
movq (%rcx,%r11,8), %rbx
movq (%rdx,%r11,8), %r14
movl %eax, %ecx
imull 0x24(%rsp), %ecx
movslq %ecx, %rcx
movl %eax, %r15d
imull 0x20(%rsp), %eax
movslq %eax, %rdx
shlq $0x3, %r15
leaq (%r14,%rdx,8), %rax
leaq (%rbx,%rdx,8), %r13
movq %r14, %rbp
subq %r15, %rbp
movq %rbx, %rdx
subq %r15, %rdx
leaq (%r14,%rcx,8), %r9
leaq (%rbx,%rcx,8), %r10
xorl %ecx, %ecx
movq (%r10,%rcx), %rsi
movq %rsi, (%rdx,%rcx)
movq (%r9,%rcx), %rsi
movq %rsi, (%rbp,%rcx)
movq (%rbx,%rcx), %rsi
movq %rsi, (%r13,%rcx)
movq (%r14,%rcx), %rsi
movq %rsi, (%rax,%rcx)
addq $0x8, %rcx
cmpq %rcx, %r15
jne 0x80a62
incq %r11
addq $0x60, %rdi
cmpq 0x18(%rsp), %r11
jne 0x80a0b
xorb $0x1, 0x78(%r12)
movl $0x0, 0x60(%r12)
movq 0x8(%rsp), %rax
movl 0x1a0(%rax), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x64(%r12)
addl $0x2, %eax
movl %eax, 0x80(%r12)
movl $0x2, 0x7c(%r12)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq