// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %r14
movl 0x24(%rdi), %eax
movl 0x4c(%rdi), %ebx
cmpl $0x64, %eax
je 0x68e1e
movq (%r14), %rcx
movl $0x14, 0x28(%rcx)
movl %eax, 0x2c(%rcx)
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
pushq $0xa
popq %rax
cmpl $0x3, %ebx
jne 0x68e31
cmpl $0x3, 0x50(%r14)
movl %eax, %ebp
jne 0x68e3b
jmp 0x68e42
cmpl $0x5, %ebx
jl 0x68e3b
imull $0x6, %ebx, %ebp
jmp 0x68e42
leal 0x2(,%rbx,4), %ebp
movq 0x1f8(%r14), %rdi
testq %rdi, %rdi
je 0x68e57
cmpl %ebp, 0x200(%r14)
jge 0x68e7d
cmpl $0xb, %ebp
cmovgel %ebp, %eax
movl %eax, 0x200(%r14)
movq 0x8(%r14), %rcx
imulq $0x24, %rax, %rdx
movq %r14, %rdi
xorl %esi, %esi
callq *(%rcx)
movq %rax, %rdi
movq %rax, 0x1f8(%r14)
movq %rdi, 0xf8(%r14)
movl %ebp, 0xf0(%r14)
cmpl $0x3, %ebx
jne 0x68f4d
cmpl $0x3, 0x50(%r14)
jne 0x68f4d
pushq $0x3
popq %rbx
pushq $0x1
popq %rbp
movl %ebx, %esi
xorl %edx, %edx
movl %ebp, %ecx
callq 0x68fcb
pushq $0x1
popq %r14
movq %r14, (%rax)
movaps 0x32522(%rip), %xmm0    # 0x9b3e0
movups %xmm0, 0x14(%rax)
movabsq $0x200000001, %r15      # imm = 0x200000001
movq %r15, 0x24(%rax)
movaps 0x32519(%rip), %xmm0    # 0x9b3f0
movups %xmm0, 0x38(%rax)
movabsq $0x100000001, %r12      # imm = 0x100000001
movq %r12, 0x48(%rax)
movups %xmm0, 0x5c(%rax)
movq %r14, 0x6c(%rax)
movaps 0x32508(%rip), %xmm0    # 0x9b400
movups %xmm0, 0x80(%rax)
movq %r14, 0x90(%rax)
movaps 0x32503(%rip), %xmm0    # 0x9b410
movups %xmm0, 0xa4(%rax)
leaq 0xb4(%rax), %rdi
movl %ebx, %esi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0x68fcb
movq %r15, (%rax)
movaps 0x324f0(%rip), %xmm0    # 0x9b420
movups %xmm0, 0x14(%rax)
movq %r12, 0x24(%rax)
movups %xmm0, 0x38(%rax)
movq %r14, 0x48(%rax)
movups %xmm0, 0x5c(%rax)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rbp
movl %ebx, %esi
xorl %edx, %edx
movl %ebp, %ecx
callq 0x68fcb
pushq $0x5
popq %rcx
pushq $0x2
popq %r15
movq %rax, %rdi
movl %ebx, %esi
movl %ebp, %edx
xorl %r8d, %r8d
movl %r15d, %r9d
callq 0x69008
pushq $0x6
popq %rdx
pushq $0x3f
popq %r14
movq %rax, %rdi
movl %ebx, %esi
movl %r14d, %ecx
xorl %r8d, %r8d
movl %r15d, %r9d
callq 0x69008
movq %rax, %rdi
movl %ebx, %esi
movl %ebp, %edx
movl %r14d, %ecx
movl %r15d, %r8d
movl %ebp, %r9d
callq 0x69008
movq %rax, %rdi
movl %ebx, %esi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0x68fcb
movq %rax, %rdi
movl %ebx, %esi
movl %ebp, %edx
movl %r14d, %ecx
movl %ebp, %r8d
xorl %r9d, %r9d
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x69008