// File: /workspace/github_c_makefile_star2_O0/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/chunk.c
// Function: chunk_record
static void
chunk_record(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
    extent_tree_t *chunks_szsnad, extent_tree_t *chunks_ad, bool cache,
    void *chunk, size_t size, size_t sn, bool zeroed, bool committed)
{
	bool unzeroed;
	extent_node_t *node, *prev;
	extent_node_t key;

	assert(!cache || !zeroed);
	unzeroed = cache || !zeroed;
	JEMALLOC_VALGRIND_MAKE_MEM_NOACCESS(chunk, size);

	malloc_mutex_lock(tsdn, &arena->chunks_mtx);
	chunk_hooks_assure_initialized_locked(tsdn, arena, chunk_hooks);
	extent_node_init(&key, arena, (void *)((uintptr_t)chunk + size), 0, 0,
	    false, false);
	node = extent_tree_ad_nsearch(chunks_ad, &key);
	/* Try to coalesce forward. */
	if (node != NULL && extent_node_addr_get(node) ==
	    extent_node_addr_get(&key) && extent_node_committed_get(node) ==
	    committed && !chunk_hooks->merge(chunk, size,
	    extent_node_addr_get(node), extent_node_size_get(node), false,
	    arena->ind)) {
		/*
		 * Coalesce chunk with the following address range.  This does
		 * not change the position within chunks_ad, so only
		 * remove/insert from/into chunks_szsnad.
		 */
		extent_tree_szsnad_remove(chunks_szsnad, node);
		arena_chunk_cache_maybe_remove(arena, node, cache);
		extent_node_addr_set(node, chunk);
		extent_node_size_set(node, size + extent_node_size_get(node));
		if (sn < extent_node_sn_get(node))
			extent_node_sn_set(node, sn);
		extent_node_zeroed_set(node, extent_node_zeroed_get(node) &&
		    !unzeroed);
		extent_tree_szsnad_insert(chunks_szsnad, node);
		arena_chunk_cache_maybe_insert(arena, node, cache);
	} else {
		/* Coalescing forward failed, so insert a new node. */
		node = arena_node_alloc(tsdn, arena);
		if (node == NULL) {
			/*
			 * Node allocation failed, which is an exceedingly
			 * unlikely failure.  Leak chunk after making sure its
			 * pages have already been purged, so that this is only
			 * a virtual memory leak.
			 */
			if (cache) {
				chunk_purge_wrapper(tsdn, arena, chunk_hooks,
				    chunk, size, 0, size);
			}
			goto label_return;
		}
		extent_node_init(node, arena, chunk, size, sn, !unzeroed,
		    committed);
		extent_tree_ad_insert(chunks_ad, node);
		extent_tree_szsnad_insert(chunks_szsnad, node);
		arena_chunk_cache_maybe_insert(arena, node, cache);
	}

	/* Try to coalesce backward. */
	prev = extent_tree_ad_prev(chunks_ad, node);
	if (prev != NULL && (void *)((uintptr_t)extent_node_addr_get(prev) +
	    extent_node_size_get(prev)) == chunk &&
	    extent_node_committed_get(prev) == committed &&
	    !chunk_hooks->merge(extent_node_addr_get(prev),
	    extent_node_size_get(prev), chunk, size, false, arena->ind)) {
		/*
		 * Coalesce chunk with the previous address range.  This does
		 * not change the position within chunks_ad, so only
		 * remove/insert node from/into chunks_szsnad.
		 */
		extent_tree_szsnad_remove(chunks_szsnad, prev);
		extent_tree_ad_remove(chunks_ad, prev);
		arena_chunk_cache_maybe_remove(arena, prev, cache);
		extent_tree_szsnad_remove(chunks_szsnad, node);
		arena_chunk_cache_maybe_remove(arena, node, cache);
		extent_node_addr_set(node, extent_node_addr_get(prev));
		extent_node_size_set(node, extent_node_size_get(prev) +
		    extent_node_size_get(node));
		if (extent_node_sn_get(prev) < extent_node_sn_get(node))
			extent_node_sn_set(node, extent_node_sn_get(prev));
		extent_node_zeroed_set(node, extent_node_zeroed_get(prev) &&
		    extent_node_zeroed_get(node));
		extent_tree_szsnad_insert(chunks_szsnad, node);
		arena_chunk_cache_maybe_insert(arena, node, cache);

		arena_node_dalloc(tsdn, arena, prev);
	}

label_return:
	malloc_mutex_unlock(tsdn, &arena->chunks_mtx);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movl %r9d, %eax
movq %rcx, -0xc0(%rbp)
movq %rdx, -0xb8(%rbp)
movq %rsi, %r9
movq -0xc0(%rbp), %rsi
movq %rdi, %r10
movq -0xb8(%rbp), %rdi
movb %al, %dl
movb 0x30(%rbp), %al
movb 0x28(%rbp), %cl
movq 0x20(%rbp), %r11
movq 0x18(%rbp), %r11
movq 0x10(%rbp), %r11
movq %r10, -0x8(%rbp)
movq %r9, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %r8, -0x28(%rbp)
andb $0x1, %dl
movb %dl, -0x29(%rbp)
andb $0x1, %cl
movb %cl, -0x2a(%rbp)
andb $0x1, %al
movb %al, -0x2b(%rbp)
jmp 0x524cb
movb $0x1, %al
testb $0x1, -0x29(%rbp)
movb %al, -0xc1(%rbp)
jne 0x524e4
movb -0x2a(%rbp), %al
xorb $-0x1, %al
movb %al, -0xc1(%rbp)
movb -0xc1(%rbp), %al
andb $0x1, %al
movb %al, -0x2c(%rbp)
leaq 0x51086(%rip), %rax     # 0xa357c
movb (%rax), %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x52516
movq 0x10(%rbp), %rdi
movq 0x18(%rbp), %rsi
callq 0x85f90
jmp 0x52518
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x8a0, %rsi            # imm = 0x8A0
callq 0x511d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x52e90
movq -0x10(%rbp), %rsi
movq 0x10(%rbp), %rdx
addq 0x18(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %r8d
xorl %r9d, %r9d
movq %r8, %rcx
movl $0x0, (%rsp)
callq 0x52ec0
movq -0x28(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x5f290
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x52748
movq -0x38(%rbp), %rdi
callq 0x53000
movq %rax, -0xd0(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x53000
movq %rax, %rcx
movq -0xd0(%rbp), %rax
cmpq %rcx, %rax
jne 0x52748
movq -0x38(%rbp), %rdi
callq 0x53060
andb $0x1, %al
movzbl %al, %eax
movb -0x2b(%rbp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x52748
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0xd8(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq 0x18(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x38(%rbp), %rdi
callq 0x53000
movq %rax, -0xe0(%rbp)
movq -0x38(%rbp), %rdi
callq 0x52fe0
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
movq -0xe0(%rbp), %rdx
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq -0x10(%rbp), %r8
movl (%r8), %r9d
xorl %r8d, %r8d
callq *%rax
testb $0x1, %al
jne 0x52748
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x5dbf0
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movb -0x29(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0x3a3f0
movq -0x38(%rbp), %rdi
movq 0x10(%rbp), %rsi
callq 0x53170
movq -0x38(%rbp), %rax
movq %rax, -0x100(%rbp)
movq 0x18(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x38(%rbp), %rdi
callq 0x52fe0
movq -0x108(%rbp), %rsi
movq -0x100(%rbp), %rdi
addq %rax, %rsi
callq 0x53080
movq 0x20(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x38(%rbp), %rdi
callq 0x53020
movq %rax, %rcx
movq -0xf8(%rbp), %rax
cmpq %rcx, %rax
jae 0x526d9
movq -0x38(%rbp), %rdi
movq 0x20(%rbp), %rsi
callq 0x53190
movq -0x38(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x38(%rbp), %rdi
callq 0x53040
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x109(%rbp)
jne 0x526fe
jmp 0x52709
movb -0x2c(%rbp), %al
xorb $-0x1, %al
movb %al, -0x109(%rbp)
movq -0x118(%rbp), %rdi
movb -0x109(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x531b0
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x5d790
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movb -0x29(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0x3a260
jmp 0x527f6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x3a4e0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x5278f
testb $0x1, -0x29(%rbp)
je 0x5278a
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq 0x10(%rbp), %rcx
movq 0x18(%rbp), %r8
movq 0x18(%rbp), %rax
xorl %r9d, %r9d
movq %rax, (%rsp)
callq 0x52c40
jmp 0x52a30
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq 0x18(%rbp), %rcx
movq 0x20(%rbp), %r8
movb -0x2c(%rbp), %al
xorb $-0x1, %al
movb -0x2b(%rbp), %r9b
movzbl %r9b, %r10d
andl $0x1, %r10d
movq %rsp, %r9
movl %r10d, (%r9)
movzbl %al, %r9d
andl $0x1, %r9d
callq 0x52ec0
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x5f3b0
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x5d790
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movb -0x29(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0x3a260
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x5f140
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x52a2e
movq -0x40(%rbp), %rdi
callq 0x53000
movq %rax, -0x120(%rbp)
movq -0x40(%rbp), %rdi
callq 0x52fe0
movq %rax, %rcx
movq -0x120(%rbp), %rax
addq %rcx, %rax
cmpq 0x10(%rbp), %rax
jne 0x52a2e
movq -0x40(%rbp), %rdi
callq 0x53060
andb $0x1, %al
movzbl %al, %eax
movb -0x2b(%rbp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x52a2e
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x128(%rbp)
movq -0x40(%rbp), %rdi
callq 0x53000
movq %rax, -0x130(%rbp)
movq -0x40(%rbp), %rdi
callq 0x52fe0
movq -0x130(%rbp), %rdi
movq %rax, %rsi
movq -0x128(%rbp), %rax
movq 0x10(%rbp), %rdx
movq 0x18(%rbp), %rcx
movq -0x10(%rbp), %r8
movl (%r8), %r9d
xorl %r8d, %r8d
callq *%rax
testb $0x1, %al
jne 0x52a2e
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x5dbf0
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x5f810
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
movb -0x29(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0x3a3f0
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x5dbf0
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movb -0x29(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0x3a3f0
movq -0x38(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x40(%rbp), %rdi
callq 0x53000
movq -0x150(%rbp), %rdi
movq %rax, %rsi
callq 0x53170
movq -0x38(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x40(%rbp), %rdi
callq 0x52fe0
movq %rax, -0x148(%rbp)
movq -0x38(%rbp), %rdi
callq 0x52fe0
movq -0x148(%rbp), %rsi
movq -0x140(%rbp), %rdi
addq %rax, %rsi
callq 0x53080
movq -0x40(%rbp), %rdi
callq 0x53020
movq %rax, -0x138(%rbp)
movq -0x38(%rbp), %rdi
callq 0x53020
movq %rax, %rcx
movq -0x138(%rbp), %rax
cmpq %rcx, %rax
jae 0x529af
movq -0x38(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x40(%rbp), %rdi
callq 0x53020
movq -0x158(%rbp), %rdi
movq %rax, %rsi
callq 0x53190
movq -0x38(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x40(%rbp), %rdi
callq 0x53040
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x159(%rbp)
jne 0x529d4
jmp 0x529e3
movq -0x38(%rbp), %rdi
callq 0x53040
movb %al, -0x159(%rbp)
movq -0x168(%rbp), %rdi
movb -0x159(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x531b0
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x5d790
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movb -0x29(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0x3a260
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x3a6e0
jmp 0x52a30
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x8a0, %rsi            # imm = 0x8A0
callq 0x51260
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopl (%rax)