// File: /workspace/github_cpp_makefile_star2_O1/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 0x519f
movq -0x8(%rdi), %rbx
movl %ebx, %ecx
andl $0x3, %ecx
cmpl $0x1, %ecx
jne 0x51a8
decq %rbx
jmp 0x51af
leaq 0x150a2(%rip), %rbx     # 0x1a248
jmp 0x51af
addq $-0x20, %rdi
movq %rdi, %rbx
testl %eax, %eax
jg 0x520a
testb $0xf, %sil
je 0x51cb
movl %esi, %ecx
andl $0xf, %ecx
leaq 0xd03b(%rip), %rdi      # 0x12200
movsbl (%rcx,%rdi), %ecx
jmp 0x51e9
movl %esi, %edi
shrl $0x4, %edi
andl $0xf, %edi
leaq 0xd026(%rip), %rcx      # 0x12200
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 0x5203
movl %ecx, %eax
jmp 0x520a
negl %eax
cmpl %eax, %ecx
cmovll %ecx, %eax
leal -0x1(%rax), %ecx
testl %ecx, %eax
jne 0x5343
cmpl $0x9, %eax
movl $0x2, %ecx
cmovll %edx, %ecx
testl %edx, %edx
cmovnel %edx, %ecx
cmpl $0x4, %ecx
ja 0x5362
leaq 0xd00b(%rip), %rdx      # 0x12240
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
addq $0x10, %rsi
movq %rsi, %rdi
callq 0x2250
movq %rax, %rcx
testq %rax, %rax
je 0x5336
leaq 0x10(%rcx), %rax
leaq 0x8(%rbx), %rdx
movq %rdx, 0x8(%rcx)
movq 0x8(%rbx), %rdx
movq %rdx, (%rcx)
movq %rax, 0x8(%rbx)
testq %rdx, %rdx
je 0x5336
leaq -0x8(%rdx), %rsi
movl -0x8(%rdx), %edi
andl $0x3, %edi
addq $-0x20, %rdx
cmpl $0x2, %edi
cmovneq %rsi, %rdx
movq %rcx, (%rdx)
jmp 0x5336
addq $0x20, %rsi
movq %rsi, %rdi
callq 0x2250
movq %rax, %rcx
testq %rax, %rax
je 0x5336
leaq 0x20(%rcx), %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 0x52ee
leaq 0x10(%rcx), %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 0x5336
movq %rbx, %rdi
movl %eax, %edx
xorl %ecx, %ecx
callq 0x10a74
testq %rax, %rax
jne 0x533b
xorl %eax, %eax
jmp 0x5341
cmpl $0x9, %eax
movl $0x8, %ecx
cmovbl %ecx, %eax
movq %rbx, %rdi
movl %eax, %edx
callq 0x10a74
movq %rax, %rcx
testq %rax, %rax
je 0x5336
incq %rbx
movq %rbx, (%rcx)
leaq 0x8(%rcx), %rax
jmp 0x5336
testq %rcx, %rcx
je 0x5309
incl 0x18be3(%rip)           # 0x1df24
popq %rbx
retq
leaq 0xdc94(%rip), %rdi      # 0x12fde
leaq 0xd1b0(%rip), %rsi      # 0x12501
leaq 0xdc99(%rip), %rcx      # 0x12ff1
movl $0xb05, %edx            # imm = 0xB05
callq 0x2140
leaq 0xd4bd(%rip), %rdi      # 0x12826
leaq 0xd191(%rip), %rsi      # 0x12501
leaq 0xdc7a(%rip), %rcx      # 0x12ff1
movl $0xb2f, %edx            # imm = 0xB2F
callq 0x2140