// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/jpeg/jcparam.c
// Function: jpeg_simple_progression
GLOBAL(void)
jpeg_simple_progression (j_compress_ptr cinfo)
{
  int ncomps = cinfo->num_components;
  int nscans;
  jpeg_scan_info * scanptr;

  /* Safety check to ensure start_compress not called yet. */
  if (cinfo->global_state != CSTATE_START)
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);

  /* Figure space needed for script.  Calculation must match code below! */
  if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
    /* Custom script for YCbCr color images. */
    nscans = 10;
  } else {
    /* All-purpose script for other color spaces. */
    if (ncomps > MAX_COMPS_IN_SCAN)
      nscans = 6 * ncomps;	/* 2 DC + 4 AC scans per component */
    else
      nscans = 2 + 4 * ncomps;	/* 2 DC scans; 4 AC scans per component */
  }

  /* Allocate space for script.
   * We need to put it in the permanent pool in case the application performs
   * multiple compressions without changing the settings.  To avoid a memory
   * leak if jpeg_simple_progression is called repeatedly for the same JPEG
   * object, we try to re-use previously allocated space, and we allocate
   * enough space to handle YCbCr even if initially asked for grayscale.
   */
  if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) {
    cinfo->script_space_size = MAX(nscans, 10);
    cinfo->script_space = (jpeg_scan_info *)
      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
			cinfo->script_space_size * SIZEOF(jpeg_scan_info));
  }
  scanptr = cinfo->script_space;
  cinfo->scan_info = scanptr;
  cinfo->num_scans = nscans;

  if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
    /* Custom script for YCbCr color images. */
    /* Initial DC scan */
    scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
    /* Initial AC scan: get some luma data out in a hurry */
    scanptr = fill_a_scan(scanptr, 0, 1, 5, 0, 2);
    /* Chroma data is too small to be worth expending many scans on */
    scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1);
    scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1);
    /* Complete spectral selection for luma AC */
    scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2);
    /* Refine next bit of luma AC */
    scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1);
    /* Finish DC successive approximation */
    scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
    /* Finish AC successive approximation */
    scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0);
    scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0);
    /* Luma bottom bit comes last since it's usually largest scan */
    scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0);
  } else {
    /* All-purpose script for other color spaces. */
    /* Successive approximation first pass */
    scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
    scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2);
    scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2);
    /* Successive approximation second pass */
    scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1);
    /* Successive approximation final pass */
    scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
    scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %r14
