// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/jpeg/jdphuff.c
// Function: decode_mcu_DC_first
METHODDEF(jboolean)
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{   
  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
  int Al = cinfo->Al;
  register int s, r;
  int blkn, ci;
  JBLOCKROW block;
  BITREAD_STATE_VARS;
  savable_state state;
  d_derived_tbl * tbl;
  jpeg_component_info * compptr;

  /* 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++) {
      block = MCU_data[blkn];
      ci = cinfo->MCU_membership[blkn];
      compptr = cinfo->cur_comp_info[ci];
      tbl = entropy->derived_tbls[compptr->dc_tbl_no];

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

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

      /* Convert DC difference to actual value, update last_dc_val */
      s += state.last_dc_val[ci];
      state.last_dc_val[ci] = s;
      /* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */
      (*block)[0] = (JCOEF) (s << Al);
    }

    /* 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, %r14
movq %rdi, %rbx
movq 0x250(%rdi), %r13
movl 0x218(%rdi), %r15d
cmpl $0x0, 0x170(%rdi)
je 0x7eb38
cmpl $0x0, 0x3c(%r13)
jne 0x7eb38
movq %rbx, %rdi
callq 0x7f502
testl %eax, %eax
je 0x7ed2d
cmpl $0x0, 0x10(%r13)
jne 0x7ed11
movq %rbx, 0x28(%rsp)
movq 0x28(%rbx), %rax
movq (%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x8(%rax), %rdi
movq %rdi, 0x10(%rsp)
movq 0x18(%r13), %rsi
movl 0x20(%r13), %edx
movl 0x38(%r13), %r8d
movl %r8d, 0x40(%rsp)
movups 0x28(%r13), %xmm0
movaps %xmm0, 0x30(%rsp)
cmpl $0x0, 0x1e0(%rbx)
jle 0x7eced
xorl %ebp, %ebp
movq (%r14,%rbp,8), %rax
movq %rax, 0x60(%rsp)
movslq 0x1e4(%rbx,%rbp,4), %rax
movq %rax, 0x58(%rsp)
movq 0x1b8(%rbx,%rax,8), %rax
movslq 0x14(%rax), %rax
movq 0x40(%r13,%rax,8), %r9
cmpl $0x7, %edx
jg 0x7ec06
movq %rbp, 0x50(%rsp)
movq %r9, %rbp
movl %r15d, %r12d
movq %rbx, %r15
movq %r14, %rbx
movq %r13, %r14
xorl %r13d, %r13d
leaq 0x8(%rsp), %rdi
xorl %ecx, %ecx
callq 0x7df73
testl %eax, %eax
je 0x7ed1b
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
movl $0x1, %r8d
cmpl $0x8, %edx
movq %r14, %r13
movq %rbx, %r14
movq %r15, %rbx
movl %r12d, %r15d
movq %rbp, %r9
movq 0x50(%rsp), %rbp
jl 0x7ec33
leal -0x8(%rdx), %ecx
movq %rsi, %rax
sarq %cl, %rax
movzbl %al, %eax
movl %eax, %ecx
movl 0x120(%r9,%rcx,4), %ecx
testl %ecx, %ecx
je 0x7ec2d
subl %ecx, %edx
movzbl 0x520(%r9,%rax), %r12d
jmp 0x7ec54
movl $0x9, %r8d
leaq 0x8(%rsp), %rdi
movq %r9, %rcx
callq 0x7e0c0
testl %eax, %eax
js 0x7ed2d
movl %eax, %r12d
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
testl %r12d, %r12d
je 0x7ecb0
cmpl %r12d, %edx
jge 0x7ec7c
leaq 0x8(%rsp), %rdi
movl %r12d, %ecx
callq 0x7df73
testl %eax, %eax
je 0x7ed2d
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
subl %r12d, %edx
movq %rsi, %rdi
movl %edx, %ecx
sarq %cl, %rdi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %r12d, %ecx
shll %cl, %eax
notl %eax
andl %edi, %eax
movl %r12d, %ecx
leaq 0x2bd31(%rip), %rdi     # 0xaa9d0
cmpl (%rdi,%rcx,4), %eax
jge 0x7ecb2
leaq 0x2bd65(%rip), %rdi     # 0xaaa10
addl (%rdi,%rcx,4), %eax
jmp 0x7ecb2
xorl %eax, %eax
movq 0x58(%rsp), %rcx
addl 0x34(%rsp,%rcx,4), %eax
movl %eax, 0x34(%rsp,%rcx,4)
movl %r15d, %ecx
shll %cl, %eax
movq 0x60(%rsp), %rcx
movw %ax, (%rcx)
incq %rbp
movslq 0x1e0(%rbx), %rax
cmpq %rax, %rbp
jl 0x7eb87
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rdi
movq 0x28(%rbx), %rax
leaq 0x28(%r13), %r8
movq %rcx, (%rax)
movq %rdi, 0x8(%rax)
movq %rsi, 0x18(%r13)
movl %edx, 0x20(%r13)
movl 0x40(%rsp), %eax
movl %eax, 0x10(%r8)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%r8)
decl 0x3c(%r13)
movl $0x1, %r13d
movl %r13d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r13d, %r13d
jmp 0x7ed1b