// File: /workspace/github_cpp_makefile_star2_O2/attractivechaos[P]udb2/stb/./stb.h
// Function: stb_ps_add
stb_ps *  stb_ps_add   (stb_ps *ps, void *value)
{
   #ifdef STB_DEBUG
   assert(!stb_ps_find(ps,value));
   #endif
   if (value == NULL) return ps; // ignore NULL adds to avoid bad breakage
   assert((3 & (int) value) == STB_ps_direct);
   assert(stb_ps_fastlist_valid(value));
   assert(value != STB_DEL);     // STB_DEL is less likely

   switch (3 & (int) ps) {
      case STB_ps_direct:
         if (ps == NULL) return (stb_ps *) value;
         return EncodeBucket(stb_bucket_create2(ps,value));

      case STB_ps_bucket: {
         stb_ps_bucket *b = GetBucket(ps);
         stb_ps_array  *a;
         assert(STB_BUCKET_SIZE == 4);
         if (b->p[0] == NULL) { b->p[0] = value; return ps; }
         if (b->p[1] == NULL) { b->p[1] = value; return ps; }
         if (b->p[2] == NULL) { b->p[2] = value; return ps; }
         if (b->p[3] == NULL) { b->p[3] = value; return ps; }
         a = (stb_ps_array *) malloc(sizeof(*a) + 7 * sizeof(a->p[0])); // 8 slots, must be 2^k
         memcpy(a->p, b, sizeof(*b));
         a->p[4] = value;
         a->count = 5;
         stb_bucket_free(b);
         return EncodeArray(a);
      }

      case STB_ps_array: {
         stb_ps_array *a = GetArray(ps);
         if (a->count == stb_ps_array_max) {
            // promote from array to hash
            stb_ps_hash *h = stb_ps_makehash(2 << stb_log2_ceil(a->count), a->count, a->p);
            free(a);
            return stb_ps_add(EncodeHash(h), value);
         }
         // do we need to resize the array? the array doubles in size when it
         // crosses a power-of-two
         if ((a->count & (a->count-1))==0) {
            int newsize = a->count*2;
            // clamp newsize to max if:
            //    1. it's larger than max
            //    2. newsize*1.5 is larger than max (to avoid extra resizing)
            if (newsize + a->count > stb_ps_array_max)
               newsize = stb_ps_array_max;
            a = (stb_ps_array *) realloc(a, sizeof(*a) + (newsize-1) * sizeof(a->p[0]));
         }
         a->p[a->count++] = value;
         return EncodeArray(a);
      }
      case STB_ps_hash: {
         stb_ps_hash *h = GetHash(ps);
         stb_uint32 hash = stb_hashptr(value);
         stb_uint32 n = hash & h->mask;
         void **t = h->table;
         // find first NULL or STB_DEL entry
         if (!stb_ps_empty(t[n])) {
            stb_uint32 s = stb_rehash(hash) | 1;
            do {
               n = (n + s) & h->mask;
            } while (!stb_ps_empty(t[n]));
         }
         if (t[n] == STB_DEL)
            -- h->count_deletes;
         t[n] = value;
         ++ h->count;
         if (h->count == h->grow_threshhold) {
            stb_ps_hash *h2 = stb_ps_makehash(h->size*2, h->size, t);
            free(h);
            return EncodeHash(h2);
         }
         if (h->count + h->count_deletes == h->rehash_threshhold) {
            stb_ps_hash *h2 = stb_ps_makehash(h->size, h->size, t);
            free(h);
            return EncodeHash(h2);
         }
         return ps;
      }
   }
   return NULL; /* NOTREACHED */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x5d12(%rip), %r13      # 0x101a4
pushq $0xd
popq %rbp
pushq $0x2
popq %r15
movq %rdi, (%rsp)
testq %r14, %r14
je 0xa502
testb $0x3, %r14b
jne 0xa694
cmpq $0x1, %r14
jbe 0xa6b3
movl %ebx, %eax
andl $0x3, %eax
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
leaq -0x2(%rbx), %r12
movl -0x2(%rbx), %eax
cmpl $0xd, %eax
jne 0xa602
movl %ebp, %edi
callq 0x37b7
movl %r15d, %edi
movl %eax, %ecx
shll %cl, %edi
addq $0x6, %rbx
movl %ebp, %esi
movq %rbx, %rdx
callq 0xa283
movq %rax, %rbx
movq %r12, %rdi
callq 0x23c0
addq $0x3, %rbx
jmp 0xa49d
movq (%rsp), %rbx
jmp 0xa682
testq %rbx, %rbx
je 0xa668
pushq $0x20
popq %rdi
callq 0x2250
movq %rbx, (%rax)
movq %r14, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
incq %rax
movq %rax, %rbx
jmp 0xa682
leaq -0x1(%rbx), %r15
cmpq $0x0, -0x1(%rbx)
je 0xa66d
cmpq $0x0, 0x7(%rbx)
je 0xa672
cmpq $0x0, 0xf(%rbx)
je 0xa678
cmpq $0x0, 0x17(%rbx)
je 0xa67e
pushq $0x48
popq %rdi
callq 0x2250
movq %rax, %rbx
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups %xmm0, 0x8(%rax)
movups %xmm1, 0x18(%rax)
movq %r14, 0x28(%rax)
movl $0x5, (%rax)
movq %r15, %rdi
callq 0x23c0
addq $0x2, %rbx
jmp 0xa682
movq %r14, %rdi
callq 0x5355
movl 0x1(%rbx), %esi
movl %esi, %ecx
andl %eax, %ecx
leaq 0x1d(%rbx), %rdx
movq 0x1d(%rbx,%rcx,8), %rdi
testl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
je 0xa5db
movl %eax, %edi
shrl $0x6, %edi
addl %eax, %edi
shrl $0x13, %eax
addl %edi, %eax
orl $0x1, %eax
addl %eax, %ecx
andl %esi, %ecx
movq (%rdx,%rcx,8), %rdi
testl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
jne 0xa5cb
cmpq $0x1, %rdi
jne 0xa5e4
decl 0x9(%rbx)
leaq -0x3(%rbx), %r15
movq %r14, 0x1d(%rbx,%rcx,8)
movl 0x5(%rbx), %eax
incl %eax
movl %eax, 0x5(%rbx)
cmpl 0xd(%rbx), %eax
jne 0xa645
movl (%r15), %esi
leal (%rsi,%rsi), %edi
jmp 0xa652
leal -0x1(%rax), %ecx
testl %ecx, %eax
jne 0xa62e
cmpl $0x5, %eax
leal -0x1(%rax,%rax), %eax
pushq $0xc
popq %rcx
cmovll %eax, %ecx
movslq %ecx, %rax
leaq 0x10(,%rax,8), %rsi
movq %r12, %rdi
callq 0x22b0
movq %rax, %r12
movl (%rax), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r12)
cltq
movq %r14, 0x8(%r12,%rax,8)
addq $0x2, %r12
movq %r12, %rbx
jmp 0xa682
addl 0x9(%rbx), %eax
cmpl 0x15(%rbx), %eax
jne 0xa682
movl (%r15), %edi
movl %edi, %esi
callq 0xa283
movq %rax, %rbx
movq %r15, %rdi
callq 0x23c0
addq $0x3, %rbx
jmp 0xa682
movq %r14, %rbx
jmp 0xa682
movq %r14, (%r15)
jmp 0xa682
movq %r14, 0x7(%rbx)
jmp 0xa682
movq %r14, 0xf(%rbx)
jmp 0xa682
movq %r14, 0x17(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x63f3(%rip), %rdi      # 0x10a8e
leaq 0x5d7f(%rip), %rsi      # 0x10421
leaq 0x6447(%rip), %rcx      # 0x10af0
movl $0x1e2a, %edx           # imm = 0x1E2A
callq 0x2140
leaq 0x6419(%rip), %rdi      # 0x10ad3
leaq 0x5d60(%rip), %rsi      # 0x10421
leaq 0x6428(%rip), %rcx      # 0x10af0
movl $0x1e2b, %edx           # imm = 0x1E2B
callq 0x2140