movl 0x24(%rdi), %eax
movl 0x4c(%rdi), %ebx
cmpl $0x64, %eax
je 0x726f2
movq (%r14), %rcx
movl $0x14, 0x28(%rcx)
movl %eax, 0x2c(%rcx)
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
cmpl $0x3, %ebx
jne 0x72705
movl $0xa, %ebp
cmpl $0x3, 0x50(%r14)
jne 0x72712
jmp 0x72719
cmpl $0x5, %ebx
jl 0x72712
leal (%rbx,%rbx), %eax
leal (%rax,%rax,2), %ebp
jmp 0x72719
leal 0x2(,%rbx,4), %ebp
movq 0x1f8(%r14), %rax
testq %rax, %rax
je 0x7272e
cmpl %ebp, 0x200(%r14)
jge 0x7275a
cmpl $0xb, %ebp
movl $0xa, %eax
cmovgel %ebp, %eax
movl %eax, 0x200(%r14)
movq 0x8(%r14), %rcx
shlq $0x2, %rax
leaq (%rax,%rax,8), %rdx
movq %r14, %rdi
xorl %esi, %esi
callq *(%rcx)
movq %rax, 0x1f8(%r14)
movq %rax, 0xf8(%r14)
movl %ebp, 0xf0(%r14)
cmpl $0x3, %ebx
jne 0x72860
cmpl $0x3, 0x50(%r14)
movl $0x3, (%rax)
movabsq $0x100000000, %rcx      # imm = 0x100000000
jne 0x7290f
movq %rcx, 0x4(%rax)
movl $0x2, 0xc(%rax)
movaps 0x378f2(%rip), %xmm0    # 0xaa090
movups %xmm0, 0x14(%rax)
movl $0x1, %ecx
movq %rcx, 0x24(%rax)
movaps 0x3789e(%rip), %xmm0    # 0xaa050
movups %xmm0, 0x38(%rax)
movabsq $0x200000001, %rdx      # imm = 0x200000001
movq %rdx, 0x48(%rax)
movaps 0x378e5(%rip), %xmm0    # 0xaa0b0
movups %xmm0, 0x5c(%rax)
movabsq $0x100000001, %rsi      # imm = 0x100000001
movq %rsi, 0x6c(%rax)
movups %xmm0, 0x80(%rax)
movq %rcx, 0x90(%rax)
movaps 0x3786e(%rip), %xmm0    # 0xaa060
movups %xmm0, 0xa4(%rax)
movq %rcx, 0xb4(%rax)
movaps 0x37869(%rip), %xmm0    # 0xaa070
movups %xmm0, 0xc8(%rax)
movaps 0x3788b(%rip), %xmm0    # 0xaa0a0
movups %xmm0, 0xd8(%rax)
movaps 0x2fa5d(%rip), %xmm0    # 0xa2280
movups %xmm0, 0xec(%rax)
movq %rdx, 0xfc(%rax)
movaps 0x37848(%rip), %xmm0    # 0xaa080
movups %xmm0, 0x110(%rax)
movq %rsi, 0x120(%rax)
movups %xmm0, 0x134(%rax)
movq %rcx, 0x144(%rax)
movups %xmm0, 0x158(%rax)
jmp 0x729c6
xorl %ebp, %ebp
movq %rax, %rdi
movl %ebx, %esi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x729dd
testl %ebx, %ebx
jle 0x729cb
movaps 0x377ce(%rip), %xmm0    # 0xaa050
movl $0x1, (%rax)
movl %ebp, 0x4(%rax)
movups %xmm0, 0x14(%rax)
addq $0x24, %rax
incl %ebp
cmpl %ebp, %ebx
jne 0x72882
xorl %ecx, %ecx
movaps 0x377be(%rip), %xmm0    # 0xaa060
movl $0x1, (%rax)
movl %ecx, 0x4(%rax)
movups %xmm0, 0x14(%rax)
addq $0x24, %rax
incl %ecx
cmpl %ecx, %ebx
jne 0x728a2
xorl %ecx, %ecx
movaps 0x377ae(%rip), %xmm0    # 0xaa070
movl $0x1, (%rax)
movl %ecx, 0x4(%rax)
movups %xmm0, 0x14(%rax)
addq $0x24, %rax
incl %ecx
cmpl %ecx, %ebx
jne 0x728c2
xorl %ebp, %ebp
movq %rax, %rdi
movl %ebx, %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x729dd
movaps 0x3778d(%rip), %xmm0    # 0xaa080
movl $0x1, (%rax)
movl %ebp, 0x4(%rax)
movups %xmm0, 0x14(%rax)
addq $0x24, %rax
incl %ebp
cmpl %ebp, %ebx
jne 0x728f3
jmp 0x729c6
movq %rcx, 0x4(%rax)
movl $0x2, 0xc(%rax)
movaps 0x3776f(%rip), %xmm0    # 0xaa090
movups %xmm0, 0x14(%rax)
addq $0x48, %rax
xorl %ecx, %ecx
movaps 0x3771e(%rip), %xmm0    # 0xaa050
movl $0x1, -0x24(%rax)
movl %ecx, -0x20(%rax)
movups %xmm0, -0x10(%rax)
incl %ecx
addq $0x24, %rax
cmpl $0x3, %ecx
jne 0x72932
xorl %ecx, %ecx
movaps 0x3770c(%rip), %xmm0    # 0xaa060
movl $0x1, -0x24(%rax)
movl %ecx, -0x20(%rax)
movups %xmm0, -0x10(%rax)
incl %ecx
addq $0x24, %rax
cmpl $0x3, %ecx
jne 0x72954
xorl %ecx, %ecx
movaps 0x376fa(%rip), %xmm0    # 0xaa070
movl $0x1, -0x24(%rax)
movl %ecx, -0x20(%rax)
movups %xmm0, -0x10(%rax)
incl %ecx
addq $0x24, %rax
cmpl $0x3, %ecx
jne 0x72976
movaps 0x3770a(%rip), %xmm0    # 0xaa0a0
movups %xmm0, -0x24(%rax)
movaps 0x2f8df(%rip), %xmm0    # 0xa2280
movups %xmm0, -0x10(%rax)
xorl %ecx, %ecx
movaps 0x376d2(%rip), %xmm0    # 0xaa080
movl $0x1, (%rax)
movl %ecx, 0x4(%rax)
movups %xmm0, 0x14(%rax)
addq $0x24, %rax
incl %ecx
cmpl $0x3, %ecx
jne 0x729ae
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rdi
movl %ebx, %esi
movl $0x1, %edx
xorl %ecx, %ecx
popq %rbx
popq %r14
popq %rbp
jmp 0x729dd