// File: /workspace/github_cpp_makefile_star2_O2/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 $0x38, %rsp
cmpq $0x0, 0x30(%rdi)
jne 0xb738
movq %rdi, %r14
leaq 0x30(%rdi), %rax
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
movq %rdi, 0x18(%rsp)
movslq 0x8(%r14), %rax
movq (%r14), %rdi
cmpq %rax, %r12
jge 0xb720
movq (%rdi,%r12,8), %r13
testq %r13, %r13
je 0xb685
movl -0x10(%r13), %ebx
movq 0x28(%r14), %rcx
testq %rcx, %rcx
movl $0xc8, %eax
pushq $0x14
popq %rdx
cmovel %edx, %eax
cmpl %eax, %ebx
movq %rbx, 0x20(%rsp)
jle 0xb448
movl 0x10(%r14), %eax
sarl $0x3, %eax
cmpl %eax, %ebx
jge 0xb448
movl 0xc(%r14), %eax
addl %eax, %eax
addl 0x14(%r14), %eax
cmpl $0x1f, %eax
jg 0xb448
movq 0x18(%r14), %rdi
movq 0x20(%r14), %rsi
movl %ebx, %edx
callq 0xb23c
imull $0x7ff8a3ed, 0x14(%r14), %ecx # imm = 0x7FF8A3ED
movq %rax, %r15
addl $0x2aa01d31, %ecx       # imm = 0x2AA01D31
movl %ecx, 0x14(%rax)
xorl %ebx, %ebx
cmpq %rbx, 0x20(%rsp)
je 0xb68d
movq (%r13,%rbx,8), %rsi
movq %r15, %rdi
callq 0xb2c2
incq %rbx
jmp 0xb42b
testq %rcx, %rcx
movq %r12, 0x30(%rsp)
je 0xb53d
movslq %ebx, %r15
movq %rcx, 0x12970(%rip)     # 0x1ddd0
movq %r13, %rdi
movq %r15, %rsi
pushq $0x8
popq %rdx
leaq 0x2e7(%rip), %rcx       # 0xb757
callq 0x20a0
leal -0x1(%rbx), %eax
movl %eax, 0x2c(%rsp)
xorl %ebx, %ebx
cmpl 0x2c(%rsp), %ebx
jge 0xb66b
movslq %ebx, %r12
leaq (,%r12,8), %rbp
addq %r13, %rbp
movq 0x18(%rsp), %r14
cmpq %r15, %r12
jge 0xb4b6
movq (%rbp), %rdi
movq (%r13,%r12,8), %rsi
callq *0x28(%r14)
testl %eax, %eax
jne 0xb4bb
incq %r12
jmp 0xb49b
movq 0x20(%rsp), %r12
movl %r12d, %r14d
subl %ebx, %r14d
movl %r12d, %ebx
cmpl $0x2, %r14d
jl 0xb47e
andq $0x0, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
pushq $0x8
popq %rsi
movl %r14d, %edx
callq 0x5206
movq 0x8(%rsp), %rax
movl %r14d, %edx
movq %rax, %r14
shlq $0x3, %rdx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2230
movq 0x10(%rsp), %rax
movq (%rax), %rax
testq %rax, %rax
je 0xb516
movl -0x10(%rax), %ecx
cmpl -0xc(%rax), %ecx
jge 0xb516
incl %ecx
movl %ecx, -0x10(%rax)
jmp 0xb52c
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
callq 0x521e
movq (%rbx), %rax
movslq -0x10(%rax), %rcx
movq %r14, -0x8(%rax,%rcx,8)
movl %r12d, %ebx
jmp 0xb47e
testl %ebx, %ebx
movl $0x0, %r12d
cmovgl %ebx, %r12d
xorl %r14d, %r14d
cmpq %r12, %r14
je 0xb66b
cmpq $0x0, (%r13,%r14,8)
je 0xb663
andq $0x0, 0x8(%rsp)
xorl %ebp, %ebp
movq %r14, %r15
leal 0x1(%r15), %eax
cmpl %eax, %ebx
jle 0xb618
movq (%r13,%r14,8), %rdi
movq 0x8(%r13,%r15,8), %rsi
movq 0x18(%rsp), %rax
callq *0x20(%rax)
incq %r15
testl %eax, %eax
je 0xb56c
testq %rbp, %rbp
je 0xb59b
movl -0x10(%rbp), %eax
jmp 0xb5c3
movq (%r13,%r14,8), %rbx
leaq 0x8(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
callq 0x521e
movq 0x8(%rsp), %rbp
testq %rbp, %rbp
je 0xb5d4
movslq -0x10(%rbp), %rax
movq %rbx, -0x8(%rbp,%rax,8)
movq (%r13,%r15,8), %rbx
cmpl -0xc(%rbp), %eax
jge 0xb5e1
incl %eax
movl %eax, -0x10(%rbp)
jmp 0xb5f6
movq %rbx, -0x8
movq (%r13,%r15,8), %rbx
leaq 0x8(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
callq 0x521e
movq 0x8(%rsp), %rbp
testq %rbp, %rbp
je 0xb601
movslq -0x10(%rbp), %rax
jmp 0xb603
xorl %eax, %eax
movq %rbx, -0x8(%rbp,%rax,8)
andq $0x0, (%r13,%r15,8)
movq 0x20(%rsp), %rbx
jmp 0xb56c
andq $0x0, (%r13,%r14,8)
testq %rbp, %rbp
je 0xb663
movq 0x10(%rsp), %rax
movq (%rax), %rax
testq %rax, %rax
je 0xb63f
movl -0x10(%rax), %ecx
cmpl -0xc(%rax), %ecx
jge 0xb63f
incl %ecx
movl %ecx, -0x10(%rax)
jmp 0xb65a
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
callq 0x521e
movq (%rbx), %rax
movq 0x20(%rsp), %rbx
movslq -0x10(%rax), %rcx
movq %rbp, -0x8(%rax,%rcx,8)
incq %r14
jmp 0xb54c
movq 0x30(%rsp), %r12
leaq (,%r12,8), %rdi
movq 0x18(%rsp), %r14
addq (%r14), %rdi
callq 0x510d
incq %r12
jmp 0xb3b0
movq %r12, %rbp
leaq (,%r12,8), %rdi
addq (%r14), %rdi
callq 0x510d
movq %r15, %rdi
callq 0xb383
movq 0x30(%r15), %r14
xorl %r12d, %r12d
testq %r14, %r14
je 0xb6ba
movslq -0x10(%r14), %rax
jmp 0xb6bc
xorl %eax, %eax
cmpq %rax, %r12
jge 0xb70b
movq (%r14,%r12,8), %rbx
movq 0x10(%rsp), %rax
movq (%rax), %rax
testq %rax, %rax
je 0xb6e1
movl -0x10(%rax), %ecx
cmpl -0xc(%rax), %ecx
jge 0xb6e1
incl %ecx
movl %ecx, -0x10(%rax)
jmp 0xb6f8
movq 0x10(%rsp), %r13
movq %r13, %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
callq 0x521e
movq (%r13), %rax
movslq -0x10(%rax), %rcx
movq %rbx, -0x8(%rax,%rcx,8)
andq $0x0, (%r14,%r12,8)
incq %r12
jmp 0xb6af
movq %r15, %rdi
callq 0xb326
movq 0x18(%rsp), %r14
movq %rbp, %r12
jmp 0xb685
callq 0x23c0
andq $0x0, (%r14)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x54d7(%rip), %rdi      # 0x10c16
leaq 0x4cdb(%rip), %rsi      # 0x10421
leaq 0x54db(%rip), %rcx      # 0x10c28
movl $0x20e8, %edx           # imm = 0x20E8
callq 0x2140