// File: /workspace/github_cpp_makefile_star2_O1/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), %rbp
movq 0x8(%rdi), %rax
leaq (,%rbp,8), %rcx
leaq (%rcx,%rcx,4), %rdx
movl $0x1, %r13d
movl $0x1, %esi
callq *(%rax)
movq %rax, %r14
movaps 0x25841(%rip), %xmm0    # 0xaac60
movups %xmm0, (%rax)
movabsq $0x1f00000000, %rax     # imm = 0x1F00000000
movq %rax, 0x10(%r14)
movq %rbx, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x85c18
cmpq $0x2, %rbp
movq %r14, 0x20(%rsp)
jl 0x855a0
movl $0x1, %r13d
movl $0x2, %r12d
leaq (,%r13,2), %rax
cmpq %rbp, %rax
jbe 0x8548b
movq %r13, %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 0x85471
jmp 0x854b4
movq %r13, %rax
xorl %esi, %esi
xorl %ecx, %ecx
movq %r14, %rdx
movq 0x20(%rdx), %rdi
cmpq %rcx, %rdi
jle 0x854ab
cmpq $0x0, 0x18(%rdx)
cmovgq %rdi, %rcx
cmovgq %rdx, %rsi
addq $0x28, %rdx
decq %rax
jne 0x85495
testq %rsi, %rsi
je 0x855a0
leaq (,%r13,4), %rcx
addq %r13, %rcx
movl 0x14(%rsi), %eax
movl %eax, 0x14(%r14,%rcx,8)
movups (%rsi), %xmm0
movups %xmm0, (%r14,%rcx,8)
movl 0x10(%rsi), %eax
movl %eax, 0x10(%r14,%rcx,8)
movl (%rsi), %eax
movl 0x4(%rsi), %edx
movl %edx, %ebx
subl %eax, %ebx
shll $0x4, %ebx
movl 0xc(%rsi), %edi
movl 0x8(%rsi), %r8d
movl %edi, %r9d
subl %r8d, %r9d
shll $0x2, %r9d
leal (%r9,%r9,2), %r14d
movl 0x14(%rsi), %r10d
movl 0x10(%rsi), %r11d
movl %r10d, %r15d
subl %r11d, %r15d
shll $0x3, %r15d
xorl %r9d, %r9d
cmpl %r14d, %ebx
cmovlel %r14d, %ebx
movq 0x20(%rsp), %r14
setle %r9b
cmpl %ebx, %r15d
leaq (%r14,%rcx,8), %r15
cmovgl %r12d, %r9d
cmpl $0x2, %r9d
je 0x8554d
cmpl $0x1, %r9d
jne 0x85561
leaq 0xc(%rsi), %r9
leaq 0x8(%r15), %rcx
addl %edi, %r8d
movl %r8d, %eax
jmp 0x8556a
leaq 0x14(%rsi), %r9
leaq (%r14,%rcx,8), %rcx
addq $0x10, %rcx
addl %r10d, %r11d
movl %r11d, %eax
jmp 0x8556a
leaq 0x4(%rsi), %r9
addl %edx, %eax
movq %r15, %rcx
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
movl %edx, (%r9)
incl %edx
movl %edx, (%rcx)
movq (%rsp), %rbx
movq %rbx, %rdi
callq 0x85c18
movq %rbx, %rdi
movq %r15, %rsi
callq 0x85c18
incq %r13
cmpq %rbp, %r13
jne 0x8545a
movl %ebp, %r13d
movq %r13, 0x18(%rsp)
testl %r13d, %r13d
jle 0x85754
movl 0x18(%rsp), %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 0x855df
xorl %r9d, %r9d
xorl %eax, %eax
xorl %ecx, %ecx
xorl %r10d, %r10d
jmp 0x856e8
leaq (%r14,%rax,8), %rax
movq (%rsp), %rcx
movq 0x270(%rcx), %rcx
movq 0x30(%rcx), %rcx
movq %rcx, 0x48(%rsp)
movl 0xc(%rax), %ecx
movl 0x14(%rax), %edi
movslq 0x10(%rax), %r8
movslq 0x8(%rax), %r14
movq %rcx, 0x58(%rsp)
leal 0x1(%rcx), %eax
movl %eax, 0x14(%rsp)
incl %edx
movl %edi, %r12d
movl %edi, %ebx
subl %r8d, %ebx
incl %ebx
leal 0x4(,%r8,8), %eax
movl %eax, 0x10(%rsp)
movq %r14, %rax
shlq $0x6, %rax
movq %r8, %r13
leaq (%rax,%r8,2), %rax
movq %rax, 0x40(%rsp)
xorl %r10d, %r10d
xorl %ecx, %ecx
xorl %eax, %eax
xorl %r9d, %r9d
movq %r14, 0x50(%rsp)
movl %edx, 0xc(%rsp)
cmpl 0x58(%rsp), %r14d
movq %rsi, 0x60(%rsp)
jg 0x856cf
leal 0x4(,%rsi,8), %edx
movslq %edx, %r11
movq 0x48(%rsp), %rdx
movq (%rdx,%rsi,8), %r8
addq 0x40(%rsp), %r8
movq %r14, %rdi
cmpl %r12d, %r13d
jg 0x856c2
leal 0x2(,%rdi,4), %edx
movslq %edx, %rsi
movl 0x10(%rsp), %r14d
xorl %edx, %edx
movzwl (%r8,%rdx,2), %ebp
testq %rbp, %rbp
je 0x856b7
addq %rbp, %r9
movq %rbp, %r15
imulq %r11, %r15
addq %r15, %rax
movq %rbp, %r15
imulq %rsi, %r15
addq %r15, %rcx
movslq %r14d, %r15
imulq %rbp, %r15
addq %r15, %r10
incq %rdx
addl $0x8, %r14d
cmpl %edx, %ebx
jne 0x8568c
incq %rdi
addq $0x40, %r8
cmpl %edi, 0x14(%rsp)
jne 0x85676
movq 0x60(%rsp), %rsi
incq %rsi
movl 0xc(%rsp), %edx
cmpl %esi, %edx
movq 0x50(%rsp), %r14
jne 0x8564f
movq %r9, %rsi
sarq %rsi
addq %rsi, %rax
cqto
idivq %r9
movq (%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 0x855ba
movq (%rsp), %rdi
movq 0x18(%rsp), %rcx
movl %ecx, 0x9c(%rdi)
movq (%rdi), %rax
movl $0x60, 0x28(%rax)
movl %ecx, 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