// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x250(%rdi), %r15
movl 0x210(%rdi), %ebp
movl 0x218(%rdi), %eax
movl %eax, 0x14(%rsp)
cmpl $0x0, 0x170(%rdi)
je 0x7fabc
cmpl $0x0, 0x3c(%r15)
jne 0x7fabc
movq %rbx, %rdi
callq 0x802e6
testl %eax, %eax
je 0x7fce8
cmpl $0x0, 0x10(%r15)
jne 0x7fcce
movl 0x28(%r15), %r13d
testl %r13d, %r13d
je 0x7fad8
decl %r13d
jmp 0x7fcca
movq %rbx, 0x38(%rsp)
movq 0x28(%rbx), %rax
movq (%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x18(%r15), %rsi
movq %r15, %rax
movl 0x20(%r15), %r15d
movl 0x20c(%rbx), %ecx
cmpl %ebp, %ecx
movq %rax, 0x48(%rsp)
jg 0x7fca2
movl %ecx, 0xc(%rsp)
movq (%r14), %rcx
movq %rcx, 0x50(%rsp)
movq 0x60(%rax), %rax
movq %rax, 0x40(%rsp)
movl %ebp, 0x10(%rsp)
xorl %ebp, %ebp
cmpl $0x7, %r15d
jg 0x7fb6b
xorl %r12d, %r12d
leaq 0x18(%rsp), %rdi
movq %rsi, %r13
movl %r15d, %edx
xorl %ecx, %ecx
callq 0x7ebdf
testl %eax, %eax
je 0x7fbce
movq 0x28(%rsp), %rsi
movl 0x30(%rsp), %r15d
movl $0x1, %r8d
cmpl $0x8, %r15d
movq 0x40(%rsp), %r9
jge 0x7fb70
jmp 0x7fba2
movq 0x40(%rsp), %r9
leal -0x8(%r15), %ecx
movq %rsi, %rax
sarq %cl, %rax
movzbl %al, %eax
movl %eax, %ecx
movl 0x120(%r9,%rcx,4), %ecx
testl %ecx, %ecx
je 0x7fb9c
subl %ecx, %r15d
movzbl 0x520(%r9,%rax), %r14d
movb $0x1, %r12b
jmp 0x7fbd1
movl $0x9, %r8d
leaq 0x18(%rsp), %rdi
movq %rsi, %r13
movl %r15d, %edx
movq %r9, %rcx
callq 0x7ed1e
movl %eax, %r14d
testl %eax, %eax
js 0x7fbcb
movq 0x28(%rsp), %rsi
movb $0x1, %r12b
movl 0x30(%rsp), %r15d
jmp 0x7fbd1
xorl %r12d, %r12d
movq %r13, %rsi
testb %r12b, %r12b
je 0x7fcd7
movl %r14d, %r12d
sarl $0x4, %r12d
movl %r14d, %r13d
andl $0xf, %r13d
je 0x7fc79
cmpl %r13d, %r15d
jge 0x7fc15
leaq 0x18(%rsp), %rdi
movl %r15d, %edx
movl %r13d, %ecx
callq 0x7ebdf
testl %eax, %eax
je 0x7fcd7
movq 0x28(%rsp), %rsi
movl 0x30(%rsp), %r15d
subl %r13d, %r15d
movq %rsi, %rax
movl %r15d, %ecx
sarq %cl, %rax
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl %r13d, %ecx
shll %cl, %r14d
notl %r14d
andl %eax, %r14d
movl %r13d, %eax
leaq 0x2ad83(%rip), %rcx     # 0xaa9c0
cmpl (%rcx,%rax,4), %r14d
movl 0x10(%rsp), %edx
jge 0x7fc52
leaq 0x2adb2(%rip), %rcx     # 0xaaa00
addl (%rcx,%rax,4), %r14d
movl %r14d, %eax
movl 0x14(%rsp), %ecx
shll %cl, %eax
addl 0xc(%rsp), %r12d
movslq %r12d, %rcx
leaq 0x2b016(%rip), %rdi     # 0xaac80
movslq (%rdi,%rcx,4), %rcx
movq 0x50(%rsp), %rdi
movw %ax, (%rdi,%rcx,2)
jmp 0x7fc90
cmpl $0xf, %r12d
jne 0x7fcec
movl 0xc(%rsp), %eax
addl $0xf, %eax
xorl %r14d, %r14d
movl %eax, %r12d
movl 0x10(%rsp), %edx
leal 0x1(%r12), %eax
movl %eax, 0xc(%rsp)
cmpl %edx, %r12d
jl 0x7fb2b
xorl %r13d, %r13d
movq 0x18(%rsp), %rax
movq 0x28(%rbx), %rcx
movq %rax, (%rcx)
movq 0x20(%rsp), %rax
movq %rax, 0x8(%rcx)
movq 0x48(%rsp), %rax
movq %rsi, 0x18(%rax)
movl %r15d, 0x20(%rax)
movq %rax, %r15
movl %r13d, 0x28(%r15)
decl 0x3c(%r15)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
jmp 0x7fcd7
movl $0x1, %r13d
movl %r12d, %ecx
shll %cl, %r13d
cmpl $0x10, %r14d
jb 0x7fd39
cmpl %r12d, %r15d
jge 0x7fd21
leaq 0x18(%rsp), %rdi
movl %r15d, %edx
movl %r12d, %ecx
callq 0x7ebdf
testl %eax, %eax
je 0x7fcd7
movq 0x28(%rsp), %rsi
movl 0x30(%rsp), %r15d
subl %r12d, %r15d
movq %rsi, %rax
movl %r15d, %ecx
sarq %cl, %rax
leal -0x1(%r13), %ecx
andl %eax, %ecx
addl %r13d, %ecx
movl %ecx, %r13d
decl %r13d
jmp 0x7fca5