// File: /workspace/github_cpp_makefile_star2_O2/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, %r15
movq %rdi, %rbx
movq 0x250(%rdi), %r14
movl 0x210(%rdi), %eax
movl %eax, 0x4(%rsp)
movl 0x218(%rdi), %eax
movl %eax, (%rsp)
cmpl $0x0, 0x170(%rdi)
je 0x72b3e
cmpl $0x0, 0x3c(%r14)
jne 0x72b3e
movq %rbx, %rdi
callq 0x73255
testl %eax, %eax
je 0x72d33
cmpl $0x0, 0x10(%r14)
jne 0x72d19
movl 0x28(%r14), %r13d
testl %r13d, %r13d
je 0x72b5a
decl %r13d
jmp 0x72d15
leaq 0x8(%rsp), %rdx
movq %rbx, 0x20(%rdx)
movq 0x28(%rbx), %rax
movq (%rax), %rcx
movq %rcx, (%rdx)
movq 0x8(%rax), %rax
movq %rax, 0x8(%rdx)
movq 0x18(%r14), %rsi
movl 0x20(%r14), %edx
movq (%r15), %rax
movq %rax, 0x30(%rsp)
movq 0x60(%r14), %r15
movl 0x20c(%rbx), %ebp
cmpl 0x4(%rsp), %ebp
jg 0x72cab
cmpl $0x7, %edx
jg 0x72bc7
xorl %r12d, %r12d
leaq 0x8(%rsp), %rdi
xorl %ecx, %ecx
callq 0x71e39
testl %eax, %eax
je 0x72d21
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
pushq $0x1
popq %r8
cmpl $0x8, %edx
jl 0x72bf2
leal -0x8(%rdx), %ecx
movq %rsi, %rax
sarq %cl, %rax
movzbl %al, %eax
movl %eax, %ecx
movl 0x120(%r15,%rcx,4), %ecx
testl %ecx, %ecx
je 0x72bee
subl %ecx, %edx
movzbl 0x520(%r15,%rax), %eax
jmp 0x72c10
pushq $0x9
popq %r8
leaq 0x8(%rsp), %rdi
movq %r15, %rcx
callq 0x71f5f
testl %eax, %eax
js 0x72d33
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
movl %eax, %r12d
shrl $0x4, %r12d
movl %eax, %r13d
andl $0xf, %r13d
je 0x72c94
cmpl %r13d, %edx
jge 0x72c43
leaq 0x8(%rsp), %rdi
movl %r13d, %ecx
callq 0x71e39
testl %eax, %eax
je 0x72d33
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
subl %r13d, %edx
movq %rsi, %rdi
movl %edx, %ecx
sarq %cl, %rdi
pushq $-0x1
popq %rax
movl %r13d, %ecx
shll %cl, %eax
notl %eax
andl %edi, %eax
movl %r13d, %ecx
leaq 0x28abc(%rip), %rdi     # 0x9b720
cmpl (%rdi,%rcx,4), %eax
jge 0x72c73
leaq 0x28af0(%rip), %rdi     # 0x9b760
addl (%rdi,%rcx,4), %eax
movl (%rsp), %ecx
shll %cl, %eax
addl %ebp, %r12d
movslq %r12d, %rcx
leaq 0x28d5b(%rip), %rdi     # 0x9b9e0
movslq (%rdi,%rcx,4), %rcx
movq 0x30(%rsp), %rdi
movw %ax, (%rdi,%rcx,2)
jmp 0x72ca0
cmpl $0xf, %r12d
jne 0x72cb0
addl $0xf, %ebp
movl %ebp, %r12d
incl %r12d
movl %r12d, %ebp
jmp 0x72b8f
xorl %r13d, %r13d
jmp 0x72cf8
pushq $0x1
popq %r13
movl %r12d, %ecx
shll %cl, %r13d
cmpl $0x10, %eax
jb 0x72cf5
cmpl %r12d, %edx
jge 0x72cde
leaq 0x8(%rsp), %rdi
movl %r12d, %ecx
callq 0x71e39
testl %eax, %eax
je 0x72d33
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
movq 0x8(%rsp), %rax
movq 0x28(%rbx), %rcx
movq %rax, (%rcx)
movq 0x10(%rsp), %rax
movq %rax, 0x8(%rcx)
movq %rsi, 0x18(%r14)
movl %edx, 0x20(%r14)
movl %r13d, 0x28(%r14)
pushq $0x1
popq %r12
decl 0x3c(%r14)
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r12d, %r12d
jmp 0x72d21