// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/jpeg/jquant2.c
// Function: finish_pass1
METHODDEF(void)
finish_pass1 (j_decompress_ptr cinfo)
{
  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;

  /* Select the representative colors and fill in cinfo->colormap */
  cinfo->colormap = cquantize->sv_colormap;
  select_colors(cinfo, cquantize->desired);
  /* Force next pass to zero the color index table */
  cquantize->needs_zeroed = TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movq 0x270(%rdi), %rcx
movq 0x20(%rcx), %rax
movq %rax, 0xa0(%rdi)
movq %rcx, 0x28(%rsp)
movslq 0x28(%rcx), %r13
movq 0x8(%rdi), %rax
leaq (,%r13,8), %rcx
leaq (%rcx,%rcx,4), %rdx
movl $0x1, %ebp
movl $0x1, %esi
callq *(%rax)
movq %rax, %r14
movaps 0x2667c(%rip), %xmm0    # 0xaaca0
movups %xmm0, (%rax)
movabsq $0x1f00000000, %rax     # imm = 0x1F00000000
movq %rax, 0x10(%r14)
movq %rbx, 0x8(%rsp)
movq 0x270(%rbx), %rax
movq 0x30(%rax), %rdi
movq %r14, %rsi
callq 0x84e0e
cmpq $0x2, %r13
movq %r14, 0x20(%rsp)
jl 0x847d5
movl $0x1, %ebp
movl $0x2, %r12d
leaq (,%rbp,2), %rax
cmpq %r13, %rax
jbe 0x84698
movq %rbp, %rax
xorl %esi, %esi
xorl %ecx, %ecx
movq %r14, %rdx
movq 0x18(%rdx), %rdi
cmpq %rcx, %rdi
cmovgq %rdi, %rcx
cmovgq %rdx, %rsi
addq $0x28, %rdx
decq %rax
jne 0x8467e
jmp 0x846c1
movq %rbp, %rax
xorl %esi, %esi
xorl %ecx, %ecx
movq %r14, %rdx
movq 0x20(%rdx), %rdi
cmpq %rcx, %rdi
jle 0x846b8
cmpq $0x0, 0x18(%rdx)
cmovgq %rdi, %rcx
cmovgq %rdx, %rsi
addq $0x28, %rdx
decq %rax
jne 0x846a2
testq %rsi, %rsi
je 0x847c6
leaq (,%rbp,4), %rcx
addq %rbp, %rcx
movl 0x4(%rsi), %edx
movl %edx, 0x4(%r14,%rcx,8)
movl 0xc(%rsi), %edi
movl %edi, 0xc(%r14,%rcx,8)
movl 0x14(%rsi), %r9d
movl %r9d, 0x14(%r14,%rcx,8)
movl (%rsi), %eax
movl %eax, (%r14,%rcx,8)
movl 0x8(%rsi), %r8d
movl %r8d, 0x8(%r14,%rcx,8)
movl 0x10(%rsi), %r10d
movl %edx, %ebx
subl %eax, %ebx
shll $0x4, %ebx
movl %edi, %r11d
subl %r8d, %r11d
shll $0x2, %r11d
leal (%r11,%r11,2), %r14d
movl %r9d, %r15d
subl %r10d, %r15d
shll $0x3, %r15d
xorl %r11d, %r11d
cmpl %r14d, %ebx
cmovlel %r14d, %ebx
movq 0x20(%rsp), %r14
setle %r11b
cmpl %ebx, %r15d
leaq (%r14,%rcx,8), %r15
movl %r10d, 0x10(%r14,%rcx,8)
cmovgl %r12d, %r11d
cmpl $0x2, %r11d
je 0x84763
cmpl $0x1, %r11d
jne 0x84777
leaq 0xc(%rsi), %r11
leaq (%r14,%rcx,8), %rcx
addq $0x8, %rcx
addl %edi, %r8d
movl %r8d, %eax
jmp 0x84780
leaq 0x14(%rsi), %r11
leaq (%r14,%rcx,8), %rcx
addq $0x10, %rcx
addl %r9d, %r10d
movl %r10d, %eax
jmp 0x84780
leaq 0x4(%rsi), %r11
addl %edx, %eax
movq %r15, %rcx
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
movl %edx, (%r11)
incl %edx
movl %edx, (%rcx)
movq 0x8(%rsp), %rbx
movq 0x270(%rbx), %rax
movq 0x30(%rax), %rdi
callq 0x84e0e
movq 0x270(%rbx), %rax
movq 0x30(%rax), %rdi
movq %r15, %rsi
callq 0x84e0e
incq %rbp
cmpq %r13, %rbp
jne 0x84667
jmp 0x847c9
movl %ebp, %r13d
movl %r13d, %ebp
testl %r13d, %r13d
jle 0x84981
movl %ebp, 0x10(%rsp)
movl %ebp, %eax
movq %rax, 0x30(%rsp)
xorl %r8d, %r8d
movq %r8, 0x38(%rsp)
leaq (%r8,%r8,4), %rax
movslq (%r14,%rax,8), %rsi
movl 0x4(%r14,%rax,8), %edx
cmpl %edx, %esi
jle 0x84808
xorl %r9d, %r9d
xorl %eax, %eax
xorl %ecx, %ecx
xorl %r10d, %r10d
jmp 0x84910
leaq (%r14,%rax,8), %rax
movq 0x8(%rsp), %rcx
movq 0x270(%rcx), %rcx
movq 0x30(%rcx), %rcx
movq %rcx, 0x48(%rsp)
movl 0xc(%rax), %ecx
movl 0x14(%rax), %r8d
movslq 0x10(%rax), %r9
movslq 0x8(%rax), %rbp
movq %rcx, 0x58(%rsp)
leal 0x1(%rcx), %eax
movl %eax, 0x1c(%rsp)
incl %edx
movl %r8d, %r13d
movl %r8d, %ebx
subl %r9d, %ebx
incl %ebx
leal 0x4(,%r9,8), %eax
movl %eax, 0x18(%rsp)
movq %rbp, %rax
shlq $0x6, %rax
movq %r9, %rdi
leaq (%rax,%r9,2), %rax
movq %rax, 0x40(%rsp)
xorl %r10d, %r10d
xorl %ecx, %ecx
xorl %eax, %eax
xorl %r9d, %r9d
movq %rbp, 0x50(%rsp)
movl %edx, 0x14(%rsp)
cmpl 0x58(%rsp), %ebp
movq %rsi, 0x60(%rsp)
jg 0x848f7
leal 0x4(,%rsi,8), %edx
movslq %edx, %r11
movq 0x48(%rsp), %rdx
movq (%rdx,%rsi,8), %r8
addq 0x40(%rsp), %r8
cmpl %r13d, %edi
jg 0x848ea
leal 0x2(,%rbp,4), %edx
movslq %edx, %rsi
movl 0x18(%rsp), %r14d
xorl %edx, %edx
movzwl (%r8,%rdx,2), %r12d
testq %r12, %r12
je 0x848df
addq %r12, %r9
movq %r12, %r15
imulq %r11, %r15
addq %r15, %rax
movq %r12, %r15
imulq %rsi, %r15
addq %r15, %rcx
movslq %r14d, %r15
imulq %r12, %r15
addq %r15, %r10
incq %rdx
addl $0x8, %r14d
cmpl %edx, %ebx
jne 0x848b4
incq %rbp
addq $0x40, %r8
cmpl %ebp, 0x1c(%rsp)
jne 0x8489e
movq 0x60(%rsp), %rsi
incq %rsi
movl 0x14(%rsp), %edx
cmpl %esi, %edx
movq 0x50(%rsp), %rbp
jne 0x8487b
movq %r9, %rsi
sarq %rsi
addq %rsi, %rax
cqto
idivq %r9
movq 0x8(%rsp), %rdi
movq 0xa0(%rdi), %rdx
movq (%rdx), %rdx
movq 0x38(%rsp), %r8
movb %al, (%rdx,%r8)
addq %rsi, %rcx
movq %rcx, %rax
cqto
idivq %r9
movq 0xa0(%rdi), %rcx
movq 0x8(%rcx), %rcx
movb %al, (%rcx,%r8)
addq %r10, %rsi
movq %rsi, %rax
cqto
idivq %r9
movq 0xa0(%rdi), %rcx
movq 0x10(%rcx), %rcx
movb %al, (%rcx,%r8)
incq %r8
cmpq 0x30(%rsp), %r8
movq 0x20(%rsp), %r14
jne 0x847e3
movl 0x10(%rsp), %ebp
movq 0x8(%rsp), %rdi
movl %ebp, 0x9c(%rdi)
movq (%rdi), %rax
movl $0x60, 0x28(%rax)
movl %ebp, 0x2c(%rax)
movq (%rdi), %rax
movl $0x1, %esi
callq *0x8(%rax)
movq 0x28(%rsp), %rax
movl $0x1, 0x38(%rax)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq