// File: /workspace/github_cpp_makefile_star2_O3/attractivechaos[P]udb2/stb/./stb.h
// Function: malloc_base
static void * malloc_base(void *context, size_t size, stb__alloc_type t, int align)
{
   void *p;

   stb__alloc *src = stb__get_context(context);

   if (align <= 0) {
      // compute worst-case C packed alignment
      // e.g. a 24-byte struct is 8-aligned
      int align_proposed = 1 << stb_lowbit8(size);

      if (align_proposed < 0)
         align_proposed = 4;

      if (align_proposed == 0) {
         if (size == 0)
            align_proposed = 1;
         else
            align_proposed = 256;
      }

      // a negative alignment means 'don't align any larger
      // than this'; so -16 means we align 1,2,4,8, or 16

      if (align < 0) {
         if (align_proposed > -align)
            align_proposed = -align;
      }

      align = align_proposed;
   }

   assert(stb_is_pow2(align));

   // don't cause misalignment when allocating nochildren
   if (t == STB__nochildren && align > 8)
      t = STB__alloc;

   switch (t) {
      case STB__alloc: {
         stb__alloc *s = (stb__alloc *) malloc(size + sizeof(*s));
         if (s == NULL) return NULL;
         p = s+1;
         s->child = NULL;
         stb__insert_alloc(src, s);

         stb__setchunks(s,NULL);
         break;
      }

      case STB__nochildren: {
         stb__nochildren *s = (stb__nochildren *) malloc(size + sizeof(*s));
         if (s == NULL) return NULL;
         p = s+1;
         stb__insert_nochild(src, s);
         break;
      }

      case STB__chunk_raw: {
         p = stb__alloc_chunk(src, size, align, 0);
         if (p == NULL) return NULL;
         break;
      }

      case STB__chunked: {
         stb__chunked *s;
         if (align < sizeof(stb_uintptr)) align = sizeof(stb_uintptr);
         s = (stb__chunked *) stb__alloc_chunk(src, size, align, sizeof(*s));
         if (s == NULL) return NULL;
         stb__setparent(s, src);
         p = s+1;
         break;
      }

      default: p = NULL; assert(0); /* NOTREACHED */
   }

   ++stb_alloc_count_alloc;
   return p;
}

// Assembly:
pushq %rbx
movl %ecx, %eax
testq %rdi, %rdi
je 0x50a5
movq -0x8(%rdi), %rbx
movl %ebx, %ecx
andl $0x3, %ecx
cmpl $0x1, %ecx
jne 0x50ae
decq %rbx
jmp 0x50b5
leaq 0x1518c(%rip), %rbx     # 0x1a238
jmp 0x50b5
addq $-0x20, %rdi
movq %rdi, %rbx
testl %eax, %eax
jg 0x5110
testb $0xf, %sil
je 0x50d1
movl %esi, %ecx
andl $0xf, %ecx
leaq 0xd0d5(%rip), %rdi      # 0x121a0
movsbl (%rcx,%rdi), %ecx
jmp 0x50ef
movl %esi, %edi
shrl $0x4, %edi
andl $0xf, %edi
leaq 0xd0c0(%rip), %rcx      # 0x121a0
movsbl (%rdi,%rcx), %r8d
leal 0x4(%r8), %ecx
testl %edi, %edi
cmovel %r8d, %ecx
movl $0x1, %edi
shll %cl, %edi
cmpl $0x1f, %ecx
movl $0x4, %ecx
cmovnel %edi, %ecx
testl %eax, %eax
js 0x5109
movl %ecx, %eax
jmp 0x5110
negl %eax
cmpl %eax, %ecx
cmovll %ecx, %eax
leal -0x1(%rax), %ecx
testl %ecx, %eax
jne 0x5244
cmpl $0x9, %eax
movl $0x2, %ecx
cmovll %edx, %ecx
testl %edx, %edx
cmovnel %edx, %ecx
cmpl $0x4, %ecx
ja 0x5263
leaq 0xd0a5(%rip), %rdx      # 0x121e0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
addq $0x10, %rsi
movq %rsi, %rdi
callq 0x2250
testq %rax, %rax
je 0x5240
movq %rax, %rcx
addq $0x10, %rax
leaq 0x8(%rbx), %rdx
movq %rdx, 0x8(%rcx)
movq 0x8(%rbx), %rdx
movq %rdx, (%rcx)
movq %rax, 0x8(%rbx)
testq %rdx, %rdx
je 0x5238
leaq -0x8(%rdx), %rsi
movl -0x8(%rdx), %edi
andl $0x3, %edi
addq $-0x20, %rdx
cmpl $0x2, %edi
cmovneq %rsi, %rdx
movq %rcx, (%rdx)
jmp 0x5238
addq $0x20, %rsi
movq %rsi, %rdi
callq 0x2250
testq %rax, %rax
je 0x5240
movq %rax, %rcx
addq $0x20, %rax
movq $0x0, 0x8(%rcx)
leaq 0x8(%rbx), %rdx
movq %rdx, (%rcx)
movq 0x8(%rbx), %rdx
movq %rdx, 0x10(%rcx)
movq %rax, 0x8(%rbx)
testq %rdx, %rdx
je 0x51f7
movq %rcx, %rsi
addq $0x10, %rsi
leaq -0x8(%rdx), %rdi
movl -0x8(%rdx), %r8d
andl $0x3, %r8d
addq $-0x20, %rdx
cmpl $0x2, %r8d
cmovneq %rdi, %rdx
movq %rsi, (%rdx)
movq $0x2, 0x18(%rcx)
jmp 0x5238
movq %rbx, %rdi
movl %eax, %edx
xorl %ecx, %ecx
callq 0x10785
testq %rax, %rax
jne 0x5238
jmp 0x5240
cmpl $0x9, %eax
movl $0x8, %ecx
cmovbl %ecx, %eax
movq %rbx, %rdi
movl %eax, %edx
callq 0x10785
testq %rax, %rax
je 0x5240
incq %rbx
movq %rbx, (%rax)
addq $0x8, %rax
incl 0x18cd6(%rip)           # 0x1df14
jmp 0x5242
xorl %eax, %eax
popq %rbx
retq
leaq 0xdd39(%rip), %rdi      # 0x12f84
leaq 0xd25f(%rip), %rsi      # 0x124b1
leaq 0xdd3e(%rip), %rcx      # 0x12f97
movl $0xb05, %edx            # imm = 0xB05
callq 0x2140
leaq 0xd56c(%rip), %rdi      # 0x127d6
leaq 0xd240(%rip), %rsi      # 0x124b1
leaq 0xdd1f(%rip), %rcx      # 0x12f97
movl $0xb2f, %edx            # imm = 0xB2F
callq 0x2140