// File: /workspace/github_c_makefile_star2_O0/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/chunk.c
// Function: chunk_recycle
static void *
chunk_recycle(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
    extent_tree_t *chunks_szsnad, extent_tree_t *chunks_ad, bool cache,
    void *new_addr, size_t size, size_t alignment, size_t *sn, bool *zero,
    bool *commit, bool dalloc_node)
{
	void *ret;
	extent_node_t *node;
	size_t alloc_size, leadsize, trailsize;
	bool zeroed, committed;

	assert(CHUNK_CEILING(size) == size);
	assert(alignment > 0);
	assert(new_addr == NULL || alignment == chunksize);
	assert(CHUNK_ADDR2BASE(new_addr) == new_addr);
	/*
	 * Cached chunks use the node linkage embedded in their headers, in
	 * which case dalloc_node is true, and new_addr is non-NULL because
	 * we're operating on a specific chunk.
	 */
	assert(dalloc_node || new_addr != NULL);

	alloc_size = size + CHUNK_CEILING(alignment) - chunksize;
	/* Beware size_t wrap-around. */
	if (alloc_size < size)
		return (NULL);
	malloc_mutex_lock(tsdn, &arena->chunks_mtx);
	chunk_hooks_assure_initialized_locked(tsdn, arena, chunk_hooks);
	if (new_addr != NULL) {
		extent_node_t key;
		extent_node_init(&key, arena, new_addr, alloc_size, 0, false,
		    false);
		node = extent_tree_ad_search(chunks_ad, &key);
	} else {
		node = chunk_first_best_fit(arena, chunks_szsnad, alloc_size);
	}
	if (node == NULL || (new_addr != NULL && extent_node_size_get(node) <
	    size)) {
		malloc_mutex_unlock(tsdn, &arena->chunks_mtx);
		return (NULL);
	}
	leadsize = ALIGNMENT_CEILING((uintptr_t)extent_node_addr_get(node),
	    alignment) - (uintptr_t)extent_node_addr_get(node);
	assert(new_addr == NULL || leadsize == 0);
	assert(extent_node_size_get(node) >= leadsize + size);
	trailsize = extent_node_size_get(node) - leadsize - size;
	ret = (void *)((uintptr_t)extent_node_addr_get(node) + leadsize);
	*sn = extent_node_sn_get(node);
	zeroed = extent_node_zeroed_get(node);
	if (zeroed)
		*zero = true;
	committed = extent_node_committed_get(node);
	if (committed)
		*commit = true;
	/* Split the lead. */
	if (leadsize != 0 &&
	    chunk_hooks->split(extent_node_addr_get(node),
	    extent_node_size_get(node), leadsize, size, false, arena->ind)) {
		malloc_mutex_unlock(tsdn, &arena->chunks_mtx);
		return (NULL);
	}
	/* Remove node from the tree. */
	extent_tree_szsnad_remove(chunks_szsnad, node);
	extent_tree_ad_remove(chunks_ad, node);
	arena_chunk_cache_maybe_remove(arena, node, cache);
	if (leadsize != 0) {
		/* Insert the leading space as a smaller chunk. */
		extent_node_size_set(node, leadsize);
		extent_tree_szsnad_insert(chunks_szsnad, node);
		extent_tree_ad_insert(chunks_ad, node);
		arena_chunk_cache_maybe_insert(arena, node, cache);
		node = NULL;
	}
	if (trailsize != 0) {
		/* Split the trail. */
		if (chunk_hooks->split(ret, size + trailsize, size,
		    trailsize, false, arena->ind)) {
			if (dalloc_node && node != NULL)
				arena_node_dalloc(tsdn, arena, node);
			malloc_mutex_unlock(tsdn, &arena->chunks_mtx);
			chunk_record(tsdn, arena, chunk_hooks, chunks_szsnad,
			    chunks_ad, cache, ret, size + trailsize, *sn,
			    zeroed, committed);
			return (NULL);
		}
		/* Insert the trailing space as a smaller chunk. */
		if (node == NULL) {
			node = arena_node_alloc(tsdn, arena);
			if (node == NULL) {
				malloc_mutex_unlock(tsdn, &arena->chunks_mtx);
				chunk_record(tsdn, arena, chunk_hooks,
				    chunks_szsnad, chunks_ad, cache, ret, size
				    + trailsize, *sn, zeroed, committed);
				return (NULL);
			}
		}
		extent_node_init(node, arena, (void *)((uintptr_t)(ret) + size),
		    trailsize, *sn, zeroed, committed);
		extent_tree_szsnad_insert(chunks_szsnad, node);
		extent_tree_ad_insert(chunks_ad, node);
		arena_chunk_cache_maybe_insert(arena, node, cache);
		node = NULL;
	}
	if (!committed && chunk_hooks->commit(ret, size, 0, size, arena->ind)) {
		malloc_mutex_unlock(tsdn, &arena->chunks_mtx);
		chunk_record(tsdn, arena, chunk_hooks, chunks_szsnad, chunks_ad,
		    cache, ret, size, *sn, zeroed, committed);
		return (NULL);
	}
	malloc_mutex_unlock(tsdn, &arena->chunks_mtx);

	assert(dalloc_node || node != NULL);
	if (dalloc_node && node != NULL)
		arena_node_dalloc(tsdn, arena, node);
	if (*zero) {
		if (!zeroed)
			memset(ret, 0, size);
		else if (config_debug) {
			size_t i;
			size_t *p = (size_t *)(uintptr_t)ret;

			for (i = 0; i < size / sizeof(size_t); i++)
				assert(p[i] == 0);
		}
		if (config_valgrind)
			JEMALLOC_VALGRIND_MAKE_MEM_DEFINED(ret, size);
	}
	return (ret);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x130, %rsp            # imm = 0x130
movl %r9d, %eax
movq %rcx, -0x100(%rbp)
movq %rdx, %rcx
movq -0x100(%rbp), %rdx
movq %rcx, -0xf8(%rbp)
movq %rsi, %rcx
movq -0xf8(%rbp), %rsi
movq %rcx, -0xf0(%rbp)
movq %rdi, %r9
movq -0xf0(%rbp), %rdi
movb %al, %cl
movb 0x40(%rbp), %al
movq 0x38(%rbp), %r10
movq 0x30(%rbp), %r10
movq 0x28(%rbp), %r10
movq 0x20(%rbp), %r10
movq 0x18(%rbp), %r10
movq 0x10(%rbp), %r10
movq %r9, -0x20(%rbp)
movq %rdi, -0x28(%rbp)
movq %rsi, -0x30(%rbp)
movq %rdx, -0x38(%rbp)
movq %r8, -0x40(%rbp)
andb $0x1, %cl
movb %cl, -0x41(%rbp)
andb $0x1, %al
movb %al, -0x42(%rbp)
jmp 0x51a82
jmp 0x51a84
jmp 0x51a86
jmp 0x51a88
jmp 0x51a8a
jmp 0x51a8c
jmp 0x51a8e
jmp 0x51a90
jmp 0x51a92
movq 0x18(%rbp), %rax
movq 0x20(%rbp), %rcx
addq 0x5260f(%rip), %rcx     # 0xa40b0
movq 0x52608(%rip), %rdx     # 0xa40b0
xorq $-0x1, %rdx
andq %rdx, %rcx
addq %rcx, %rax
subq 0x525ef(%rip), %rax     # 0xa40a8
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq 0x18(%rbp), %rax
jae 0x51ad4
movq $0x0, -0x18(%rbp)
jmp 0x52074
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0x8a0, %rsi            # imm = 0x8A0
callq 0x511d0
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x52e90
cmpq $0x0, 0x10(%rbp)
je 0x51b3d
movq -0x28(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq -0x60(%rbp), %rcx
leaq -0xe8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %r8d
xorl %r9d, %r9d
movl $0x0, (%rsp)
callq 0x52ec0
movq -0x40(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x5f210
movq %rax, -0x58(%rbp)
jmp 0x51b52
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x60(%rbp), %rdx
callq 0x52f80
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x51b6f
cmpq $0x0, 0x10(%rbp)
je 0x51b90
movq -0x58(%rbp), %rdi
callq 0x52fe0
cmpq 0x18(%rbp), %rax
jae 0x51b90
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0x8a0, %rsi            # imm = 0x8A0
callq 0x51260
movq $0x0, -0x18(%rbp)
jmp 0x52074
movq -0x58(%rbp), %rdi
callq 0x53000
movq 0x20(%rbp), %rcx
subq $0x1, %rcx
addq %rcx, %rax
movq 0x20(%rbp), %rcx
xorq $-0x1, %rcx
addq $0x1, %rcx
andq %rcx, %rax
movq %rax, -0x108(%rbp)
movq -0x58(%rbp), %rdi
callq 0x53000
movq %rax, %rcx
movq -0x108(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x68(%rbp)
jmp 0x51bd6
jmp 0x51bd8
jmp 0x51bda
movq -0x58(%rbp), %rdi
callq 0x52fe0
subq -0x68(%rbp), %rax
subq 0x18(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x58(%rbp), %rdi
callq 0x53000
addq -0x68(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rdi
callq 0x53020
movq %rax, %rcx
movq 0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rdi
callq 0x53040
andb $0x1, %al
movb %al, -0x71(%rbp)
testb $0x1, -0x71(%rbp)
je 0x51c2e
movq 0x30(%rbp), %rax
movb $0x1, (%rax)
movq -0x58(%rbp), %rdi
callq 0x53060
andb $0x1, %al
movb %al, -0x72(%rbp)
testb $0x1, -0x72(%rbp)
je 0x51c49
movq 0x38(%rbp), %rax
movb $0x1, (%rax)
cmpq $0x0, -0x68(%rbp)
je 0x51cc4
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x110(%rbp)
movq -0x58(%rbp), %rdi
callq 0x53000
movq %rax, -0x118(%rbp)
movq -0x58(%rbp), %rdi
callq 0x52fe0
movq -0x118(%rbp), %rdi
movq %rax, %rsi
movq -0x110(%rbp), %rax
movq -0x68(%rbp), %rdx
movq 0x18(%rbp), %rcx
movq -0x28(%rbp), %r8
movl (%r8), %r9d
xorl %r8d, %r8d
callq *%rax
testb $0x1, %al
jne 0x51ca3
jmp 0x51cc4
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0x8a0, %rsi            # imm = 0x8A0
callq 0x51260
movq $0x0, -0x18(%rbp)
jmp 0x52074
movq -0x38(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x5dbf0
movq -0x40(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x5f810
movq -0x28(%rbp), %rdi
movq -0x58(%rbp), %rsi
movb -0x41(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0x3a3f0
cmpq $0x0, -0x68(%rbp)
je 0x51d3e
movq -0x58(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x53080
movq -0x38(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x5d790
movq -0x40(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x5f3b0
movq -0x28(%rbp), %rdi
movq -0x58(%rbp), %rsi
movb -0x41(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0x3a260
movq $0x0, -0x58(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x51f37
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x50(%rbp), %rdi
movq 0x18(%rbp), %rsi
addq -0x70(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq -0x70(%rbp), %rcx
movq -0x28(%rbp), %r8
movl (%r8), %r9d
xorl %r8d, %r8d
callq *%rax
testb $0x1, %al
jne 0x51d7a
jmp 0x51e1c
testb $0x1, -0x42(%rbp)
je 0x51d98
cmpq $0x0, -0x58(%rbp)
je 0x51d98
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0x3a6e0
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0x8a0, %rsi            # imm = 0x8A0
callq 0x51260
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
movb -0x41(%rbp), %r9b
movq -0x50(%rbp), %r14
movq 0x18(%rbp), %rbx
addq -0x70(%rbp), %rbx
movq 0x28(%rbp), %rax
movq (%rax), %r11
movb -0x71(%rbp), %r10b
movb -0x72(%rbp), %al
andb $0x1, %r9b
andb $0x1, %r10b
andb $0x1, %al
movzbl %r9b, %r9d
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movzbl %r10b, %r10d
movl %r10d, 0x18(%rsp)
movzbl %al, %eax
movl %eax, 0x20(%rsp)
callq 0x52460
movq $0x0, -0x18(%rbp)
jmp 0x52074
cmpq $0x0, -0x58(%rbp)
jne 0x51ec9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x3a4e0
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x51ec7
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0x8a0, %rsi            # imm = 0x8A0
callq 0x51260
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
movb -0x41(%rbp), %r9b
movq -0x50(%rbp), %r14
movq 0x18(%rbp), %rbx
addq -0x70(%rbp), %rbx
movq 0x28(%rbp), %rax
movq (%rax), %r11
movb -0x71(%rbp), %r10b
movb -0x72(%rbp), %al
andb $0x1, %r9b
andb $0x1, %r10b
andb $0x1, %al
movzbl %r9b, %r9d
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movzbl %r10b, %r10d
movl %r10d, 0x18(%rsp)
movzbl %al, %eax
movl %eax, 0x20(%rsp)
callq 0x52460
movq $0x0, -0x18(%rbp)
jmp 0x52074
jmp 0x51ec9
movq -0x58(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq 0x18(%rbp), %rdx
movq -0x70(%rbp), %rcx
movq 0x28(%rbp), %rax
movq (%rax), %r8
movb -0x71(%rbp), %r9b
movb -0x72(%rbp), %al
andb $0x1, %r9b
andb $0x1, %al
movzbl %r9b, %r9d
movzbl %al, %eax
movl %eax, (%rsp)
callq 0x52ec0
movq -0x38(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x5d790
movq -0x40(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x5f3b0
movq -0x28(%rbp), %rdi
movq -0x58(%rbp), %rsi
movb -0x41(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0x3a260
movq $0x0, -0x58(%rbp)
testb $0x1, -0x72(%rbp)
jne 0x51fe9
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x50(%rbp), %rdi
movq 0x18(%rbp), %rsi
movq 0x18(%rbp), %rcx
movq -0x28(%rbp), %rdx
movl (%rdx), %r8d
xorl %edx, %edx
callq *%rax
testb $0x1, %al
jne 0x51f69
jmp 0x51fe9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0x8a0, %rsi            # imm = 0x8A0
callq 0x51260
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
movb -0x41(%rbp), %r9b
movq -0x50(%rbp), %r14
movq 0x18(%rbp), %rbx
movq 0x28(%rbp), %rax
movq (%rax), %r11
movb -0x71(%rbp), %r10b
movb -0x72(%rbp), %al
andb $0x1, %r9b
andb $0x1, %r10b
andb $0x1, %al
movzbl %r9b, %r9d
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movzbl %r10b, %r10d
movl %r10d, 0x18(%rsp)
movzbl %al, %eax
movl %eax, 0x20(%rsp)
callq 0x52460
movq $0x0, -0x18(%rbp)
jmp 0x52074
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0x8a0, %rsi            # imm = 0x8A0
callq 0x51260
jmp 0x51fff
testb $0x1, -0x42(%rbp)
je 0x5201d
cmpq $0x0, -0x58(%rbp)
je 0x5201d
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0x3a6e0
movq 0x30(%rbp), %rax
testb $0x1, (%rax)
je 0x5206c
testb $0x1, -0x71(%rbp)
jne 0x5203d
movq -0x50(%rbp), %rdi
movq 0x18(%rbp), %rdx
xorl %esi, %esi
callq 0xb210
jmp 0x5203f
jmp 0x5203f
jmp 0x52041
leaq 0x51534(%rip), %rax     # 0xa357c
movb (%rax), %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x52068
movq -0x50(%rbp), %rdi
movq 0x18(%rbp), %rsi
callq 0x86070
jmp 0x5206a
jmp 0x5206c
movq -0x50(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbx
popq %r14
popq %rbp
retq
nopw %cs:(%rax,%rax)