// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %r15d
movl %edx, %ebp
movq %rsi, %r14
testq %rdi, %rdi
je 0x4c5f
movq -0x8(%rdi), %rbx
movl %ebx, %eax
andl $0x3, %eax
cmpl $0x1, %eax
jne 0x4c68
decq %rbx
jmp 0x4c6f
leaq 0x135d2(%rip), %rbx     # 0x18238
jmp 0x4c6f
addq $-0x20, %rdi
movq %rdi, %rbx
testl %r15d, %r15d
jg 0x4ca0
movl %r14d, %edi
callq 0x37d3
pushq $0x1
popq %rdx
movl %eax, %ecx
shll %cl, %edx
cmpl $0x1f, %eax
pushq $0x4
popq %rax
cmovnel %edx, %eax
testl %r15d, %r15d
js 0x4c96
movl %eax, %r15d
jmp 0x4ca0
negl %r15d
cmpl %r15d, %eax
cmovll %eax, %r15d
leal -0x1(%r15), %eax
testl %eax, %r15d
jne 0x4d91
cmpl $0x9, %r15d
pushq $0x2
popq %rax
cmovll %ebp, %eax
testl %ebp, %ebp
cmovnel %ebp, %eax
cmpl $0x4, %eax
ja 0x4db0
leaq 0xb484(%rip), %rcx      # 0x10150
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
addq $0x10, %r14
movq %r14, %rdi
callq 0x2250
testq %rax, %rax
je 0x4d80
movq %rax, %r14
addq $0x10, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5020
jmp 0x4d78
addq $0x20, %r14
movq %r14, %rdi
callq 0x2250
testq %rax, %rax
je 0x4d80
movq %rax, %r15
movq %rax, %r14
addq $0x20, %r14
andq $0x0, 0x8(%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4fe7
movq $0x2, 0x18(%r15)
jmp 0x4d78
movq %rbx, %rdi
movl %r14d, %esi
movl %r15d, %edx
xorl %ecx, %ecx
callq 0xed27
movq %rax, %r14
testq %rax, %rax
jne 0x4d78
jmp 0x4d80
cmpl $0x9, %r15d
pushq $0x8
popq %rcx
cmovbl %ecx, %r15d
movq %rbx, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0xed27
testq %rax, %rax
je 0x4d80
movq %rax, %r14
incq %rbx
movq %rbx, (%rax)
addq $0x8, %r14
incl 0x17196(%rip)           # 0x1bf14
jmp 0x4d83
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc15c(%rip), %rdi      # 0x10ef4
leaq 0xb682(%rip), %rsi      # 0x10421
leaq 0xc161(%rip), %rcx      # 0x10f07
movl $0xb05, %edx            # imm = 0xB05
callq 0x2140
leaq 0xb98f(%rip), %rdi      # 0x10746
leaq 0xb663(%rip), %rsi      # 0x10421
leaq 0xc142(%rip), %rcx      # 0x10f07
movl $0xb2f, %edx            # imm = 0xB2F
callq 0x2140