// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/jpeg/jcmarker.c
// Function: write_scan_header
METHODDEF(void)
write_scan_header (j_compress_ptr cinfo)
{
  my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
  int i;
  jpeg_component_info *compptr;

  if (cinfo->arith_code) {
    /* Emit arith conditioning info.  We may have some duplication
     * if the file has multiple scans, but it's so small it's hardly
     * worth worrying about.
     */
    emit_dac(cinfo);
  } else {
    /* Emit Huffman tables.
     * Note that emit_dht() suppresses any duplicate tables.
     */
    for (i = 0; i < cinfo->comps_in_scan; i++) {
      compptr = cinfo->cur_comp_info[i];
      if (cinfo->progressive_mode) {
	/* Progressive mode: only DC or only AC tables are used in one scan */
	if (cinfo->Ss == 0) {
	  if (cinfo->Ah == 0)	/* DC needs no table for refinement scan */
	    emit_dht(cinfo, compptr->dc_tbl_no, FALSE);
	} else {
	  emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
	}
      } else {
	/* Sequential mode: need both DC and AC tables */
	emit_dht(cinfo, compptr->dc_tbl_no, FALSE);
	emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
      }
    }
  }

  /* Emit DRI if required --- note that DRI value could change for each scan.
   * We avoid wasting space with unnecessary DRIs, however.
   */
  if (cinfo->restart_interval != marker->last_restart_interval) {
    emit_dri(cinfo);
    marker->last_restart_interval = cinfo->restart_interval;
  }

  emit_sos(cinfo);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0x1d0(%rdi), %r14
cmpl $0x0, 0x104(%rdi)
je 0x6a266
movl 0x118(%rbx), %eax
cmpl 0x38(%r14), %eax
je 0x6a193
movq %rbx, %rdi
movl $0xdd, %esi
callq 0x6a39e
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x6a3f3
movl 0x118(%rbx), %esi
movq %rbx, %rdi
callq 0x6a3f3
movl 0x118(%rbx), %eax
movl %eax, 0x38(%r14)
movq %rbx, %rdi
movl $0xda, %esi
callq 0x6a39e
movl 0x144(%rbx), %eax
leal 0x6(,%rax,2), %esi
movq %rbx, %rdi
callq 0x6a3f3
movl 0x144(%rbx), %esi
movq %rbx, %rdi
callq 0x6a3bf
xorl %r14d, %r14d
movslq 0x144(%rbx), %rax
cmpq %rax, %r14
jge 0x6a22b
movq 0x148(%rbx,%r14,8), %r15
movl (%r15), %esi
movq %rbx, %rdi
callq 0x6a3bf
movl 0x14(%r15), %ecx
movl 0x18(%r15), %eax
cmpl $0x0, 0x134(%rbx)
je 0x6a217
xorl %esi, %esi
cmpl $0x0, 0x19c(%rbx)
jne 0x6a219
xorl %eax, %eax
cmpl $0x0, 0x1a4(%rbx)
je 0x6a217
movl 0x104(%rbx), %edx
testl %edx, %edx
cmovel %edx, %ecx
movl %ecx, %esi
shll $0x4, %esi
addl %eax, %esi
movq %rbx, %rdi
callq 0x6a3bf
incq %r14
jmp 0x6a1c6
movl 0x19c(%rbx), %esi
movq %rbx, %rdi
callq 0x6a3bf
movl 0x1a0(%rbx), %esi
movq %rbx, %rdi
callq 0x6a3bf
movl 0x1a4(%rbx), %esi
shll $0x4, %esi
addl 0x1a8(%rbx), %esi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6a3bf
xorl %r15d, %r15d
pushq $0x1
popq %rbp
movslq 0x144(%rbx), %rax
cmpq %rax, %r15
jge 0x6a157
movq 0x148(%rbx,%r15,8), %r12
cmpl $0x0, 0x134(%rbx)
je 0x6a2ab
cmpl $0x0, 0x19c(%rbx)
jne 0x6a2ba
cmpl $0x0, 0x1a4(%rbx)
jne 0x6a2c9
movl 0x14(%r12), %esi
movq %rbx, %rdi
xorl %edx, %edx
jmp 0x6a2c4
movl 0x14(%r12), %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x6a5b3
movl 0x18(%r12), %esi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x6a5b3
incq %r15
jmp 0x6a26c