// File: /workspace/github_cpp_makefile_star2_O2/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), %rdi
cmpl $0x0, 0x60(%rdi)
movq %rdi, 0x8(%rsp)
jne 0x7363b
movq 0x230(%rbx), %rax
movslq 0x78(%rdi), %rcx
movq 0x68(%rdi,%rcx,8), %rsi
movq %rbx, %rdi
callq *0x18(%rax)
movq 0x8(%rsp), %rdi
testl %eax, %eax
je 0x738d7
movl $0x1, 0x60(%rdi)
incl 0x84(%rdi)
movl 0x7c(%rdi), %eax
testl %eax, %eax
je 0x7369e
cmpl $0x1, %eax
je 0x7376d
cmpl $0x2, %eax
jne 0x738d7
movq 0x238(%rbx), %rax
movslq 0x78(%rdi), %rcx
movq 0x68(%rdi,%rcx,8), %rsi
leaq 0x64(%rdi), %rdx
movl 0x80(%rdi), %ecx
movl %ebp, (%rsp)
movq %rbx, %rdi
movq %r15, %r8
movq %r14, %r9
callq *0x8(%rax)
movq 0x8(%rsp), %rdi
movl 0x64(%rdi), %eax
cmpl 0x80(%rdi), %eax
jb 0x738d7
andl $0x0, 0x7c(%rdi)
cmpl %ebp, (%r14)
jae 0x738d7
movq %r15, 0x10(%rsp)
andl $0x0, 0x64(%rdi)
movl 0x1a0(%rbx), %r8d
leal -0x1(%r8), %eax
movl %eax, 0x80(%rdi)
movl 0x84(%rdi), %eax
cmpl 0x1a4(%rbx), %eax
jne 0x7375c
movq 0x228(%rbx), %r9
movq 0x130(%rbx), %r10
movl 0x38(%rbx), %r11d
xorl %r13d, %r13d
testl %r11d, %r11d
cmovlel %r13d, %r11d
xorl %r15d, %r15d
cmpq %r11, %r15
je 0x7375c
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 0x73722
leal -0x1(%rsi), %eax
cltd
idivl %ecx
incl %eax
movl %eax, 0x80(%r9)
movslq 0x78(%r9), %rax
movq 0x68(%r9,%rax,8), %rax
movq (%rax,%r15,8), %rax
addl %ecx, %ecx
movslq %esi, %rdx
testl %ecx, %ecx
cmovlel %r13d, %ecx
leaq (%rax,%rdx,8), %rsi
xorl %edi, %edi
cmpq %rdi, %rcx
je 0x73753
movq -0x8(%rax,%rdx,8), %r12
movq %r12, (%rsi,%rdi,8)
incq %rdi
jmp 0x73740
incq %r15
addq $0x60, %r10
jmp 0x736e9
movq 0x8(%rsp), %rdi
movl $0x1, 0x7c(%rdi)
movq 0x10(%rsp), %r15
movq 0x238(%rbx), %rax
movslq 0x78(%rdi), %rcx
movq 0x68(%rdi,%rcx,8), %rsi
leaq 0x64(%rdi), %rdx
movl 0x80(%rdi), %ecx
movl %ebp, (%rsp)
movq %rbx, %rdi
movq %r15, %r8
movq %r14, %r9
callq *0x8(%rax)
movq 0x8(%rsp), %rcx
movl 0x64(%rcx), %eax
cmpl 0x80(%rcx), %eax
jb 0x738d7
cmpl $0x1, 0x84(%rcx)
jne 0x738a7
movq 0x228(%rbx), %rax
movq %rax, 0x20(%rsp)
movl 0x1a0(%rbx), %eax
movq 0x130(%rbx), %r9
movl 0x38(%rbx), %ecx
leal 0x1(%rax), %r8d
movq %rax, 0x18(%rsp)
leal 0x2(%rax), %r14d
xorl %r11d, %r11d
testl %ecx, %ecx
cmovlel %r11d, %ecx
movq %rcx, 0x10(%rsp)
cmpq 0x10(%rsp), %r11
je 0x738b8
movl 0x24(%r9), %eax
imull 0xc(%r9), %eax
cltd
idivl 0x18(%rsp)
movq 0x20(%rsp), %rcx
movq 0x68(%rcx), %rdx
movq 0x70(%rcx), %rsi
movq (%rdx,%r11,8), %rdx
movq (%rsi,%r11,8), %rbx
movl %eax, %esi
movl %r8d, %edi
imull %r8d, %esi
movslq %eax, %r8
movq %r14, %r10
imull %r14d, %eax
movslq %eax, %r15
testl %r8d, %r8d
movl $0x0, %eax
cmovgl %r8d, %eax
movslq %esi, %r12
leaq (%rbx,%r15,8), %r14
leaq (%rdx,%r15,8), %r15
shlq $0x3, %r8
movq %rbx, %r13
subq %r8, %r13
movq %rdx, %rbp
subq %r8, %rbp
leaq (%rbx,%r12,8), %rsi
leaq (%rdx,%r12,8), %r12
shlq $0x3, %rax
xorl %r8d, %r8d
cmpq %r8, %rax
je 0x73895
movq (%r12,%r8), %rcx
movq %rcx, (%rbp,%r8)
movq (%rsi,%r8), %rcx
movq %rcx, (%r13,%r8)
movq (%rdx,%r8), %rcx
movq %rcx, (%r15,%r8)
movq (%rbx,%r8), %rcx
movq %rcx, (%r14,%r8)
addq $0x8, %r8
jmp 0x73868
incq %r11
addq $0x60, %r9
movq %r10, %r14
movl %edi, %r8d
jmp 0x737ee
movl 0x1a0(%rbx), %r14d
leal 0x1(%r14), %r8d
addl $0x2, %r14d
jmp 0x738bd
movq 0x8(%rsp), %rcx
xorb $0x1, 0x78(%rcx)
andl $0x0, 0x60(%rcx)
movl %r8d, 0x64(%rcx)
movl %r14d, 0x80(%rcx)
movl $0x2, 0x7c(%rcx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq