// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/deps/jemalloc/src/chunk.c
// Function: chunk_record
static void
chunk_record(arena_t *arena, chunk_hooks_t *chunk_hooks,
    extent_tree_t *chunks_szad, extent_tree_t *chunks_ad, bool cache,
    void *chunk, size_t size, 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(&arena->chunks_mtx);
	chunk_hooks_assure_initialized_locked(arena, chunk_hooks);
	extent_node_init(&key, arena, (void *)((uintptr_t)chunk + size), 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_szad.
		 */
		extent_tree_szad_remove(chunks_szad, 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));
		extent_node_zeroed_set(node, extent_node_zeroed_get(node) &&
		    !unzeroed);
		extent_tree_szad_insert(chunks_szad, node);
		arena_chunk_cache_maybe_insert(arena, node, cache);
	} else {
		/* Coalescing forward failed, so insert a new node. */
		node = arena_node_alloc(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(arena, chunk_hooks, chunk,
				    size, 0, size);
			}
			goto label_return;
		}
		extent_node_init(node, arena, chunk, size, !unzeroed,
		    committed);
		extent_tree_ad_insert(chunks_ad, node);
		extent_tree_szad_insert(chunks_szad, 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_szad.
		 */
		extent_tree_szad_remove(chunks_szad, prev);
		extent_tree_ad_remove(chunks_ad, prev);
		arena_chunk_cache_maybe_remove(arena, prev, cache);
		extent_tree_szad_remove(chunks_szad, 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));
		extent_node_zeroed_set(node, extent_node_zeroed_get(prev) &&
		    extent_node_zeroed_get(node));
		extent_tree_szad_insert(chunks_szad, node);
		arena_chunk_cache_maybe_insert(arena, node, cache);

		arena_node_dalloc(arena, prev);
	}

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, %r15
movl %r8d, %ebx
movq %rcx, %r13
movq %rdx, 0x8(%rsp)
movq %rsi, %r12
movq %rdi, %r14
movb 0xc8(%rsp), %bpl
leaq 0x2ba2a(%rip), %rax     # 0x5a684
cmpb $0x1, (%rax)
je 0x2ef2f
xorb $0x1, %bpl
leaq 0x3c0(%r14), %rdi
movq %rdi, 0x18(%rsp)
callq 0x106d0
leaq 0x19821(%rip), %rsi     # 0x484a0
movl $0x38, %edx
movq %r12, %rdi
callq 0x104a0
testl %eax, %eax
jne 0x2ecc5
movups 0x418(%r14), %xmm0
movups 0x428(%r14), %xmm1
movups 0x438(%r14), %xmm2
movq 0x448(%r14), %rax
movq %rax, 0x30(%r12)
movups %xmm2, 0x20(%r12)
movups %xmm1, 0x10(%r12)
movups %xmm0, (%r12)
movl %ebx, 0x4(%rsp)
orb %bl, %bpl
movq 0xc0(%rsp), %rax
addq %r15, %rax
leaq 0x20(%rsp), %rsi
movq %r14, (%rsi)
movq %rax, 0x8(%rsi)
movq $0x0, 0x10(%rsi)
movl $0x0, 0x17(%rsi)
movq %r13, %rdi
callq 0x3573f
testq %rax, %rax
je 0x2ed3b
movq %rax, %rbx
movq 0x8(%rax), %rdx
cmpq 0x28(%rsp), %rdx
jne 0x2ed3b
movb 0xd0(%rsp), %al
cmpb %al, 0x19(%rbx)
jne 0x2ed3b
movq 0x10(%rbx), %rcx
movl (%r14), %r9d
movq %r15, %rdi
movq 0xc0(%rsp), %rsi
xorl %r8d, %r8d
callq *0x30(%r12)
testb %al, %al
je 0x2eeaa
movq %r14, %rdi
callq 0x270cc
testq %rax, %rax
je 0x2ee64
movq %rax, %rbx
xorb $0x1, %bpl
movq %r14, (%rax)
movq %r15, 0x8(%rax)
movq 0xc0(%rsp), %rax
movq %rax, 0x10(%rbx)
movb %bpl, 0x18(%rbx)
movb 0xd0(%rsp), %al
movb %al, 0x19(%rbx)
movb $0x0, 0x1a(%rbx)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x357dd
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x3491e
movzbl 0x4(%rsp), %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x27024
movq %r13, %rdi
movq %rbx, %rsi
callq 0x356b1
testq %rax, %rax
je 0x2ee8e
movq %rax, %rbp
movq 0x8(%rax), %rdi
movq 0x10(%rax), %rsi
leaq (%rsi,%rdi), %rax
cmpq %r15, %rax
jne 0x2ee8e
movb 0xd0(%rsp), %al
cmpb %al, 0x19(%rbp)
jne 0x2ee8e
movl (%r14), %r9d
movq %r15, %rdx
movq 0xc0(%rsp), %rcx
xorl %r8d, %r8d
callq *0x30(%r12)
testb %al, %al
jne 0x2ee8e
movq 0x8(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
callq 0x34b6e
movq %r13, %rdi
movq %rbp, %rsi
callq 0x35949
movzbl 0x4(%rsp), %r15d
movq %r14, %rdi
movq %rbp, %rsi
movl %r15d, %edx
callq 0x27085
movq %r12, %rdi
movq %rbx, %rsi
callq 0x34b6e
movq %r14, %rdi
movq %rbx, %rsi
movl %r15d, %edx
callq 0x27085
movq 0x8(%rbp), %rax
movq %rax, 0x8(%rbx)
movq 0x10(%rbp), %rax
addq %rax, 0x10(%rbx)
cmpb $0x1, 0x18(%rbp)
jne 0x2eeff
movb 0x18(%rbx), %al
jmp 0x2ef01
cmpb $0x0, 0x4(%rsp)
je 0x2ee8e
movq %r14, %rdi
movq %r12, %rsi
callq 0x2eb4e
movl (%r14), %r8d
movq %r15, %rdi
movq 0xc0(%rsp), %rcx
movq %rcx, %rsi
xorl %edx, %edx
callq *0x20(%r12)
movq 0x18(%rsp), %rdi
callq 0x10440
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x34b6e
movzbl 0x4(%rsp), %edx
movl %edx, 0x14(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x27085
movq %r15, 0x8(%rbx)
movq 0xc0(%rsp), %rax
addq %rax, 0x10(%rbx)
xorb $0x1, %bpl
andb %bpl, 0x18(%rbx)
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x3491e
movq %r14, %rdi
movq %rbx, %rsi
movl 0x14(%rsp), %edx
jmp 0x2ed9b
xorl %eax, %eax
movb %al, 0x18(%rbx)
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x3491e
movq %r14, %rdi
movq %rbx, %rsi
movl %r15d, %edx
callq 0x27024
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2715e
jmp 0x2ee8e
movq %r15, %rdi
movq 0xc0(%rsp), %rsi
callq 0x3e764
jmp 0x2ec63