// File: /workspace/github_c_makefile_star2_O1/erikdubbelboer[P]discnt/deps/jemalloc/src/base.c
// Function: je_base_alloc
void *
base_alloc(size_t size)
{
	void *ret;
	size_t csize, usize;
	extent_node_t *node;
	extent_node_t key;

	/*
	 * Round size up to nearest multiple of the cacheline size, so that
	 * there is no chance of false cache line sharing.
	 */
	csize = CACHELINE_CEILING(size);

	usize = s2u(csize);
	extent_node_init(&key, NULL, NULL, usize, false, false);
	malloc_mutex_lock(&base_mtx);
	node = extent_tree_szad_nsearch(&base_avail_szad, &key);
	if (node != NULL) {
		/* Use existing space. */
		extent_tree_szad_remove(&base_avail_szad, node);
	} else {
		/* Try to allocate more space. */
		node = base_chunk_alloc(csize);
	}
	if (node == NULL) {
		ret = NULL;
		goto label_return;
	}

	ret = extent_node_addr_get(node);
	if (extent_node_size_get(node) > csize) {
		extent_node_addr_set(node, (void *)((uintptr_t)ret + csize));
		extent_node_size_set(node, extent_node_size_get(node) - csize);
		extent_tree_szad_insert(&base_avail_szad, node);
	} else
		base_node_dalloc(node);
	if (config_stats) {
		base_allocated += csize;
		/*
		 * Add one PAGE to base_resident for every page boundary that is
		 * crossed by the new allocation.
		 */
		base_resident += PAGE_CEILING((uintptr_t)ret + csize) -
		    PAGE_CEILING((uintptr_t)ret);
	}
	JEMALLOC_VALGRIND_MAKE_MEM_DEFINED(ret, csize);
label_return:
	malloc_mutex_unlock(&base_mtx);
	return (ret);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x68, %rsp
addq $0x3f, %rdi
movq %rdi, %rbx
andq $-0x40, %rbx
cmpq $0x1000, %rbx           # imm = 0x1000
ja 0x4001e
leaq -0x1(%rbx), %rax
shrq $0x3, %rax
leaq 0x199ca(%rip), %rcx     # 0x59800
movzbl (%rcx,%rax), %eax
leaq 0x1923f(%rip), %rcx     # 0x59080
movq (%rcx,%rax,8), %rax
xorps %xmm0, %xmm0
movq %rsp, %r14
movaps %xmm0, (%r14)
movq %rax, 0x10(%r14)
movw $0x0, 0x18(%r14)
movb $0x0, 0x1a(%r14)
leaq 0x4470a(%rip), %rdi     # 0x84570
callq 0x12960
leaq 0x44726(%rip), %rdi     # 0x84598
movq %r14, %rsi
callq 0x466ed
testq %rax, %rax
je 0x3fe96
movq %rax, %r14
leaq 0x4470f(%rip), %rdi     # 0x84598
movq %rax, %rsi
callq 0x46b1f
jmp 0x3ff73
movq 0x44783(%rip), %r14     # 0x84620
testq %r14, %r14
je 0x3fec7
movq (%r14), %rax
movq %rax, 0x44774(%rip)     # 0x84620
leaq 0x438e1(%rip), %rax     # 0x83794
cmpb $0x1, (%rax)
jne 0x3feca
movl $0x68, %esi
movq %r14, %rdi
callq 0x507e2
jmp 0x3feca
xorl %r14d, %r14d
xorl %r12d, %r12d
testq %r14, %r14
sete %r12b
shll $0x7, %r12d
leaq 0x447c1(%rip), %rax     # 0x846a0
movq (%rax), %r15
leaq (%rbx,%r12), %rax
addq %r15, %rax
notq %r15
andq %rax, %r15
movq %r15, %rdi
callq 0x40653
testq %rax, %rax
je 0x3ff4a
addq %r15, 0x44715(%rip)     # 0x84618
testq %r14, %r14
jne 0x3ff2d
movq %rax, %r14
addq %r12, 0x446f6(%rip)     # 0x84608
addq %r12, %rax
subq %r12, %r15
addl $0xfff, %r12d           # imm = 0xFFF
andl $0x1000, %r12d          # imm = 0x1000
addq %r12, 0x446e3(%rip)     # 0x84610
movq $0x0, (%r14)
movq %rax, 0x8(%r14)
movq %r15, 0x10(%r14)
movw $0x101, 0x18(%r14)      # imm = 0x101
movb $0x0, 0x1a(%r14)
jmp 0x3ff73
testq %r14, %r14
je 0x3ff70
leaq 0x4383e(%rip), %rax     # 0x83794
cmpb $0x1, (%rax)
je 0x40053
movq 0x446ba(%rip), %rax     # 0x84620
movq %rax, (%r14)
movq %r14, 0x446b0(%rip)     # 0x84620
xorl %r14d, %r14d
testq %r14, %r14
je 0x3ffa2
movq 0x8(%r14), %r15
movq 0x10(%r14), %rax
subq %rbx, %rax
jbe 0x3ffa7
leaq (%rbx,%r15), %rcx
movq %rcx, 0x8(%r14)
movq %rax, 0x10(%r14)
leaq 0x44600(%rip), %rdi     # 0x84598
movq %r14, %rsi
callq 0x468cb
jmp 0x3ffc8
xorl %r15d, %r15d
jmp 0x40003
leaq 0x437e6(%rip), %rax     # 0x83794
cmpb $0x1, (%rax)
je 0x40041
movq 0x44662(%rip), %rax     # 0x84620
movq %rax, (%r14)
movq %r14, 0x44658(%rip)     # 0x84620
addq %rbx, 0x44639(%rip)     # 0x84608
leaq (%r15,%rbx), %rax
addq $0xfff, %rax            # imm = 0xFFF
movq $-0x1000, %rcx          # imm = 0xF000
andq %rcx, %rax
leaq 0xfff(%r15), %rdx
andq %rcx, %rdx
subq %rdx, %rax
addq %rax, 0x44619(%rip)     # 0x84610
leaq 0x43796(%rip), %rax     # 0x83794
cmpb $0x1, (%rax)
je 0x40034
leaq 0x44566(%rip), %rdi     # 0x84570
callq 0x125c0
movq %r15, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rsp, %r14
movq %rbx, %rsi
movq %r14, %rdx
callq 0x14b4c
movq (%r14), %rax
jmp 0x3fe45
movq %r15, %rdi
movq %rbx, %rsi
callq 0x50824
jmp 0x40003
movl $0x68, %esi
movq %r14, %rdi
callq 0x507e2
jmp 0x3ffb7
movl $0x68, %esi
movq %r14, %rdi
callq 0x507e2
jmp 0x3ff5f