// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/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 0x28991
leaq -0x1(%rbx), %rax
shrq $0x3, %rax
leaq 0x1a306(%rip), %rcx     # 0x42b00
movzbl (%rcx,%rax), %eax
leaq 0x19b7b(%rip), %rcx     # 0x42380
movq (%rcx,%rax,8), %rax
xorps %xmm0, %xmm0
movq %rsp, %r14
movaps %xmm0, (%r14)
movq %rax, 0x10(%r14)
andw $0x0, 0x18(%r14)
movb $0x0, 0x1a(%r14)
leaq 0x2ed57(%rip), %rdi     # 0x57580
callq 0x106d0
leaq 0x2ed73(%rip), %rdi     # 0x575a8
movq %r14, %rsi
callq 0x2e977
testq %rax, %rax
je 0x28861
movq %rax, %r14
leaq 0x2ed5c(%rip), %rdi     # 0x575a8
movq %rax, %rsi
callq 0x2eb97
movq 0x8(%r14), %r15
movq 0x10(%r14), %r12
jmp 0x288fc
movq 0x2edc8(%rip), %r14     # 0x57630
testq %r14, %r14
je 0x2888b
movq (%r14), %rax
movq %rax, 0x2edb9(%rip)     # 0x57630
leaq 0x2de06(%rip), %rax     # 0x56684
cmpb $0x1, (%rax)
je 0x289d5
xorl %eax, %eax
jmp 0x28890
movl $0x80, %eax
addq %rbx, %rax
leaq 0x2ee16(%rip), %rcx     # 0x576b0
movq (%rcx), %r12
addq %r12, %rax
notq %r12
andq %rax, %r12
movq %r12, %rdi
callq 0x28f97
testq %rax, %rax
je 0x2897f
movq %rax, %r15
addq %r12, 0x2ed67(%rip)     # 0x57628
testq %r14, %r14
jne 0x288e4
movq %r15, %r14
subq $-0x80, %r15
addq $-0x80, %r12
subq $-0x80, 0x2ed3f(%rip)   # 0x57618
addq $0x1000, 0x2ed3c(%rip) # imm = 0x1000
andq $0x0, (%r14)
movq %r15, 0x8(%r14)
movq %r12, 0x10(%r14)
movw $0x101, 0x18(%r14)      # imm = 0x101
movb $0x0, 0x1a(%r14)
subq %rbx, %r12
jbe 0x2891e
leaq (%rbx,%r15), %rax
movq %rax, 0x8(%r14)
movq %r12, 0x10(%r14)
leaq 0x2ec94(%rip), %rdi     # 0x575a8
movq %r14, %rsi
callq 0x2ea29
jmp 0x28926
movq %r14, %rdi
callq 0x289ff
movq %r15, %rax
addq %rbx, 0x2ece8(%rip)     # 0x57618
leaq (%r15,%rbx), %rcx
addq $0xfff, %rcx            # imm = 0xFFF
movq $-0x1000, %rdx          # imm = 0xF000
andq %rdx, %rcx
addq $0xfff, %rax            # imm = 0xFFF
andq %rdx, %rax
subq %rax, %rcx
addq %rcx, 0x2ecc8(%rip)     # 0x57620
leaq 0x2dd25(%rip), %rax     # 0x56684
cmpb $0x1, (%rax)
je 0x289c8
leaq 0x2ec15(%rip), %rdi     # 0x57580
callq 0x10440
movq %r15, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
testq %r14, %r14
je 0x2898c
movq %r14, %rdi
callq 0x289ff
xorl %r15d, %r15d
jmp 0x28964
testq %rdi, %rdi
js 0x289e5
leaq -0x1(,%rbx,2), %rax
bsrq %rax, %rax
leal -0x3(%rax), %ecx
pushq $-0x1
popq %rdx
shlq %cl, %rdx
cmpq $0x6, %rax
notq %rdx
pushq $0x7
popq %rax
cmovaeq %rdx, %rax
leaq (%rax,%rbx), %rcx
notq %rax
andq %rcx, %rax
jmp 0x28809
movq %r15, %rdi
movq %rbx, %rsi
callq 0x38fac
jmp 0x28964
pushq $0x68
popq %rsi
movq %r14, %rdi
callq 0x38f6a
jmp 0x28887
movabsq $0x7fffffffffffffc0, %rax # imm = 0x7FFFFFFFFFFFFFC0
andq %rax, %rdi
cmpq $0x1, %rdi
pushq $0x40
popq %rax
sbbq $0x0, %rax
jmp 0x289a2