// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/jpeg/jdphuff.c
// Function: decode_mcu_AC_first
METHODDEF(jboolean)
decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{   
  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
  int Se = cinfo->Se;
  int Al = cinfo->Al;
  register int s, k, r;
  unsigned int EOBRUN;
  JBLOCKROW block;
  BITREAD_STATE_VARS;
  d_derived_tbl * tbl;

  /* Process restart marker if needed; may have to suspend */
  if (cinfo->restart_interval) {
    if (entropy->restarts_to_go == 0)
      if (! process_restart(cinfo))
	return FALSE;
  }

  /* If we've run out of data, just leave the MCU set to zeroes.
   * This way, we return uniform gray for the remainder of the segment.
   */
  if (! entropy->pub.insufficient_data) {

    /* Load up working state.
     * We can avoid loading/saving bitread state if in an EOB run.
     */
    EOBRUN = entropy->saved.EOBRUN;	/* only part of saved state we need */

    /* There is always only one block per MCU */

    if (EOBRUN > 0)		/* if it's a band of zeroes... */
      EOBRUN--;			/* ...process it now (we do nothing) */
    else {
      BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
      block = MCU_data[0];
      tbl = entropy->ac_derived_tbl;

      for (k = cinfo->Ss; k <= Se; k++) {
	HUFF_DECODE(s, br_state, tbl, return FALSE, label2);
	r = s >> 4;
	s &= 15;
	if (s) {
	  k += r;
	  CHECK_BIT_BUFFER(br_state, s, return FALSE);
	  r = GET_BITS(s);
	  s = HUFF_EXTEND(r, s);
	  /* Scale and output coefficient in natural (dezigzagged) order */
	  (*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al);
	} else {
	  if (r == 15) {	/* ZRL */
	    k += 15;		/* skip 15 zeroes in band */
	  } else {		/* EOBr, run length is 2^r + appended bits */
	    EOBRUN = 1 << r;
	    if (r) {		/* EOBr, r > 0 */
	      CHECK_BIT_BUFFER(br_state, r, return FALSE);
	      r = GET_BITS(r);
	      EOBRUN += r;
	    }
	    EOBRUN--;		/* this band is processed at this moment */
	    break;		/* force end-of-band */
	  }
	}
      }

      BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
    }

    /* Completed MCU, so update state */
    entropy->saved.EOBRUN = EOBRUN;	/* only part of saved state we need */
  }

  /* Account for restart interval (no-op if not using restarts) */
  entropy->restarts_to_go--;

  return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x250(%rdi), %r15
movl 0x210(%rdi), %ebp
movl 0x218(%rdi), %eax
movl %eax, 0x4(%rsp)
cmpl $0x0, 0x170(%rdi)
je 0x7ed7d
cmpl $0x0, 0x3c(%r15)
jne 0x7ed7d
movq %rbx, %rdi
callq 0x7f502
testl %eax, %eax
je 0x7ef86
cmpl $0x0, 0x10(%r15)
jne 0x7ef1b
movl 0x28(%r15), %r13d
testl %r13d, %r13d
je 0x7ed99
decl %r13d
jmp 0x7ef17
movq %rbx, 0x28(%rsp)
movq 0x28(%rbx), %rax
movq (%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x18(%r15), %rsi
movl 0x20(%r15), %edx
movl %ebp, %eax
movl 0x20c(%rbx), %ebp
movl %eax, (%rsp)
cmpl %eax, %ebp
jg 0x7eef7
movq (%r14), %rax
movq %rax, 0x30(%rsp)
movq 0x60(%r15), %r14
cmpl $0x7, %edx
jg 0x7ee0a
xorl %r12d, %r12d
leaq 0x8(%rsp), %rdi
xorl %ecx, %ecx
callq 0x7df73
testl %eax, %eax
je 0x7ef25
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
movl $0x1, %r8d
cmpl $0x8, %edx
jl 0x7ee37
leal -0x8(%rdx), %ecx
movq %rsi, %rax
sarq %cl, %rax
movzbl %al, %eax
movl %eax, %ecx
movl 0x120(%r14,%rcx,4), %ecx
testl %ecx, %ecx
je 0x7ee31
subl %ecx, %edx
movzbl 0x520(%r14,%rax), %eax
jmp 0x7ee55
movl $0x9, %r8d
leaq 0x8(%rsp), %rdi
movq %r14, %rcx
callq 0x7e0c0
testl %eax, %eax
js 0x7ef86
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
movl %eax, %r12d
shrl $0x4, %r12d
movl %eax, %r13d
andl $0xf, %r13d
je 0x7eedc
cmpl %r13d, %edx
jge 0x7ee88
leaq 0x8(%rsp), %rdi
movl %r13d, %ecx
callq 0x7df73
testl %eax, %eax
je 0x7ef86
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
subl %r13d, %edx
movq %rsi, %rdi
movl %edx, %ecx
sarq %cl, %rdi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %r13d, %ecx
shll %cl, %eax
notl %eax
andl %edi, %eax
movl %r13d, %ecx
leaq 0x2bb25(%rip), %rdi     # 0xaa9d0
cmpl (%rdi,%rcx,4), %eax
jge 0x7eeba
leaq 0x2bb59(%rip), %rdi     # 0xaaa10
addl (%rdi,%rcx,4), %eax
movl 0x4(%rsp), %ecx
shll %cl, %eax
addl %ebp, %r12d
movslq %r12d, %rcx
leaq 0x2bdf3(%rip), %rdi     # 0xaacc0
movslq (%rdi,%rcx,4), %rcx
movq 0x30(%rsp), %rdi
movw %ax, (%rdi,%rcx,2)
jmp 0x7eee8
cmpl $0xf, %r12d
jne 0x7ef37
addl $0xf, %ebp
movl %ebp, %r12d
leal 0x1(%r12), %ebp
cmpl (%rsp), %r12d
jl 0x7edda
xorl %r13d, %r13d
movq 0x8(%rsp), %rax
movq 0x28(%rbx), %rcx
movq %rax, (%rcx)
movq 0x10(%rsp), %rax
movq %rax, 0x8(%rcx)
movq %rsi, 0x18(%r15)
movl %edx, 0x20(%r15)
movl %r13d, 0x28(%r15)
decl 0x3c(%r15)
movl $0x1, %r12d
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %r13d
movl %r12d, %ecx
shll %cl, %r13d
cmpl $0x10, %eax
jb 0x7ef7e
cmpl %r12d, %edx
jge 0x7ef67
leaq 0x8(%rsp), %rdi
movl %r12d, %ecx
callq 0x7df73
testl %eax, %eax
je 0x7ef86
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
subl %r12d, %edx
movq %rsi, %rax
movl %edx, %ecx
sarq %cl, %rax
leal -0x1(%r13), %ecx
andl %eax, %ecx
addl %r13d, %ecx
movl %ecx, %r13d
decl %r13d
jmp 0x7eefa
xorl %r12d, %r12d
jmp 0x7ef25