// File: /workspace/github_c_makefile_star2_O3/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, %rbp
movl %ecx, %r14d
cmpl $0x2, %edi
je 0xf0df0
cmpl $0x1, %edi
je 0xf0c29
testl %edi, %edi
jne 0xf1250
shlq $0x2, %r14
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x552d0
jmp 0xf1239
movslq %ecx, %rdx
shlq $0x2, %rdx
movq %rbx, %rdi
movq %rbp, %rsi
movq %rcx, %r15
callq 0x552d0
movl $0x1, %eax
testl %r15d, %r15d
jle 0xf123e
xorl %r13d, %r13d
movl $0xff00, %ecx           # imm = 0xFF00
movl $0xff, %edx
movl $0x80, %esi
movl $0x40, %r8d
xorl %r15d, %r15d
xorl %edi, %edi
movl (%rbp,%r13,4), %r10d
movl %r15d, %r11d
andl %ecx, %r11d
movl %r10d, %r9d
orl %ecx, %r9d
andl $0xff00ff, %r15d        # imm = 0xFF00FF
subl %r15d, %r9d
movl %r10d, %r15d
subl %r11d, %r10d
movl %r9d, %r11d
shrl $0x10, %r11d
shrl $0x8, %r10d
andl %edx, %r11d
cmpl %esi, %r11d
movb $0x2, %r12b
sbbb $0x0, %r12b
testl %r11d, %r11d
movzbl %r12b, %r12d
cmovel %r11d, %r12d
andl %edx, %r10d
cmpl $0x7f, %r10d
seta %r11b
shlb $0x3, %r11b
addb $0x8, %r11b
testl %r10d, %r10d
movzbl %r11b, %r11d
cmovel %r10d, %r11d
andl %edx, %r9d
cmpl %esi, %r9d
movl $0x80, %r10d
cmovbl %r8d, %r10d
testl %r9d, %r9d
cmovel %r9d, %r10d
orb %dil, %r10b
orb %r12b, %r10b
movl %r10d, %edi
orb %r11b, %dil
incq %r13
cmpq %r13, %r14
jne 0xf0c69
leal (%rdi,%rdi), %ecx
testb %dil, %cl
je 0xf123e
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 0xf0d2e
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 0xf0d14
jmp 0xf1239
cmpl $0x2, %ecx
jb 0xf1239
movq %rsi, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
movl %ecx, %edi
imull %edi, %edi
movl $0x4, %esi
callq 0x56580
testq %rax, %rax
je 0xf11ed
movq %rax, %r13
movq 0x8(%rsp), %rax
movq 0x48(%rax), %r12
movl (%r12), %r15d
leaq 0x430(%rsp), %rdi
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 0xf11e5
movq 0x8(%rsp), %rax
movslq 0x8(%rax), %rax
movq %rax, 0x20(%rsp)
leaq 0x30(%rsp), %rdx
movq %rbp, %rdi
leaq 0x430(%rsp), %rbp
movq %rdi, 0x28(%rsp)
movq 0x10(%rsp), %rsi
movq %rbp, %rcx
callq 0xf09d8
movq 0x10(%rsp), %r10
movq 0x8(%rsp), %r11
movl 0xc(%r11), %edi
testl %edi, %edi
jle 0xf0f99
movq 0x18(%rsp), %r9
movq 0x20(%rsp), %rax
leaq (%r9,%rax,4), %rax
notl %r15d
movl 0x8(%r11), %r8d
xorl %esi, %esi
xorl %ecx, %ecx
movq %r9, %rdx
testl %r8d, %r8d
jle 0xf0f81
xorl %edi, %edi
movl (%r12,%rdi,4), %r8d
cmpl %r15d, %r8d
je 0xf0f18
cmpl %r8d, 0x30(%rsp)
jne 0xf0ee5
xorl %r9d, %r9d
jmp 0xf0f03
xorl %esi, %esi
leal (%r10,%rsi), %r11d
sarl %r11d
movslq %r11d, %r9
cmpl %r8d, 0x30(%rsp,%r9,4)
jae 0xf0efe
movl %r11d, %esi
movl %r10d, %r11d
movl %r11d, %r10d
jne 0xf0ee7
movl 0x430(%rsp,%r9,4), %esi
movl %r8d, %r15d
movq 0x10(%rsp), %r10
movq 0x8(%rsp), %r11
movl %esi, (%rax,%rdi,4)
testq %rdi, %rdi
je 0xf0f45
movl -0x4(%rax,%rdi,4), %r8d
cmpl %r8d, %esi
je 0xf0f45
movl %esi, %r9d
imull %r10d, %r9d
addl %r8d, %r9d
incl (%r13,%r9,4)
imull %r10d, %r8d
addl %esi, %r8d
incl (%r13,%r8,4)
testl %ecx, %ecx
je 0xf0f6d
movl (%rdx,%rdi,4), %r8d
cmpl %r8d, %esi
je 0xf0f6d
movl %esi, %r9d
imull %r10d, %r9d
addl %r8d, %r9d
incl (%r13,%r9,4)
imull %r10d, %r8d
addl %esi, %r8d
incl (%r13,%r8,4)
incq %rdi
movslq 0x8(%r11), %r8
cmpq %r8, %rdi
jl 0xf0ed0
movl 0xc(%r11), %edi
movslq 0x50(%r11), %r9
leaq (%r12,%r9,4), %r12
incl %ecx
movq %rax, %r9
movq %rdx, %rax
cmpl %edi, %ecx
jl 0xf0ec2
movq 0x18(%rsp), %rdi
callq 0x57290
movq 0x10(%rsp), %r11
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 0xf0fb5
cmpl %esi, %edi
movzbl %cl, %ecx
cmoval %edx, %ecx
cmoval %edi, %esi
incl %edx
addq %r14, %rax
cmpl %r14d, %edx
jne 0xf0fb0
movb %cl, 0x30(%rsp)
movzbl %cl, %eax
movl %eax, %edx
imull %r11d, %edx
xorl %edi, %edi
xorl %esi, %esi
xorl %r8d, %r8d
xorl %r9d, %r9d
leal (%rdx,%rdi), %r10d
movl (%r13,%r10,4), %r10d
cmpl %r9d, %r10d
movzbl %sil, %esi
cmoval %edi, %esi
movzbl %r8b, %r8d
cmoval %edi, %r8d
cmoval %r10d, %r9d
incq %rdi
cmpq %rdi, %r14
jne 0xf0ff2
movb %sil, 0x31(%rsp)
cmpb %r8b, %cl
je 0xf126f
movl %r11d, %edx
addl $-0x2, %edx
je 0xf11f1
movb $0x0, 0x430(%rsp)
movl $0x0, 0x434(%rsp)
movzbl %sil, %esi
movzbl %cl, %ecx
xorl %edi, %edi
movl %esi, %r8d
xorl %r9d, %r9d
cmpq %rdi, %rcx
je 0xf109b
cmpq %rdi, %rsi
je 0xf109b
movl %r9d, %r10d
movb %dil, 0x430(%rsp,%r10,8)
movl %eax, %r11d
movl %r8d, %r15d
movl (%r13,%r15,4), %r15d
addl (%r13,%r11,4), %r15d
movl %r15d, 0x434(%rsp,%r10,8)
cmpl 0x4(%rbp), %r15d
jbe 0xf1093
leaq (%rsp,%r10,8), %rbp
addq $0x430, %rbp            # imm = 0x430
movq 0x10(%rsp), %r11
incl %r9d
incq %rdi
addl %r11d, %r8d
addl %r11d, %eax
cmpq %rdi, %r14
jne 0xf1055
leal -0x3(%r11), %edi
movl %edx, %r8d
xorl %r15d, %r15d
movl $0x1, %r12d
movl $0x1, %eax
movb (%rbp), %sil
movzbl %sil, %ecx
movq %rax, 0x8(%rsp)
leal 0x1(%rax), %r10d
movl %r15d, %eax
xorl %edx, %edx
divl %r11d
cmpl %r10d, %edx
jne 0xf10e9
movl %r10d, %eax
movq %rax, 0x8(%rsp)
jmp 0xf1170
movb %sil, 0x7(%rsp)
movl %r12d, %eax
movq %r11, %r12
movl %ecx, %r11d
imull %r12d, %r11d
movq %r15, 0x18(%rsp)
leal 0x1(%r15), %esi
xorl %r9d, %r9d
movl %eax, 0x20(%rsp)
movl %eax, %r15d
movl %edx, %eax
movzbl 0x30(%rsp,%rax), %eax
addl %r11d, %eax
movl (%r13,%rax,4), %eax
imull %r15d, %eax
addl %eax, %r9d
movl %esi, %eax
xorl %edx, %edx
divl %r12d
addl $-0x2, %r15d
incl %esi
cmpl %r10d, %edx
jne 0xf110e
testl %r9d, %r9d
jle 0xf1154
movq 0x18(%rsp), %r15
testl %r15d, %r15d
cmovel %r14d, %r15d
decl %r15d
movl %r15d, %r10d
movq 0x10(%rsp), %r11
jmp 0xf1166
movl %r10d, %eax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %r11
movq 0x18(%rsp), %r15
movl 0x20(%rsp), %r12d
movb 0x7(%rsp), %sil
movl %r10d, %eax
movb %sil, 0x30(%rsp,%rax)
movq 0x428(%rsp,%r8,8), %rax
movq %rax, (%rbp)
decq %r8
je 0xf11d9
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 0xf11ba
movq %rsi, %rbp
incq %rdx
addq $0x8, %rax
movq %rbp, %rsi
cmpq %rdx, %rdi
jne 0xf119a
decq %rdi
incl %r12d
movq 0x8(%rsp), %rax
jmp 0xf10be
movq 0x8(%rsp), %rax
incl %eax
movq %r15, %r12
jmp 0xf11f9
movq %r13, %rdi
callq 0x57290
xorl %eax, %eax
jmp 0xf123e
xorl %r12d, %r12d
movl $0x2, %eax
movq 0x28(%rsp), %r15
xorl %edx, %edx
divl %r11d
cmpl %r12d, %edx
jne 0xf128e
movq %r13, %rdi
callq 0x57290
movl %r12d, %ecx
xorl %esi, %esi
movq 0x10(%rsp), %rdi
leal (%rcx,%rsi), %eax
xorl %edx, %edx
divl %edi
movzbl 0x30(%rsp,%rdx), %eax
movl (%r15,%rax,4), %eax
movl %eax, (%rbx,%rsi,4)
incq %rsi
cmpq %rsi, %r14
jne 0xf121e
movl $0x1, %eax
addq $0xc38, %rsp            # imm = 0xC38
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3b0f3(%rip), %rdi     # 0x12c34a
leaq 0x3cbcb(%rip), %rsi     # 0x12de29
leaq 0x3cc25(%rip), %rcx     # 0x12de8a
movl $0x190, %edx            # imm = 0x190
callq 0x55710
leaq 0x3cd54(%rip), %rdi     # 0x12dfca
leaq 0x3cbac(%rip), %rsi     # 0x12de29
leaq 0x3cd51(%rip), %rcx     # 0x12dfd5
movl $0xf0, %edx
callq 0x55710
leaq 0x3ccac(%rip), %rdi     # 0x12df41
leaq 0x3cb8d(%rip), %rsi     # 0x12de29
leaq 0x3ccbf(%rip), %rcx     # 0x12df62
movl $0x172, %edx            # imm = 0x172
callq 0x55710
nopl (%rax)