// File: /workspace/github_cpp_makefile_star2_O2/attractivechaos[P]udb2/stb/./stb.h
// Function: stb_ps_remove_any
stb_ps *stb_ps_remove_any(stb_ps *ps, void **value)
{
   assert(ps != NULL);
   switch (3 & (int) ps) {
      case STB_ps_direct:
         *value = ps;
         return NULL;
      case STB_ps_bucket: {
         stb_ps_bucket *b = GetBucket(ps);
         int count=0, slast=0, last=0;
         assert(STB_BUCKET_SIZE == 4);
         if (b->p[0]) { ++count;               last = 0; }
         if (b->p[1]) { ++count; slast = last; last = 1; }
         if (b->p[2]) { ++count; slast = last; last = 2; }
         if (b->p[3]) { ++count; slast = last; last = 3; }
         *value = b->p[last];
         b->p[last] = 0;
         if (count == 2) {
            void *leftover = b->p[slast]; // second to last
            stb_bucket_free(b);
            return (stb_ps *) leftover; 
         }
         return ps;
      }
      case STB_ps_array: {
         stb_ps_array *a = GetArray(ps);
         *value = a->p[a->count-1];
         if (a->count == 4)
            return stb_ps_remove(ps, *value);
         --a->count;
         return ps;
      }
      case STB_ps_hash: {
         stb_ps_hash *h = GetHash(ps);
         void **t = h->table;
         stb_uint32 n = h->any_offset;
         while (stb_ps_empty(t[n]))
            n = (n + 1) & h->mask;
         *value = t[n];
         h->any_offset = (n+1) & h->mask;
         // check if we need to skip down to the previous type
         if (h->count-1 < stb_ps_array_max || h->count-1 == h->shrink_threshhold)
            return stb_ps_remove(ps, *value);
         t[n] = STB_DEL;
         -- h->count;
         ++ h->count_deletes;
         return ps;
      }
   }
   return ps; /* NOTREACHED */
}

// Assembly:
pushq %rbx
testq %rdi, %rdi
je 0xaa91
movl %edi, %eax
andl $0x3, %eax
leaq 0x5838(%rip), %rcx      # 0x101c4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rdi, (%rsi)
xorl %edi, %edi
jmp 0xaa8c
movslq -0x2(%rdi), %rcx
movq -0x2(%rdi,%rcx,8), %rax
movq %rax, (%rsi)
cmpq $0x4, %rcx
je 0xa9f3
decq %rcx
movl %ecx, -0x2(%rdi)
jmp 0xaa8c
movl 0x19(%rdi), %ecx
movl %ecx, %ecx
movq 0x1d(%rdi,%rcx,8), %rax
testl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jne 0xa9d4
incl %ecx
andl 0x1(%rdi), %ecx
jmp 0xa9bf
movq %rax, (%rsi)
leal 0x1(%rcx), %edx
andl 0x1(%rdi), %edx
movl %edx, 0x19(%rdi)
movl 0x5(%rdi), %edx
cmpl $0xe, %edx
jl 0xa9f3
decl %edx
cmpl 0x11(%rdi), %edx
jne 0xaa7d
movq %rax, %rsi
popq %rbx
jmp 0xa6d2
xorl %ecx, %ecx
cmpq $0x0, -0x1(%rdi)
setne %cl
leal 0x1(%rcx), %r9d
xorl %eax, %eax
cmpq $0x0, 0x7(%rdi)
setne %al
cmovel %ecx, %r9d
movq 0xf(%rdi), %rdx
movq 0x17(%rdi), %rcx
xorl %r10d, %r10d
testq %rdx, %rdx
setne %r10b
pushq $0x2
popq %r8
cmovel %eax, %r8d
xorl %r11d, %r11d
testq %rcx, %rcx
setne %r11b
pushq $0x3
popq %rbx
cmovel %r8d, %ebx
addl %r10d, %r11d
addl %r9d, %r11d
movq -0x1(%rdi,%rbx,8), %r9
movq %r9, (%rsi)
andq $0x0, -0x1(%rdi,%rbx,8)
cmpl $0x2, %r11d
jne 0xaa8c
decq %rdi
xorl %esi, %esi
testq %rdx, %rdx
cmovnel %eax, %esi
testq %rcx, %rcx
cmovnel %r8d, %esi
movq (%rdi,%rsi,8), %rbx
callq 0x23c0
movq %rbx, %rdi
jmp 0xaa8c
movq $0x1, 0x1d(%rdi,%rcx,8)
movl %edx, 0x5(%rdi)
incl 0x9(%rdi)
movq %rdi, %rax
popq %rbx
retq
leaq 0x60c1(%rip), %rdi      # 0x10b59
leaq 0x5982(%rip), %rsi      # 0x10421
leaq 0x60be(%rip), %rcx      # 0x10b64
movl $0x1ed0, %edx           # imm = 0x1ED0
callq 0x2140