// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/libraries/libwebp/src/utils/palette.c
// Function: PaletteSort
int PaletteSort(PaletteSorting method, const struct WebPPicture* const pic,
                const uint32_t* const palette_sorted, uint32_t num_colors,
                uint32_t* const palette) {
  switch (method) {
    case kSortedDefault:
      // Nothing to do, we have already sorted the palette.
      memcpy(palette, palette_sorted, num_colors * sizeof(*palette));
      return 1;
    case kMinimizeDelta:
      PaletteSortMinimizeDeltas(palette_sorted, num_colors, palette);
      return 1;
    case kModifiedZeng:
      return PaletteSortModifiedZeng(pic, palette_sorted, num_colors, palette);
    case kUnusedPalette:
    case kPaletteSortingNum:
      break;
  }

  assert(0);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc38, %rsp            # imm = 0xC38
movq %r8, %rbx
movq %rdx, %r12
movl %ecx, %r14d
cmpl $0x2, %edi
movq %rcx, 0x10(%rsp)
je 0xf1a30
cmpl $0x1, %edi
je 0xf1966
testl %edi, %edi
jne 0xf1fc2
shlq $0x2, %r14
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x552d0
jmp 0xf1fa9
movslq %ecx, %rdx
shlq $0x2, %rdx
movq %rbx, %rdi
movq %r12, %rsi
movq %rcx, %r15
callq 0x552d0
xorl %r10d, %r10d
testl %r15d, %r15d
jle 0xf1e3e
movl $0xff00, %eax           # imm = 0xFF00
movl $0xff, %ecx
movl $0x80, %edx
movl $0x40, %esi
xorl %edi, %edi
xorl %r8d, %r8d
movl (%r12,%rdi,4), %r11d
movl %r10d, %ebp
andl %eax, %ebp
movl %r11d, %r9d
orl %eax, %r9d
andl $0xff00ff, %r10d        # imm = 0xFF00FF
subl %r10d, %r9d
movl %r11d, %r10d
subl %ebp, %r11d
movl %r9d, %ebp
shrl $0x10, %ebp
shrl $0x8, %r11d
andl %ecx, %ebp
cmpl %edx, %ebp
movb $0x2, %r15b
sbbb $0x0, %r15b
testl %ebp, %ebp
movzbl %r15b, %r15d
cmovel %ebp, %r15d
andl %ecx, %r11d
cmpl $0x7f, %r11d
seta %bpl
shlb $0x3, %bpl
addb $0x8, %bpl
testl %r11d, %r11d
movzbl %bpl, %ebp
cmovel %r11d, %ebp
andl %ecx, %r9d
cmpl %edx, %r9d
movl $0x80, %r11d
cmovbl %esi, %r11d
testl %r9d, %r9d
cmovel %r9d, %r11d
orb %r8b, %r11b
orb %r15b, %r11b
orb %bpl, %r11b
incq %rdi
movl %r11d, %r8d
cmpq %rdi, %r14
jne 0xf19a0
jmp 0xf1e41
cmpl $0x2, %ecx
jb 0xf1fa9
movq %rsi, 0x8(%rsp)
movq %r12, 0x28(%rsp)
movl %ecx, %edi
imull %edi, %edi
movl $0x4, %esi
callq 0x56580
testq %rax, %rax
je 0xf1f45
movq %rax, %r13
movq 0x8(%rsp), %rax
movq 0x48(%rax), %r12
movl (%r12), %r15d
leaq 0x430(%rsp), %rdi
xorl %ebp, %ebp
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x55f20
movq 0x8(%rsp), %rax
movslq 0x8(%rax), %rdi
addq %rdi, %rdi
movl $0x4, %esi
callq 0x56b20
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0xf1f49
movq 0x8(%rsp), %rax
movslq 0x8(%rax), %rax
movq %rax, 0x20(%rsp)
leaq 0x30(%rsp), %rdx
leaq 0x430(%rsp), %rbp
movq 0x28(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %rbp, %rcx
callq 0xf16c3
movq 0x10(%rsp), %r11
movq 0x8(%rsp), %r10
cmpl $0x0, 0xc(%r10)
jle 0xf1be3
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rax
leaq (%rsi,%rax,4), %rax
notl %r15d
xorl %edi, %edi
xorl %ecx, %ecx
movq %rsi, %rdx
cmpl $0x0, 0x8(%r10)
jle 0xf1bc9
xorl %esi, %esi
movl (%r12,%rsi,4), %r8d
cmpl %r15d, %r8d
je 0xf1b64
cmpl %r8d, 0x30(%rsp)
jne 0xf1b20
xorl %edi, %edi
jmp 0xf1b5a
xorl %r10d, %r10d
movl %r11d, %r9d
leal (%r9,%r10), %r11d
sarl %r11d
movslq %r11d, %r11
movl %r10d, %r15d
cmpl %r8d, 0x30(%rsp,%r11,4)
cmovbl %r11d, %r15d
cmovel %r10d, %r15d
cmoval %r11d, %r9d
cmovel %r11d, %edi
movl %r15d, %r10d
jne 0xf1b26
movslq %edi, %rdi
movq 0x10(%rsp), %r11
movq 0x8(%rsp), %r10
movl 0x430(%rsp,%rdi,4), %edi
movl %r8d, %r15d
movl %edi, (%rax,%rsi,4)
testq %rsi, %rsi
je 0xf1b91
movl -0x4(%rax,%rsi,4), %r8d
cmpl %r8d, %edi
je 0xf1b91
movl %edi, %r9d
imull %r11d, %r9d
addl %r8d, %r9d
incl (%r13,%r9,4)
imull %r11d, %r8d
addl %edi, %r8d
incl (%r13,%r8,4)
testl %ecx, %ecx
je 0xf1bb9
movl (%rdx,%rsi,4), %r8d
cmpl %r8d, %edi
je 0xf1bb9
movl %edi, %r9d
imull %r11d, %r9d
addl %r8d, %r9d
incl (%r13,%r9,4)
imull %r11d, %r8d
addl %edi, %r8d
incl (%r13,%r8,4)
incq %rsi
movslq 0x8(%r10), %r8
cmpq %r8, %rsi
jl 0xf1b0c
movslq 0x50(%r10), %rsi
leaq (%r12,%rsi,4), %r12
incl %ecx
movq %rax, %rsi
movq %rdx, %rax
cmpl 0xc(%r10), %ecx
jl 0xf1afc
movq 0x18(%rsp), %rdi
callq 0x57290
movq 0x10(%rsp), %r11
movb $0x0, 0x30(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
xorl %edx, %edx
xorl %esi, %esi
xorl %r8d, %r8d
xorl %edi, %edi
leal (%rax,%r8), %r9d
addl (%r13,%r9,4), %edi
incq %r8
cmpq %r8, %r14
jne 0xf1c04
cmpl %esi, %edi
movzbl %cl, %ecx
cmoval %edx, %ecx
cmoval %edi, %esi
incl %edx
addq %r14, %rax
cmpl %r14d, %edx
jne 0xf1bff
movb %cl, 0x30(%rsp)
movb $0x0, 0x31(%rsp)
movzbl %cl, %eax
movl %eax, %edx
imull %r11d, %edx
xorl %edi, %edi
xorl %esi, %esi
xorl %r8d, %r8d
leal (%rdx,%rdi), %r9d
movl (%r13,%r9,4), %r9d
cmpl %r8d, %r9d
movzbl %sil, %esi
cmoval %edi, %esi
cmoval %r9d, %r8d
incq %rdi
cmpq %rdi, %r14
jne 0xf1c43
movb %sil, 0x31(%rsp)
cmpb %sil, %cl
je 0xf1fe1
movl %r11d, %edx
addl $-0x2, %edx
je 0xf1f53
movb $0x0, 0x430(%rsp)
movl $0x0, 0x434(%rsp)
movzbl %sil, %esi
cmpl $0x1, %r11d
movl %r11d, %edi
adcl $0x0, %edi
movzbl %cl, %ecx
xorl %r8d, %r8d
movl %esi, %r9d
xorl %r10d, %r10d
cmpq %r8, %rcx
je 0xf1cef
cmpq %r8, %rsi
je 0xf1cef
movl %r10d, %r11d
movb %r8b, 0x430(%rsp,%r11,8)
movl %eax, %r15d
movl %r9d, %r12d
movl (%r13,%r12,4), %r12d
addl (%r13,%r15,4), %r12d
movl %r12d, 0x434(%rsp,%r11,8)
cmpl 0x4(%rbp), %r12d
jbe 0xf1ce7
leaq (%rsp,%r11,8), %rbp
addq $0x430, %rbp            # imm = 0x430
movq 0x10(%rsp), %r11
incl %r10d
incq %r8
addl %r11d, %r9d
addl %r11d, %eax
cmpq %r8, %rdi
jne 0xf1ca9
leal -0x3(%r11), %edi
movl %edx, %r12d
xorl %r15d, %r15d
movl $0x1, %r8d
movl $0x1, %esi
movb (%rbp), %r9b
movzbl %r9b, %ecx
leal 0x1(%rsi), %r10d
movl %r15d, %eax
xorl %edx, %edx
divl %r11d
cmpl %r10d, %edx
jne 0xf1d38
movl %r10d, %eax
movq %rax, 0x8(%rsp)
jmp 0xf1dc2
movb %r9b, 0x7(%rsp)
movq %rsi, 0x8(%rsp)
movq %r12, 0x20(%rsp)
movq %r11, %r12
movl %ecx, %r11d
imull %r12d, %r11d
movq %r15, 0x18(%rsp)
leal 0x1(%r15), %esi
xorl %r15d, %r15d
movl %r8d, %r9d
movl %edx, %eax
movzbl 0x30(%rsp,%rax), %eax
addl %r11d, %eax
movl (%r13,%rax,4), %eax
imull %r9d, %eax
addl %eax, %r15d
movl %esi, %eax
xorl %edx, %edx
divl %r12d
addl $-0x2, %r9d
incl %esi
cmpl %r10d, %edx
jne 0xf1d60
testl %r15d, %r15d
movq 0x20(%rsp), %r12
jle 0xf1dab
movq 0x18(%rsp), %r15
testl %r15d, %r15d
cmovel %r14d, %r15d
decl %r15d
movl %r15d, %r10d
movq 0x10(%rsp), %r11
jmp 0xf1dbd
movl %r10d, %eax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %r11
movq 0x18(%rsp), %r15
movb 0x7(%rsp), %r9b
movl %r10d, %eax
movb %r9b, 0x30(%rsp,%rax)
movq 0x428(%rsp,%r12,8), %rax
movq %rax, (%rbp)
leaq 0x430(%rsp), %rbp
decq %r12
je 0xf1e23
imull %r11d, %ecx
leaq 0x430(%rsp), %rsi
movq %rsi, %rax
xorl %edx, %edx
movzbl (%rax), %r9d
addl %ecx, %r9d
movl 0x4(%rax), %r10d
addl (%r13,%r9,4), %r10d
movl %r10d, 0x4(%rax)
movq %rax, %rbp
cmpl 0x4(%rsi), %r10d
ja 0xf1e14
movq %rsi, %rbp
incq %rdx
addq $0x8, %rax
movq %rbp, %rsi
cmpq %rdx, %rdi
jne 0xf1df4
decq %rdi
incl %r8d
testq %r12, %r12
movq 0x8(%rsp), %rsi
jne 0xf1d12
incl %esi
jmp 0xf1f5b
xorl %r11d, %r11d
movl $0x1, %ebp
cmpl $0x0, 0x10(%rsp)
jle 0xf1fae
leal (%r11,%r11), %eax
andb %r11b, %al
je 0xf1fae
xorl %eax, %eax
movl $0xff, %ecx
movl $0x81, %edx
xorl %esi, %esi
movl %esi, %edi
andl $0xff00ff00, %edi       # imm = 0xFF00FF00
andl $0xff00ff, %esi         # imm = 0xFF00FF
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %rax, %r9
movl %eax, %r10d
movl (%rbx,%r9,4), %r15d
movl %r15d, %r11d
orl $0xff0000, %r11d        # imm = 0xFF0000
subl %edi, %r11d
orl $0xff00, %r15d          # imm = 0xFF00
subl %esi, %r15d
movl %r15d, %r12d
andl %ecx, %r12d
movl $0x100, %r13d           # imm = 0x100
subl %r12d, %r13d
cmpl %edx, %r12d
cmovbl %r12d, %r13d
movl %r11d, %r12d
shrl $0x8, %r12d
andl %ecx, %r12d
movl $0x100, %ebp            # imm = 0x100
subl %r12d, %ebp
cmpl %edx, %r12d
cmovbl %r12d, %ebp
addl %r13d, %ebp
shrl $0x10, %r15d
andl %ecx, %r15d
movl $0x100, %r12d           # imm = 0x100
subl %r15d, %r12d
cmpl %edx, %r15d
cmovbl %r15d, %r12d
addl %ebp, %r12d
leal (%r12,%r12,8), %ebp
movl %r11d, %r15d
shrl $0x18, %r15d
movl $0x100, %r12d           # imm = 0x100
subl %r15d, %r12d
cmpl $0x81000000, %r11d      # imm = 0x81000000
cmovbl %r15d, %r12d
addl %ebp, %r12d
cmpl %r12d, %r8d
cmoval %r9d, %r10d
cmovael %r12d, %r8d
incq %r9
cmpq %r9, %r14
jne 0xf1e86
movslq %r10d, %rdi
movl (%rbx,%rdi,4), %esi
movl (%rbx,%rax,4), %r8d
movl %r8d, (%rbx,%rdi,4)
movl %esi, (%rbx,%rax,4)
incq %rax
cmpq %r14, %rax
jne 0xf1e6c
jmp 0xf1fa9
xorl %ebp, %ebp
jmp 0xf1fae
movq %r13, %rdi
callq 0x57290
jmp 0xf1fae
xorl %r15d, %r15d
movl $0x2, %esi
movl %esi, %eax
xorl %edx, %edx
divl %r11d
cmpl %r15d, %edx
jne 0xf2000
movq %r11, %r14
movq %r13, %rdi
callq 0x57290
cmpl $0x1, %r14d
movl %r14d, %ecx
adcl $0x0, %ecx
movl %r15d, %esi
xorl %edi, %edi
movq 0x28(%rsp), %r8
movq %r14, %r9
leal (%rsi,%rdi), %eax
xorl %edx, %edx
divl %r9d
movzbl 0x30(%rsp,%rdx), %eax
movl (%r8,%rax,4), %eax
movl %eax, (%rbx,%rdi,4)
incq %rdi
cmpq %rdi, %rcx
jne 0xf1f8d
movl $0x1, %ebp
movl %ebp, %eax
addq $0xc38, %rsp            # imm = 0xC38
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3b131(%rip), %rdi     # 0x12d0fa
leaq 0x3cc31(%rip), %rsi     # 0x12ec01
leaq 0x3cc8b(%rip), %rcx     # 0x12ec62
movl $0x190, %edx            # imm = 0x190
callq 0x55710
leaq 0x3cdba(%rip), %rdi     # 0x12eda2
leaq 0x3cc12(%rip), %rsi     # 0x12ec01
leaq 0x3cdb7(%rip), %rcx     # 0x12edad
movl $0xf0, %edx
callq 0x55710
leaq 0x3cd12(%rip), %rdi     # 0x12ed19
leaq 0x3cbf3(%rip), %rsi     # 0x12ec01
leaq 0x3cd25(%rip), %rcx     # 0x12ed3a
movl $0x172, %edx            # imm = 0x172
callq 0x55710
nop