// File: tomfunkhouser[P]gaps/pkgs/jpeg/jcmaster.c
// Function: select_scan_parameters
LOCAL(void)
select_scan_parameters (j_compress_ptr cinfo)
/* Set up the scan parameters for the current scan */
{
  int ci;

#ifdef C_MULTISCAN_FILES_SUPPORTED
  if (cinfo->scan_info != NULL) {
    /* Prepare for current scan --- the script is already validated */
    my_master_ptr master = (my_master_ptr) cinfo->master;
    const jpeg_scan_info * scanptr = cinfo->scan_info + master->scan_number;

    cinfo->comps_in_scan = scanptr->comps_in_scan;
    for (ci = 0; ci < scanptr->comps_in_scan; ci++) {
      cinfo->cur_comp_info[ci] =
	&cinfo->comp_info[scanptr->component_index[ci]];
    }
    cinfo->Ss = scanptr->Ss;
    cinfo->Se = scanptr->Se;
    cinfo->Ah = scanptr->Ah;
    cinfo->Al = scanptr->Al;
  }
  else
#endif
  {
    /* Prepare for single sequential-JPEG scan containing all components */
    if (cinfo->num_components > MAX_COMPS_IN_SCAN)
      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
	       MAX_COMPS_IN_SCAN);
    cinfo->comps_in_scan = cinfo->num_components;
    for (ci = 0; ci < cinfo->num_components; ci++) {
      cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
    }
    cinfo->Ss = 0;
    cinfo->Se = DCTSIZE2-1;
    cinfo->Ah = 0;
    cinfo->Al = 0;
  }
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq 0x20(%rsp), %rax
cmpq $0x0, 0xf8(%rax)
je 0xd8764
movq 0x20(%rsp), %rax
movq 0x1b0(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x20(%rsp), %rax
movq 0xf8(%rax), %rax
movq 0x10(%rsp), %rcx
movslq 0x2c(%rcx), %rcx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movl (%rax), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x144(%rax)
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movq 0x8(%rsp), %rcx
cmpl (%rcx), %eax
jge 0xd8713
movq 0x20(%rsp), %rax
movq 0x58(%rax), %rdx
movq 0x8(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movslq 0x4(%rax,%rcx,4), %rax
imulq $0x60, %rax, %rax
addq %rax, %rdx
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq %rdx, 0x148(%rax,%rcx,8)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0xd86c8
movq 0x8(%rsp), %rax
movl 0x14(%rax), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x19c(%rax)
movq 0x8(%rsp), %rax
movl 0x18(%rax), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x1a0(%rax)
movq 0x8(%rsp), %rax
movl 0x1c(%rax), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x1a4(%rax)
movq 0x8(%rsp), %rax
movl 0x20(%rax), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x1a8(%rax)
jmp 0xd884b
movq 0x20(%rsp), %rax
cmpl $0x4, 0x4c(%rax)
jle 0xd87b2
movq 0x20(%rsp), %rax
movq (%rax), %rax
movl $0x1a, 0x28(%rax)
movq 0x20(%rsp), %rax
movl 0x4c(%rax), %ecx
movq 0x20(%rsp), %rax
movq (%rax), %rax
movl %ecx, 0x2c(%rax)
movq 0x20(%rsp), %rax
movq (%rax), %rax
movl $0x4, 0x30(%rax)
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rdi
callq *%rax
movq 0x20(%rsp), %rax
movl 0x4c(%rax), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x144(%rax)
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movq 0x20(%rsp), %rcx
cmpl 0x4c(%rcx), %eax
jge 0xd880f
movq 0x20(%rsp), %rax
movq 0x58(%rax), %rdx
movslq 0x1c(%rsp), %rax
imulq $0x60, %rax, %rax
addq %rax, %rdx
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq %rdx, 0x148(%rax,%rcx,8)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0xd87cd
movq 0x20(%rsp), %rax
movl $0x0, 0x19c(%rax)
movq 0x20(%rsp), %rax
movl $0x3f, 0x1a0(%rax)
movq 0x20(%rsp), %rax
movl $0x0, 0x1a4(%rax)
movq 0x20(%rsp), %rax
movl $0x0, 0x1a8(%rax)
addq $0x28, %rsp
retq