// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/jpeg/jdhuff.c
// Function: decode_mcu
METHODDEF(jboolean)
decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
  int blkn;
  BITREAD_STATE_VARS;
  savable_state state;

  /* 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 */
    BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
    ASSIGN_STATE(state, entropy->saved);

    /* Outer loop handles each block in the MCU */

    for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
      JBLOCKROW block = MCU_data[blkn];
      d_derived_tbl * dctbl = entropy->dc_cur_tbls[blkn];
      d_derived_tbl * actbl = entropy->ac_cur_tbls[blkn];
      register int s, k, r;

      /* Decode a single block's worth of coefficients */

      /* Section F.2.2.1: decode the DC coefficient difference */
      HUFF_DECODE(s, br_state, dctbl, return FALSE, label1);
      if (s) {
	CHECK_BIT_BUFFER(br_state, s, return FALSE);
	r = GET_BITS(s);
	s = HUFF_EXTEND(r, s);
      }

      if (entropy->dc_needed[blkn]) {
	/* Convert DC difference to actual value, update last_dc_val */
	int ci = cinfo->MCU_membership[blkn];
	s += state.last_dc_val[ci];
	state.last_dc_val[ci] = s;
	/* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
	(*block)[0] = (JCOEF) s;
      }

      if (entropy->ac_needed[blkn]) {

	/* Section F.2.2.2: decode the AC coefficients */
	/* Since zeroes are skipped, output area must be cleared beforehand */
	for (k = 1; k < DCTSIZE2; k++) {
	  HUFF_DECODE(s, br_state, actbl, 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);
	    /* Output coefficient in natural (dezigzagged) order.
	     * Note: the extra entries in jpeg_natural_order[] will save us
	     * if k >= DCTSIZE2, which could happen if the data is corrupted.
	     */
	    (*block)[jpeg_natural_order[k]] = (JCOEF) s;
	  } else {
	    if (r != 15)
	      break;
	    k += 15;
	  }
	}

      } else {

	/* Section F.2.2.2: decode the AC coefficients */
	/* In this path we just discard the values */
	for (k = 1; k < DCTSIZE2; k++) {
	  HUFF_DECODE(s, br_state, actbl, return FALSE, label3);
      
	  r = s >> 4;
	  s &= 15;
      
	  if (s) {
	    k += r;
	    CHECK_BIT_BUFFER(br_state, s, return FALSE);
	    DROP_BITS(s);
	  } else {
	    if (r != 15)
	      break;
	    k += 15;
	  }
	}

      }
    }

    /* Completed MCU, so update state */
    BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
    ASSIGN_STATE(entropy->saved, state);
  }

  /* 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 $0x68, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq 0x250(%rdi), %r14
cmpl $0x0, 0x170(%rdi)
je 0x72201
cmpl $0x0, 0x38(%r14)
je 0x72574
cmpl $0x0, 0x10(%r14)
je 0x72214
pushq $0x1
popq %rbp
decl 0x38(%r14)
jmp 0x725b2
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
leaq 0x28(%r14), %rax
movq %rax, 0x58(%rsp)
movups 0x28(%r14), %xmm0
movaps %xmm0, 0x40(%rsp)
xorl %ecx, %ecx
movq %r15, 0x60(%rsp)
movslq 0x1e0(%rbx), %rax
cmpq %rax, %rcx
jge 0x725e4
movq (%r15,%rcx,8), %rax
movq %rax, 0x38(%rsp)
movq 0x80(%r14,%rcx,8), %r13
movq %rcx, 0x30(%rsp)
movq 0xd0(%r14,%rcx,8), %r12
cmpl $0x7, %edx
jg 0x722ac
xorl %ebp, %ebp
leaq 0x8(%rsp), %rdi
xorl %ecx, %ecx
callq 0x71e39
testl %eax, %eax
je 0x725b2
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
pushq $0x1
popq %r8
cmpl $0x8, %edx
jl 0x722d7
leal -0x8(%rdx), %ecx
movq %rsi, %rax
sarq %cl, %rax
movzbl %al, %eax
movl %eax, %ecx
movl 0x120(%r13,%rcx,4), %ecx
testl %ecx, %ecx
je 0x722d3
subl %ecx, %edx
movzbl 0x520(%r13,%rax), %ebp
jmp 0x722f7
pushq $0x9
popq %r8
leaq 0x8(%rsp), %rdi
movq %r13, %rcx
callq 0x71f5f
testl %eax, %eax
js 0x725b0
movl %eax, %ebp
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
testl %ebp, %ebp
movq 0x30(%rsp), %r15
je 0x72350
cmpl %ebp, %edx
jge 0x72321
leaq 0x8(%rsp), %rdi
movl %ebp, %ecx
callq 0x71e39
testl %eax, %eax
je 0x725b0
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
subl %ebp, %edx
movq %rsi, %rdi
movl %edx, %ecx
sarq %cl, %rdi
pushq $-0x1
popq %rax
movl %ebp, %ecx
shll %cl, %eax
notl %eax
andl %edi, %eax
movl %ebp, %ecx
leaq 0x29361(%rip), %rdi     # 0x9b6a0
cmpl (%rdi,%rcx,4), %eax
jge 0x72352
leaq 0x29395(%rip), %rdi     # 0x9b6e0
addl (%rdi,%rcx,4), %eax
jmp 0x72352
xorl %eax, %eax
cmpl $0x0, 0x120(%r14,%r15,4)
je 0x72375
movslq 0x1e4(%rbx,%r15,4), %rcx
addl 0x40(%rsp,%rcx,4), %eax
movl %eax, 0x40(%rsp,%rcx,4)
movq 0x38(%rsp), %rcx
movw %ax, (%rcx)
cmpl $0x0, 0x148(%r14,%r15,4)
je 0x7249c
pushq $0x1
popq %r15
cmpl $0x3f, %r15d
jg 0x72562
cmpl $0x7, %edx
jg 0x723bf
xorl %ebp, %ebp
leaq 0x8(%rsp), %rdi
xorl %ecx, %ecx
callq 0x71e39
testl %eax, %eax
je 0x725b2
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
pushq $0x1
popq %r8
cmpl $0x8, %edx
jl 0x723ea
leal -0x8(%rdx), %ecx
movq %rsi, %rax
sarq %cl, %rax
movzbl %al, %eax
movl %eax, %ecx
movl 0x120(%r12,%rcx,4), %ecx
testl %ecx, %ecx
je 0x723e6
subl %ecx, %edx
movzbl 0x520(%r12,%rax), %ebp
jmp 0x7240a
pushq $0x9
popq %r8
leaq 0x8(%rsp), %rdi
movq %r12, %rcx
callq 0x71f5f
testl %eax, %eax
js 0x725b0
movl %eax, %ebp
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
movl %ebp, %r13d
shrl $0x4, %r13d
andl $0xf, %ebp
je 0x72480
cmpl %ebp, %edx
jge 0x72437
leaq 0x8(%rsp), %rdi
movl %ebp, %ecx
callq 0x71e39
testl %eax, %eax
je 0x725b0
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
subl %ebp, %edx
movq %rsi, %rdi
movl %edx, %ecx
sarq %cl, %rdi
pushq $-0x1
popq %rax
movl %ebp, %ecx
shll %cl, %eax
notl %eax
andl %edi, %eax
movl %ebp, %ecx
leaq 0x2924b(%rip), %rdi     # 0x9b6a0
cmpl (%rdi,%rcx,4), %eax
jge 0x72464
leaq 0x2927f(%rip), %rdi     # 0x9b6e0
addl (%rdi,%rcx,4), %eax
addl %r15d, %r13d
movslq %r13d, %rcx
leaq 0x2956f(%rip), %rdi     # 0x9b9e0
movslq (%rdi,%rcx,4), %rcx
movq 0x38(%rsp), %rdi
movw %ax, (%rdi,%rcx,2)
jmp 0x72491
cmpl $0xf, %r13d
jne 0x72562
addl $0xf, %r15d
movl %r15d, %r13d
incl %r13d
movl %r13d, %r15d
jmp 0x72388
pushq $0x1
popq %rax
movl %eax, %r13d
cmpl $0x3f, %r13d
jg 0x72562
cmpl $0x7, %edx
jg 0x724d9
xorl %ebp, %ebp
leaq 0x8(%rsp), %rdi
xorl %ecx, %ecx
callq 0x71e39
testl %eax, %eax
je 0x725b2
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
pushq $0x1
popq %r8
cmpl $0x8, %edx
jl 0x72504
leal -0x8(%rdx), %ecx
movq %rsi, %rax
sarq %cl, %rax
movzbl %al, %eax
movl %eax, %ecx
movl 0x120(%r12,%rcx,4), %ecx
testl %ecx, %ecx
je 0x72500
subl %ecx, %edx
movzbl 0x520(%r12,%rax), %ebp
jmp 0x72524
pushq $0x9
popq %r8
leaq 0x8(%rsp), %rdi
movq %r12, %rcx
callq 0x71f5f
testl %eax, %eax
js 0x725b0
movl %eax, %ebp
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
movl %ebp, %r15d
shrl $0x4, %r15d
andl $0xf, %ebp
je 0x72551
cmpl %ebp, %edx
jge 0x7254d
leaq 0x8(%rsp), %rdi
movl %ebp, %ecx
callq 0x71e39
testl %eax, %eax
je 0x725b0
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
subl %ebp, %edx
jmp 0x72557
cmpl $0xf, %r15d
jne 0x72562
addl %r15d, %r13d
incl %r13d
jmp 0x724a2
movq 0x30(%rsp), %rcx
incq %rcx
movq 0x60(%rsp), %r15
jmp 0x72251
movl 0x20(%r14), %eax
pushq $0x8
popq %rcx
cltd
idivl %ecx
movq 0x248(%rbx), %rcx
addl %eax, 0x24(%rcx)
andl $0x0, 0x20(%r14)
movq %rbx, %rdi
callq *0x10(%rcx)
testl %eax, %eax
je 0x725b0
xorl %eax, %eax
movslq 0x1b0(%rbx), %rcx
cmpq %rcx, %rax
jge 0x725c3
andl $0x0, 0x28(%r14,%rax,4)
incq %rax
jmp 0x72599
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x170(%rbx), %eax
movl %eax, 0x38(%r14)
cmpl $0x0, 0x21c(%rbx)
jne 0x72201
andl $0x0, 0x10(%r14)
jmp 0x72201
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)
movaps 0x40(%rsp), %xmm0
movq 0x58(%rsp), %rax
movups %xmm0, (%rax)
jmp 0x72208
nop