// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/deps/jemalloc/src/chunk.c
// Function: chunk_recycle
static void *
chunk_recycle(extent_tree_t *chunks_szad, extent_tree_t *chunks_ad, size_t size,
    size_t alignment, bool base, bool *zero)
{
	void *ret;
	extent_node_t *node;
	extent_node_t key;
	size_t alloc_size, leadsize, trailsize;
	bool zeroed;

	if (base) {
		/*
		 * This function may need to call base_node_{,de}alloc(), but
		 * the current chunk allocation request is on behalf of the
		 * base allocator.  Avoid deadlock (and if that weren't an
		 * issue, potential for infinite recursion) by returning NULL.
		 */
		return (NULL);
	}

	alloc_size = size + alignment - chunksize;
	/* Beware size_t wrap-around. */
	if (alloc_size < size)
		return (NULL);
	key.addr = NULL;
	key.size = alloc_size;
	malloc_mutex_lock(&chunks_mtx);
	node = extent_tree_szad_nsearch(chunks_szad, &key);
	if (node == NULL) {
		malloc_mutex_unlock(&chunks_mtx);
		return (NULL);
	}
	leadsize = ALIGNMENT_CEILING((uintptr_t)node->addr, alignment) -
	    (uintptr_t)node->addr;
	assert(node->size >= leadsize + size);
	trailsize = node->size - leadsize - size;
	ret = (void *)((uintptr_t)node->addr + leadsize);
	/* Remove node from the tree. */
	extent_tree_szad_remove(chunks_szad, node);
	extent_tree_ad_remove(chunks_ad, node);
	if (leadsize != 0) {
		/* Insert the leading space as a smaller chunk. */
		node->size = leadsize;
		extent_tree_szad_insert(chunks_szad, node);
		extent_tree_ad_insert(chunks_ad, node);
		node = NULL;
	}
	if (trailsize != 0) {
		/* Insert the trailing space as a smaller chunk. */
		if (node == NULL) {
			/*
			 * An additional node is required, but
			 * base_node_alloc() can cause a new base chunk to be
			 * allocated.  Drop chunks_mtx in order to avoid
			 * deadlock, and if node allocation fails, deallocate
			 * the result before returning an error.
			 */
			malloc_mutex_unlock(&chunks_mtx);
			node = base_node_alloc();
			if (node == NULL) {
				chunk_dealloc(ret, size, true);
				return (NULL);
			}
			malloc_mutex_lock(&chunks_mtx);
		}
		node->addr = (void *)((uintptr_t)(ret) + size);
		node->size = trailsize;
		extent_tree_szad_insert(chunks_szad, node);
		extent_tree_ad_insert(chunks_ad, node);
		node = NULL;
	}
	malloc_mutex_unlock(&chunks_mtx);

	zeroed = false;
	if (node != NULL) {
		if (node->zeroed) {
			zeroed = true;
			*zero = true;
		}
		base_node_dealloc(node);
	}
	if (zeroed == false && *zero) {
		VALGRIND_MAKE_MEM_UNDEFINED(ret, size);
		memset(ret, 0, size);
	}
	return (ret);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movb %r8b, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
andb $0x1, %al
movb %al, -0x29(%rbp)
movq %r9, -0x38(%rbp)
testb $0x1, -0x29(%rbp)
je 0xc039a
movq $0x0, -0x8(%rbp)
jmp 0xc0654
movq -0x20(%rbp), %rax
addq -0x28(%rbp), %rax
subq 0x68e07(%rip), %rax     # 0x1291b0
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0xc03ca
movq $0x0, -0x8(%rbp)
jmp 0xc0654
movq $0x0, -0x60(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq 0x68da4(%rip), %rdi     # 0x129188
callq 0xc0670
movq -0x10(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0xc9880
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xc041d
leaq 0x68d7d(%rip), %rdi     # 0x129188
callq 0xc0690
movq $0x0, -0x8(%rbp)
jmp 0xc0654
movq -0x48(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x28(%rbp), %rcx
subq $0x1, %rcx
addq %rcx, %rax
xorl %ecx, %ecx
subq -0x28(%rbp), %rcx
andq %rcx, %rax
movq -0x48(%rbp), %rcx
movq 0x28(%rcx), %rcx
subq %rcx, %rax
movq %rax, -0x98(%rbp)
jmp 0xc044d
movq -0x48(%rbp), %rax
movq 0x30(%rax), %rax
subq -0x98(%rbp), %rax
subq -0x20(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x48(%rbp), %rax
movq 0x28(%rax), %rax
addq -0x98(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0xc9e30
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0xcbaf0
cmpq $0x0, -0x98(%rbp)
je 0xc04cf
movq -0x98(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0xc99e0
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0xcb690
movq $0x0, -0x48(%rbp)
cmpq $0x0, -0xa0(%rbp)
je 0xc056c
cmpq $0x0, -0x48(%rbp)
jne 0xc052b
leaq 0x68c9d(%rip), %rdi     # 0x129188
callq 0xc0690
callq 0xbfe80
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xc051f
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0xc0950
movq $0x0, -0x8(%rbp)
jmp 0xc0654
leaq 0x68c62(%rip), %rdi     # 0x129188
callq 0xc0670
movq -0x40(%rbp), %rcx
addq -0x20(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0xa0(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0xc99e0
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0xcb690
movq $0x0, -0x48(%rbp)
leaq 0x68c15(%rip), %rdi     # 0x129188
callq 0xc0690
movb $0x0, -0xa1(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0xc05a7
movq -0x48(%rbp), %rax
testb $0x1, 0x38(%rax)
je 0xc059e
movb $0x1, -0xa1(%rbp)
movq -0x38(%rbp), %rax
movb $0x1, (%rax)
movq -0x48(%rbp), %rdi
callq 0xbfef0
movb -0xa1(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xc064c
movq -0x38(%rbp), %rax
testb $0x1, (%rax)
je 0xc064c
movq $0x4d430001, -0xe0(%rbp) # imm = 0x4D430001
movq -0x40(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq $0x0, -0xc8(%rbp)
movq $0x0, -0xc0(%rbp)
movq $0x0, -0xb8(%rbp)
leaq -0xe0(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
movq %rdx, -0xe8(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rdx
xorl %esi, %esi
callq 0x1f110
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)