// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/deps/jemalloc/src/arena.c
// Function: arena_chunk_alloc
static arena_chunk_t *
arena_chunk_alloc(arena_t *arena)
{
	arena_chunk_t *chunk;
	size_t i;

	if (arena->spare != NULL) {
		chunk = arena->spare;
		arena->spare = NULL;

		assert(arena_mapbits_allocated_get(chunk, map_bias) == 0);
		assert(arena_mapbits_allocated_get(chunk, chunk_npages-1) == 0);
		assert(arena_mapbits_unallocated_size_get(chunk, map_bias) ==
		    arena_maxclass);
		assert(arena_mapbits_unallocated_size_get(chunk,
		    chunk_npages-1) == arena_maxclass);
		assert(arena_mapbits_dirty_get(chunk, map_bias) ==
		    arena_mapbits_dirty_get(chunk, chunk_npages-1));
	} else {
		bool zero;
		size_t unzeroed;

		zero = false;
		malloc_mutex_unlock(&arena->lock);
		chunk = (arena_chunk_t *)chunk_alloc(chunksize, chunksize,
		    false, &zero, arena->dss_prec);
		malloc_mutex_lock(&arena->lock);
		if (chunk == NULL)
			return (NULL);
		if (config_stats)
			arena->stats.mapped += chunksize;

		chunk->arena = arena;

		/*
		 * Claim that no pages are in use, since the header is merely
		 * overhead.
		 */
		chunk->ndirty = 0;

		chunk->nruns_avail = 0;
		chunk->nruns_adjac = 0;

		/*
		 * Initialize the map to contain one maximal free untouched run.
		 * Mark the pages as zeroed iff chunk_alloc() returned a zeroed
		 * chunk.
		 */
		unzeroed = zero ? 0 : CHUNK_MAP_UNZEROED;
		arena_mapbits_unallocated_set(chunk, map_bias, arena_maxclass,
		    unzeroed);
		/*
		 * There is no need to initialize the internal page map entries
		 * unless the chunk is not zeroed.
		 */
		if (zero == false) {
			for (i = map_bias+1; i < chunk_npages-1; i++)
				arena_mapbits_unzeroed_set(chunk, i, unzeroed);
		} else if (config_debug) {
			for (i = map_bias+1; i < chunk_npages-1; i++) {
				assert(arena_mapbits_unzeroed_get(chunk, i) ==
				    unzeroed);
			}
		}
		arena_mapbits_unallocated_set(chunk, chunk_npages-1,
		    arena_maxclass, unzeroed);
	}

	/* Insert the run into the runs_avail tree. */
	arena_avail_insert(arena, chunk, map_bias, chunk_npages-map_bias,
	    false, false);

	return (chunk);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0xe0(%rdi), %r14
testq %r14, %r14
je 0x834c4
movq $0x0, 0xe0(%rbx)
jmp 0x835d8
leaq 0x7(%rsp), %r14
movb $0x0, (%r14)
leaq 0x8(%rbx), %r15
movq %r15, %rdi
callq 0x1fbb0
leaq 0x5c380(%rip), %r12     # 0xdf860
movq (%r12), %rdi
movl 0x88(%rbx), %r8d
movq %rdi, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0x85730
movq %rax, %r14
movq %r15, %rdi
callq 0x1faa0
testq %r14, %r14
je 0x8360f
movq (%r12), %rax
addq %rax, 0x30(%rbx)
movq %rbx, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%r14)
movq $0x0, 0x28(%r14)
movzbl 0x7(%rsp), %r10d
movl %r10d, %ecx
xorl $0x1, %ecx
shll $0x2, %ecx
leaq 0x5c3eb(%rip), %rdx     # 0xdf928
movq (%rdx), %rdi
leaq 0x5c3e9(%rip), %rsi     # 0xdf930
leaq 0x30(%r14), %rax
movq (%rsi), %r11
orq %rcx, %r11
orq $0xff0, %r11            # imm = 0xFF0
movq %r11, 0x40(%r14)
leaq 0x5c325(%rip), %r9      # 0xdf888
movq (%r9), %r8
testl %r10d, %r10d
jne 0x835c9
leaq 0x1(%rdi), %r10
leaq -0x1(%r8), %r15
cmpq %r15, %r10
jae 0x835c9
leaq (%rdi,%rdi,2), %rdi
leaq (%r14,%rdi,8), %rdi
addq $0x58, %rdi
movq (%rdx), %r8
shlq $0x3, %r8
leaq (%r8,%r8,2), %r8
movq %rdi, %r11
subq %r8, %r11
negq %r8
movq (%r11), %r11
andq $-0x5, %r11
orq %rcx, %r11
movq %r11, (%rdi,%r8)
incq %r10
movq (%r9), %r8
leaq -0x1(%r8), %r11
addq $0x18, %rdi
cmpq %r11, %r10
jb 0x83584
movq (%rdx), %rdi
orq (%rsi), %rcx
orq $0xff0, %rcx            # imm = 0xFF0
movq %rcx, %r11
notq %rdi
addq %r8, %rdi
leaq (%rdi,%rdi,2), %rcx
movq %r11, 0x10(%rax,%rcx,8)
leaq 0x5c349(%rip), %rax     # 0xdf928
movq (%rax), %rdx
leaq 0x5c29f(%rip), %rax     # 0xdf888
movq (%rax), %rcx
subq %rdx, %rcx
movq %rbx, %rdi
movq %r14, %rsi
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x83a12
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
xorl %r14d, %r14d
jmp 0x83600