// File: /workspace/github_cpp_makefile_star2_O1/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 0xbe4d
movl %edi, %eax
andl $0x3, %eax
leaq 0x655e(%rip), %rcx      # 0x12294
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rdi, (%rsi)
xorl %edi, %edi
jmp 0xbe48
movslq -0x2(%rdi), %rcx
movq -0x2(%rdi,%rcx,8), %rax
movq %rax, (%rsi)
cmpq $0x4, %rcx
je 0xbda8
decq %rcx
movl %ecx, -0x2(%rdi)
jmp 0xbe48
movl 0x19(%rdi), %ecx
movq 0x1d(%rdi,%rcx,8), %rax
testl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jne 0xbd88
movl 0x1(%rdi), %edx
incl %ecx
andl %edx, %ecx
movq 0x1d(%rdi,%rcx,8), %rax
testl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
je 0xbd78
movq %rax, (%rsi)
movl %ecx, %edx
incl %edx
andl 0x1(%rdi), %edx
movl %edx, 0x19(%rdi)
movl 0x5(%rdi), %edx
cmpl $0xe, %edx
jl 0xbda8
decl %edx
cmpl 0x11(%rdi), %edx
jne 0xbe39
movq %rax, %rsi
popq %rbx
jmp 0xba0c
xorl %ecx, %ecx
cmpq $0x0, -0x1(%rdi)
setne %cl
xorl %eax, %eax
cmpq $0x0, 0x7(%rdi)
leal 0x1(%rcx), %r9d
setne %al
cmovel %ecx, %r9d
movq 0xf(%rdi), %rdx
movq 0x17(%rdi), %rcx
xorl %r10d, %r10d
testq %rdx, %rdx
setne %r10b
movl $0x2, %r8d
cmovel %eax, %r8d
xorl %r11d, %r11d
testq %rcx, %rcx
setne %r11b
movl $0x3, %ebx
cmovel %r8d, %ebx
addl %r10d, %r11d
addl %r9d, %r11d
movq -0x1(%rdi,%rbx,8), %r9
movq %r9, (%rsi)
movq $0x0, -0x1(%rdi,%rbx,8)
cmpl $0x2, %r11d
jne 0xbe48
decq %rdi
xorl %esi, %esi
testq %rdx, %rdx
cmovnel %eax, %esi
testq %rcx, %rcx
cmovnel %r8d, %esi
movq (%rdi,%rsi,8), %rbx
callq 0x23d0
movq %rbx, %rdi
jmp 0xbe48
movq $0x1, 0x1d(%rdi,%rcx,8)
movl %edx, 0x5(%rdi)
incl 0x9(%rdi)
movq %rdi, %rax
popq %rbx
retq
leaq 0x6de5(%rip), %rdi      # 0x12c39
leaq 0x66a6(%rip), %rsi      # 0x12501
leaq 0x6de2(%rip), %rcx      # 0x12c44
movl $0x1ed0, %edx           # imm = 0x1ED0
callq 0x2140