// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x78(%rbp)
movq -0x78(%rbp), %rax
addq $0x3f, %rax
andq $-0x40, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpq $0x1000, -0x70(%rbp)    # imm = 0x1000
setbe %al
testb $0x1, %al
jne 0x4f35e
jmp 0x4f3b9
movq -0x70(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rcx
subq $0x1, %rcx
shrq $0x3, %rcx
leaq 0x3f8ff(%rip), %rax     # 0x8ec80
movzbl (%rax,%rcx), %eax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl %eax, %ecx
leaq 0x3f164(%rip), %rax     # 0x8e500
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x4f481
movq -0x70(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
setl %al
testb $0x1, %al
jne 0x4f3cf
jmp 0x4f3f1
movq -0x28(%rbp), %rdx
shlq %rdx
movl $0x3f, %eax
movl $0x40, %ecx
cmpq $0x0, %rdx
cmovneq %rcx, %rax
movq %rax, -0x108(%rbp)
jmp 0x4f408
movq -0x28(%rbp), %rdi
shlq %rdi
subq $0x1, %rdi
callq 0x4fa60
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x6, -0x30(%rbp)
jae 0x4f428
movl $0x3, %eax
movq %rax, -0x110(%rbp)
jmp 0x4f43b
movq -0x30(%rbp), %rax
subq $0x2, %rax
subq $0x1, %rax
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
addq -0x48(%rbp), %rax
movq -0x48(%rbp), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rcx
leaq -0x100(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
xorl %r9d, %r9d
movq %rdx, %rsi
movl %r9d, %r8d
callq 0x4f640
leaq 0x5314d(%rip), %rdi     # 0xa2600
callq 0x4f6f0
leaq 0x53169(%rip), %rdi     # 0xa2628
leaq -0x100(%rbp), %rsi
callq 0x5c110
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
je 0x4f4f1
movq -0x98(%rbp), %rsi
leaq 0x5313e(%rip), %rdi     # 0xa2628
callq 0x5c6d0
jmp 0x4f504
movq -0x88(%rbp), %rdi
callq 0x4f710
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
jne 0x4f51b
movq $0x0, -0x80(%rbp)
jmp 0x4f625
movq -0x98(%rbp), %rdi
callq 0x4f840
movq %rax, -0x80(%rbp)
movq -0x98(%rbp), %rdi
callq 0x4f860
cmpq -0x88(%rbp), %rax
jbe 0x4f59c
movq -0x98(%rbp), %rdi
movq -0x80(%rbp), %rsi
addq -0x88(%rbp), %rsi
callq 0x4f880
movq -0x98(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x98(%rbp), %rdi
callq 0x4f860
movq -0x118(%rbp), %rdi
movq %rax, %rsi
subq -0x88(%rbp), %rsi
callq 0x4f8a0
movq -0x98(%rbp), %rsi
leaq 0x53093(%rip), %rdi     # 0xa2628
callq 0x5c270
jmp 0x4f5a8
movq -0x98(%rbp), %rdi
callq 0x4f8c0
movq -0x88(%rbp), %rax
addq 0x530e2(%rip), %rax     # 0xa2698
movq %rax, 0x530db(%rip)     # 0xa2698
movq -0x80(%rbp), %rax
addq -0x88(%rbp), %rax
addq $0xfff, %rax            # imm = 0xFFF
andq $-0x1000, %rax          # imm = 0xF000
movq -0x80(%rbp), %rcx
addq $0xfff, %rcx            # imm = 0xFFF
andq $-0x1000, %rcx          # imm = 0xF000
subq %rcx, %rax
addq 0x530b0(%rip), %rax     # 0xa26a0
movq %rax, 0x530a9(%rip)     # 0xa26a0
leaq 0x52106(%rip), %rax     # 0xa1704
movb (%rax), %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x4f621
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x7fb10
jmp 0x4f623
jmp 0x4f625
leaq 0x52fd4(%rip), %rdi     # 0xa2600
callq 0x4f920
movq -0x80(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nop