// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/jpeg/jdhuff.c
// Function: start_pass_huff_decoder
METHODDEF(void)
start_pass_huff_decoder (j_decompress_ptr cinfo)
{
  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
  int ci, blkn, dctbl, actbl;
  jpeg_component_info * compptr;

  /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG.
   * This ought to be an error condition, but we make it a warning because
   * there are some baseline files out there with all zeroes in these bytes.
   */
  if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2-1 ||
      cinfo->Ah != 0 || cinfo->Al != 0)
    WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);

  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
    compptr = cinfo->cur_comp_info[ci];
    dctbl = compptr->dc_tbl_no;
    actbl = compptr->ac_tbl_no;
    /* Compute derived values for Huffman tables */
    /* We may do this more than once for a table, but it's not expensive */
    jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl,
			    & entropy->dc_derived_tbls[dctbl]);
    jpeg_make_d_derived_tbl(cinfo, FALSE, actbl,
			    & entropy->ac_derived_tbls[actbl]);
    /* Initialize DC predictions to 0 */
    entropy->saved.last_dc_val[ci] = 0;
  }

  /* Precalculate decoding info for each block in an MCU of this scan */
  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
    ci = cinfo->MCU_membership[blkn];
    compptr = cinfo->cur_comp_info[ci];
    /* Precalculate which table to use for each block */
    entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no];
    entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no];
    /* Decide whether we really care about the coefficient values */
    if (compptr->component_needed) {
      entropy->dc_needed[blkn] = TRUE;
      /* we don't need the ACs if producing a 1/8th-size image */
      entropy->ac_needed[blkn] = (compptr->DCT_scaled_size > 1);
    } else {
      entropy->dc_needed[blkn] = entropy->ac_needed[blkn] = FALSE;
    }
  }

  /* Initialize bitread state variables */
  entropy->bitstate.bits_left = 0;
  entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */
  entropy->pub.insufficient_data = FALSE;

  /* Initialize restart counter */
  entropy->restarts_to_go = cinfo->restart_interval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x250(%rdi), %r15
cmpl $0x0, 0x20c(%rdi)
jne 0x720c2
cmpl $0x3f, 0x210(%rbx)
jne 0x720c2
cmpl $0x0, 0x214(%rbx)
jne 0x720c2
cmpl $0x0, 0x218(%rbx)
je 0x720d5
movq (%rbx), %rax
movl $0x7a, 0x28(%rax)
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq *0x8(%rax)
leaq 0x40(%r15), %r12
leaq 0x60(%r15), %r13
xorl %ebp, %ebp
movslq 0x1b0(%rbx), %rax
cmpq %rax, %rbp
jge 0x7212d
movq 0x1b8(%rbx,%rbp,8), %rax
movslq 0x14(%rax), %rdx
movslq 0x18(%rax), %r14
leaq (%r12,%rdx,8), %rcx
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0x71b94
leaq (,%r14,8), %rcx
addq %r13, %rcx
movq %rbx, %rdi
xorl %esi, %esi
movl %r14d, %edx
callq 0x71b94
andl $0x0, 0x28(%r15,%rbp,4)
incq %rbp
jmp 0x720df
xorl %eax, %eax
movslq 0x1e0(%rbx), %rcx
cmpq %rcx, %rax
jge 0x721aa
movslq 0x1e4(%rbx,%rax,4), %rcx
movq 0x1b8(%rbx,%rcx,8), %rdx
movslq 0x14(%rdx), %rcx
movq 0x40(%r15,%rcx,8), %rcx
movq %rcx, 0x80(%r15,%rax,8)
movslq 0x18(%rdx), %rcx
movq 0x60(%r15,%rcx,8), %rcx
movq %rcx, 0xd0(%r15,%rax,8)
cmpl $0x0, 0x30(%rdx)
je 0x7218f
movl $0x1, 0x120(%r15,%rax,4)
xorl %ecx, %ecx
cmpl $0x2, 0x24(%rdx)
setge %cl
movl $0x148, %edx            # imm = 0x148
jmp 0x7219f
andl $0x0, 0x148(%r15,%rax,4)
xorl %ecx, %ecx
movl $0x120, %edx            # imm = 0x120
addq %r15, %rdx
movl %ecx, (%rdx,%rax,4)
incq %rax
jmp 0x7212f
andl $0x0, 0x20(%r15)
andq $0x0, 0x18(%r15)
andl $0x0, 0x10(%r15)
movl 0x170(%rbx), %eax
movl %eax, 0x38(%r15)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq