// File: /workspace/github_c_makefile_star2_O0/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/base.c
// Function: je_base_alloc
void *
base_alloc(tsdn_t *tsdn, 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, 0, false, false);
	malloc_mutex_lock(tsdn, &base_mtx);
	node = extent_tree_szsnad_nsearch(&base_avail_szsnad, &key);
	if (node != NULL) {
		/* Use existing space. */
		extent_tree_szsnad_remove(&base_avail_szsnad, node);
	} else {
		/* Try to allocate more space. */
		node = base_chunk_alloc(tsdn, 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_szsnad_insert(&base_avail_szsnad, node);
	} else
		base_node_dalloc(tsdn, 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(tsdn, &base_mtx);
	return (ret);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x78(%rbp)
movq %rsi, -0x80(%rbp)
movq -0x80(%rbp), %rax
addq $0x3f, %rax
andq $-0x40, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpq $0x1000, -0x70(%rbp)    # imm = 0x1000
setbe %al
testb $0x1, %al
jne 0x50272
jmp 0x502cb
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 0x407eb(%rip), %rax     # 0x90a80
movzbl (%rax,%rcx), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
movl %eax, %ecx
leaq 0x40052(%rip), %rax     # 0x90300
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x50383
movq -0x70(%rbp), %rax
movq %rax, -0x28(%rbp)
movabsq $0x7000000000000000, %rax # imm = 0x7000000000000000
cmpq %rax, -0x28(%rbp)
seta %al
testb $0x1, %al
jne 0x502ea
jmp 0x502f7
movq $0x0, -0x20(%rbp)
jmp 0x5037b
movq -0x28(%rbp), %rdi
shlq %rdi
subq $0x1, %rdi
callq 0x50a40
movl %eax, %eax
movq %rax, -0x30(%rbp)
cmpq $0x6, -0x30(%rbp)
jae 0x50322
movl $0x3, %eax
movq %rax, -0x118(%rbp)
jmp 0x50335
movq -0x30(%rbp), %rax
subq $0x2, %rax
subq $0x1, %rax
movq %rax, -0x118(%rbp)
movq -0x118(%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, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rcx
leaq -0x110(%rbp), %rdi
xorl %eax, %eax
movl %eax, %r8d
xorl %r9d, %r9d
movq %r8, %rsi
movq %r8, %rdx
movl $0x0, (%rsp)
callq 0x50570
movq -0x78(%rbp), %rdi
leaq 0x53bf7(%rip), %rsi     # 0xa3fb8
callq 0x50630
leaq 0x53c3b(%rip), %rdi     # 0xa4008
leaq -0x110(%rbp), %rsi
callq 0x5d670
movq %rax, -0xa0(%rbp)
cmpq $0x0, -0xa0(%rbp)
je 0x503ff
movq -0xa0(%rbp), %rsi
leaq 0x53c10(%rip), %rdi     # 0xa4008
callq 0x5dbf0
jmp 0x50416
movq -0x78(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x50680
movq %rax, -0xa0(%rbp)
cmpq $0x0, -0xa0(%rbp)
jne 0x50430
movq $0x0, -0x88(%rbp)
jmp 0x5054d
movq -0xa0(%rbp), %rdi
callq 0x507c0
movq %rax, -0x88(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x507e0
cmpq -0x90(%rbp), %rax
jbe 0x504b7
movq -0xa0(%rbp), %rdi
movq -0x88(%rbp), %rsi
addq -0x90(%rbp), %rsi
callq 0x50800
movq -0xa0(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x507e0
movq -0x120(%rbp), %rdi
movq %rax, %rsi
subq -0x90(%rbp), %rsi
callq 0x50820
movq -0xa0(%rbp), %rsi
leaq 0x53b58(%rip), %rdi     # 0xa4008
callq 0x5d790
jmp 0x504c7
movq -0x78(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x50840
movq -0x90(%rbp), %rax
addq 0x53b3b(%rip), %rax     # 0xa4010
movq %rax, 0x53b34(%rip)     # 0xa4010
movq -0x88(%rbp), %rax
addq -0x90(%rbp), %rax
addq $0xfff, %rax            # imm = 0xFFF
andq $-0x1000, %rax          # imm = 0xF000
movq -0x88(%rbp), %rcx
addq $0xfff, %rcx            # imm = 0xFFF
andq $-0x1000, %rcx          # imm = 0xF000
subq %rcx, %rax
addq 0x53b03(%rip), %rax     # 0xa4018
movq %rax, 0x53afc(%rip)     # 0xa4018
leaq 0x53059(%rip), %rax     # 0xa357c
movb (%rax), %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x50549
movq -0x88(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x86070
jmp 0x5054b
jmp 0x5054d
movq -0x78(%rbp), %rdi
leaq 0x53a60(%rip), %rsi     # 0xa3fb8
callq 0x508b0
movq -0x88(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopl (%rax)