// File: /workspace/github_cpp_makefile_star2_O1/attractivechaos[P]udb2/stb/./stb.h
// Function: stb_dupe_finish
void stb_dupe_finish(stb_dupe *sd)
{
   int i,j,k;
   assert(sd->dupes == NULL);
   for (i=0; i < sd->hash_size; ++i) {
      void ** list = sd->hash_table[i];
      if (list != NULL) {                                          
         int n = stb_arr_len(list);
         // @TODO: measure to find good numbers instead of just making them up!
         int thresh = (sd->ineq ? 200 : 20);
         // if n is large enough to be worth it, and n is smaller than
         // before (so we can guarantee we'll use a smaller hash table);
         // and there are enough hash bits left, assuming full 32-bit hash
         if (n > thresh && n < (sd->population >> 3) && sd->hash_shift + sd->size_log2*2 < 32) {

            // recursively process this row using stb_dupe, O(N log log N)

            stb_dupe *d = stb_dupe_create(sd->hash, sd->eq, n, sd->ineq);
            d->hash_shift = stb_randLCG_explicit(sd->hash_shift);
            for (j=0; j < n; ++j)
               stb_dupe_add(d, list[j]);
            stb_arr_free(sd->hash_table[i]);
            stb_dupe_finish(d);
            for (j=0; j < stb_arr_len(d->dupes); ++j) {
               stb_arr_push(sd->dupes, d->dupes[j]);
               d->dupes[j] = NULL; // take over ownership
            }
            stb_dupe_free(d);

         } else if (sd->ineq) {

            // process this row using qsort(), O(N log N)
            stb__compare = sd->ineq;
            qsort(list, n, sizeof(list[0]), stb__dupe_compare);

            // find equal subsequences of the list
            for (j=0; j < n-1; ) {
               // find a subsequence from j..k
               for (k=j; k < n; ++k)
                  // only use ineq so eq can be left undefined
                  if (sd->ineq(list[j], list[k]))
                     break;
               // k is the first one not in the subsequence
               if (k-j > 1) {
                  void **mylist = NULL;
                  stb_arr_setlen(mylist, k-j);
                  memcpy(mylist, list+j, sizeof(list[j]) * (k-j));
                  stb_arr_push(sd->dupes, mylist);
               }
               j = k;
            }
            stb_arr_free(sd->hash_table[i]);
         } else {

            // process this row using eq(), O(N^2)
            for (j=0; j < n; ++j) {
               if (list[j] != NULL) {
                  void **output  = NULL;
                  for (k=j+1; k < n; ++k) {
                     if (sd->eq(list[j], list[k])) {
                        if (output == NULL)
                           stb_arr_push(output, list[j]);
                        stb_arr_push(output, list[k]);
                        list[k] = NULL;
                     }
                  }
                  list[j] = NULL;
                  if (output)
                     stb_arr_push(sd->dupes, output);
               }
            }
            stb_arr_free(sd->hash_table[i]);
         }
      }
   }
   free(sd->hash_table);
   sd->hash_table = NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpq $0x0, 0x30(%rdi)
jne 0xcd66
movq %rdi, %r15
cmpl $0x0, 0x8(%rdi)
jle 0xcd48
leaq 0x30(%r15), %rax
movq %rax, 0x8(%rsp)
xorl %r14d, %r14d
movq %r15, 0x18(%rsp)
movq (%r15), %rax
movq (%rax,%r14,8), %r13
testq %r13, %r13
je 0xcd24
movslq -0x10(%r13), %r12
movl %r12d, %r8d
movq 0x28(%r15), %rcx
testq %rcx, %rcx
movl $0xc8, %eax
movl $0x14, %edx
cmovel %edx, %eax
cmpl %eax, %r12d
jle 0xca4d
movl 0x10(%r15), %eax
sarl $0x3, %eax
cmpl %eax, %r12d
jge 0xca4d
movl 0xc(%r15), %eax
addl %eax, %eax
addl 0x14(%r15), %eax
cmpl $0x1f, %eax
jg 0xca4d
movq 0x18(%r15), %rdi
movq 0x20(%r15), %rsi
movl %r8d, %edx
movq %r8, %rbp
callq 0xc753
imull $0x7ff8a3ed, 0x14(%r15), %ecx # imm = 0x7FF8A3ED
addl $0x2aa01d31, %ecx       # imm = 0x2AA01D31
movl %ecx, 0x14(%rax)
testl %r12d, %r12d
movq %rax, %r12
jle 0xc9a2
xorl %ebx, %ebx
movq (%r13,%rbx,8), %rsi
movq %r12, %rdi
callq 0xc7fc
incq %rbx
cmpq %rbx, %rbp
jne 0xc98d
movq %r12, %rbx
movq %r14, %r12
leaq (,%r14,8), %rdi
addq (%r15), %rdi
callq 0x56c1
movq %rbx, %rdi
callq 0xc8d1
movq %rbx, %r13
movq 0x30(%rbx), %r14
xorl %r15d, %r15d
movq 0x8(%rsp), %rsi
testq %r14, %r14
je 0xc9da
movslq -0x10(%r14), %rax
jmp 0xc9dc
xorl %eax, %eax
cmpq %rax, %r15
jge 0xcd36
movq (%rsi), %rax
testq %rax, %rax
je 0xc9f4
movl -0x10(%rax), %ecx
incl %ecx
jmp 0xc9f9
movl $0x1, %ecx
testq %rax, %rax
je 0xca03
movl -0xc(%rax), %edx
jmp 0xca05
xorl %edx, %edx
movq (%r14,%r15,8), %rbx
cmpl %edx, %ecx
jle 0xca28
movq 0x8(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x57e0
movq 0x8(%rsp), %rsi
jmp 0xca2b
incl -0x10(%rax)
movq (%rsi), %rax
testq %rax, %rax
je 0xca39
movslq -0x10(%rax), %rcx
jmp 0xca3b
xorl %ecx, %ecx
movq %rbx, -0x8(%rax,%rcx,8)
movq $0x0, (%r14,%r15,8)
incq %r15
jmp 0xc9cf
movq %r14, 0x20(%rsp)
testq %rcx, %rcx
movq %r8, 0x10(%rsp)
je 0xcb95
movq %rcx, 0x13379(%rip)     # 0x1fde0
movl $0x8, %edx
movq %r13, %rdi
movq %r12, %rsi
leaq 0x30c(%rip), %rcx       # 0xcd85
callq 0x20a0
movq 0x10(%rsp), %rdx
cmpl $0x2, %edx
jl 0xcb83
leal -0x1(%rdx), %r14d
xorl %r12d, %r12d
xorl %ebp, %ebp
movslq %r12d, %rbx
cmpl %edx, %r12d
jge 0xcac8
movq %rbx, %rbp
movq (%r13,%rbx,8), %rdi
movq (%r13,%rbp,8), %rsi
callq *0x28(%r15)
testl %eax, %eax
jne 0xcac3
incq %rbp
movq 0x10(%rsp), %rdx
cmpq %rbp, %rdx
jne 0xcaa0
movl %edx, %ebp
jmp 0xcac8
movq 0x10(%rsp), %rdx
movl %ebp, %r15d
subl %r12d, %r15d
cmpl $0x2, %r15d
jl 0xcb72
movq $0x0, (%rsp)
movq %rsp, %rdi
movl $0x8, %esi
movl %r15d, %edx
movl %r15d, %ecx
callq 0x56fd
movq (%rsp), %r12
leaq (,%rbx,8), %rsi
addq %r13, %rsi
movl %r15d, %edx
shlq $0x3, %rdx
movq %r12, %rdi
callq 0x2230
movq 0x8(%rsp), %rsi
movq (%rsi), %rax
testq %rax, %rax
je 0xcb25
movl -0x10(%rax), %ecx
incl %ecx
jmp 0xcb2a
movl $0x1, %ecx
testq %rax, %rax
je 0xcb34
movl -0xc(%rax), %edx
jmp 0xcb36
xorl %edx, %edx
cmpl %edx, %ecx
jle 0xcb55
movq 0x8(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x57e0
movq 0x8(%rsp), %rsi
jmp 0xcb58
incl -0x10(%rax)
movq 0x10(%rsp), %rdx
movq (%rsi), %rax
testq %rax, %rax
je 0xcb6b
movslq -0x10(%rax), %rcx
jmp 0xcb6d
xorl %ecx, %ecx
movq %r12, -0x8(%rax,%rcx,8)
movl %ebp, %r12d
cmpl %r14d, %ebp
movq 0x18(%rsp), %r15
jl 0xca95
movq 0x20(%rsp), %r14
leaq (,%r14,8), %rdi
jmp 0xcd1c
testl %r12d, %r12d
jle 0xcd0a
movq %r8, %r15
movq %r13, %r12
xorl %r14d, %r14d
cmpq $0x0, (%r13,%r14,8)
je 0xccf7
movq $0x0, (%rsp)
leaq 0x1(%r14), %rax
cmpq %r8, %rax
jae 0xcc84
movl $0x1, %ebp
movq (%r13,%r14,8), %rdi
movq (%r12,%rbp,8), %rsi
movq 0x18(%rsp), %rax
callq *0x20(%rax)
testl %eax, %eax
je 0xcc78
cmpq $0x0, (%rsp)
jne 0xcc1a
movq (%r13,%r14,8), %rbx
movq %rsp, %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x57e0
movq (%rsp), %rax
testq %rax, %rax
je 0xcc13
movslq -0x10(%rax), %rcx
jmp 0xcc15
xorl %ecx, %ecx
movq %rbx, -0x8(%rax,%rcx,8)
movq (%r12,%rbp,8), %rbx
movq (%rsp), %rax
testq %rax, %rax
je 0xcc2e
movl -0x10(%rax), %ecx
incl %ecx
jmp 0xcc33
movl $0x1, %ecx
testq %rax, %rax
je 0xcc3d
movl -0xc(%rax), %edx
jmp 0xcc3f
xorl %edx, %edx
cmpl %edx, %ecx
jle 0xcc57
movq %rsp, %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x57e0
jmp 0xcc5a
incl -0x10(%rax)
movq (%rsp), %rax
testq %rax, %rax
je 0xcc69
movslq -0x10(%rax), %rcx
jmp 0xcc6b
xorl %ecx, %ecx
movq %rbx, -0x8(%rax,%rcx,8)
movq $0x0, (%r12,%rbp,8)
incq %rbp
cmpq %rbp, %r15
jne 0xcbcd
movq $0x0, (%r13,%r14,8)
movq (%rsp), %rbp
testq %rbp, %rbp
movq 0x8(%rsp), %rsi
je 0xccf2
movq (%rsi), %rax
testq %rax, %rax
je 0xccaa
movl -0x10(%rax), %ecx
incl %ecx
jmp 0xccaf
movl $0x1, %ecx
testq %rax, %rax
je 0xccb9
movl -0xc(%rax), %edx
jmp 0xccbb
xorl %edx, %edx
cmpl %edx, %ecx
jle 0xccda
movq 0x8(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x57e0
movq 0x8(%rsp), %rsi
jmp 0xccdd
incl -0x10(%rax)
movq (%rsi), %rax
testq %rax, %rax
je 0xcceb
movslq -0x10(%rax), %rcx
jmp 0xcced
xorl %ecx, %ecx
movq %rbp, -0x8(%rax,%rcx,8)
movq 0x10(%rsp), %r8
incq %r14
addq $0x8, %r12
decq %r15
cmpq %r8, %r14
jne 0xcba7
movq 0x20(%rsp), %r14
leaq (,%r14,8), %rdi
movq 0x18(%rsp), %r15
addq (%r15), %rdi
callq 0x56c1
incq %r14
movslq 0x8(%r15), %rax
cmpq %rax, %r14
jl 0xc908
jmp 0xcd48
movq %r13, %rdi
callq 0xc87f
movq 0x18(%rsp), %r15
movq %r12, %r14
jmp 0xcd24
movq (%r15), %rdi
callq 0x23d0
movq $0x0, (%r15)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5f89(%rip), %rdi      # 0x12cf6
leaq 0x578d(%rip), %rsi      # 0x12501
leaq 0x5f8d(%rip), %rcx      # 0x12d08
movl $0x20e8, %edx           # imm = 0x20E8
callq 0x2140