// File: /workspace/github_cpp_makefile_star2_O1/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 $0x78, %rsp
movq %rsi, 0x68(%rsp)
movq 0x250(%rdi), %rbp
movl 0x218(%rdi), %eax
movl %eax, 0x24(%rsp)
cmpl $0x0, 0x170(%rdi)
movq %rdi, 0x8(%rsp)
je 0x7f84c
cmpl $0x0, 0x3c(%rbp)
jne 0x7f84c
movq 0x8(%rsp), %rdi
callq 0x802e6
movq 0x8(%rsp), %rdi
testl %eax, %eax
je 0x7fa60
cmpl $0x0, 0x10(%rbp)
jne 0x7fa56
movq %rdi, 0x48(%rsp)
movq 0x28(%rdi), %rax
movq (%rax), %rcx
movq %rcx, 0x28(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x18(%rbp), %rsi
movl 0x20(%rbp), %r12d
movl 0x38(%rbp), %eax
movl %eax, 0x60(%rsp)
movups 0x28(%rbp), %xmm0
movaps %xmm0, 0x50(%rsp)
cmpl $0x0, 0x1e0(%rdi)
jle 0x7fa26
xorl %r14d, %r14d
movq %rbp, 0x10(%rsp)
movq 0x68(%rsp), %rax
movq (%rax,%r14,8), %r15
movslq 0x1e4(%rdi,%r14,4), %rax
movq %rax, 0x70(%rsp)
movq 0x1b8(%rdi,%rax,8), %rax
movslq 0x14(%rax), %rax
movq 0x40(%rbp,%rax,8), %rbp
cmpl $0x7, %r12d
movq %r15, 0x18(%rsp)
jg 0x7f90b
xorl %ebx, %ebx
leaq 0x28(%rsp), %rdi
movq %rsi, %r15
movl %r12d, %edx
xorl %ecx, %ecx
callq 0x7ebdf
testl %eax, %eax
je 0x7f975
movq 0x38(%rsp), %rsi
movl 0x40(%rsp), %r12d
movl $0x1, %r8d
cmpl $0x8, %r12d
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %r15
jl 0x7f941
leal -0x8(%r12), %ecx
movq %rsi, %rax
sarq %cl, %rax
movzbl %al, %eax
movl %eax, %ecx
movl 0x120(%rbp,%rcx,4), %ecx
testl %ecx, %ecx
je 0x7f93b
subl %ecx, %r12d
movzbl 0x520(%rbp,%rax), %r13d
movb $0x1, %bl
movq 0x10(%rsp), %rbp
jmp 0x7f987
movl $0x9, %r8d
leaq 0x28(%rsp), %rdi
movq %rsi, %r15
movl %r12d, %edx
movq %rbp, %rcx
callq 0x7ed1e
movl %eax, %r13d
testl %eax, %eax
js 0x7f973
movq 0x38(%rsp), %rsi
movb $0x1, %bl
movl 0x40(%rsp), %r12d
movq 0x10(%rsp), %rbp
movq 0x8(%rsp), %rdi
jmp 0x7f982
xorl %ebx, %ebx
movq 0x10(%rsp), %rbp
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq 0x18(%rsp), %r15
testb %bl, %bl
je 0x7fa60
testl %r13d, %r13d
je 0x7f9f5
cmpl %r13d, %r12d
jge 0x7f9c0
leaq 0x28(%rsp), %rdi
movl %r12d, %edx
movl %r13d, %ecx
callq 0x7ebdf
testl %eax, %eax
je 0x7fa60
movq 0x38(%rsp), %rsi
movl 0x40(%rsp), %r12d
movq 0x8(%rsp), %rdi
subl %r13d, %r12d
movq %rsi, %rdx
movl %r12d, %ecx
sarq %cl, %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %r13d, %ecx
shll %cl, %eax
notl %eax
andl %edx, %eax
movslq %r13d, %rcx
leaq 0x2afdc(%rip), %rdx     # 0xaa9c0
cmpl (%rdx,%rcx,4), %eax
jge 0x7f9f7
leaq 0x2b010(%rip), %rdx     # 0xaaa00
addl (%rdx,%rcx,4), %eax
jmp 0x7f9f7
xorl %eax, %eax
movq 0x70(%rsp), %rcx
addl 0x54(%rsp,%rcx,4), %eax
movl %eax, 0x54(%rsp,%rcx,4)
movl %eax, %edx
movl 0x24(%rsp), %ecx
shll %cl, %edx
movw %dx, (%r15)
incq %r14
movslq 0x1e0(%rdi), %rcx
movl %eax, %r13d
cmpq %rcx, %r14
jl 0x7f89d
leaq 0x28(%rbp), %rax
movq 0x28(%rsp), %rcx
movq 0x28(%rdi), %rdx
movq %rcx, (%rdx)
movq 0x30(%rsp), %rcx
movq %rcx, 0x8(%rdx)
movq %rsi, 0x18(%rbp)
movl %r12d, 0x20(%rbp)
movl 0x60(%rsp), %ecx
movl %ecx, 0x10(%rax)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rax)
decl 0x3c(%rbp)
movl $0x1, %eax
jmp 0x7fa62
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq