// File: /workspace/github_c_makefile_star2_O2/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 0x7a863
andq $0x0, 0xe0(%rbx)
jmp 0x7a969
leaq 0x7(%rsp), %r14
movb $0x0, (%r14)
leaq 0x8(%rbx), %r15
movq %r15, %rdi
callq 0x1fbb0
leaq 0x61fe1(%rip), %r12     # 0xdc860
movq (%r12), %rdi
movl 0x88(%rbx), %r8d
movq %rdi, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0x7c988
movq %rax, %r14
movq %r15, %rdi
callq 0x1faa0
testq %r14, %r14
je 0x7a905
movq (%r12), %rax
addq %rax, 0x30(%rbx)
movq %rbx, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%r14)
andq $0x0, 0x28(%r14)
movzbl 0x7(%rsp), %r9d
movl %r9d, %edx
xorl $0x1, %edx
shll $0x2, %edx
leaq 0x62053(%rip), %rsi     # 0xdc928
movq (%rsi), %rcx
leaq 0x62051(%rip), %rdi     # 0xdc930
leaq 0x30(%r14), %rax
movq (%rdi), %r8
orq %rdx, %r8
orq $0xff0, %r8             # imm = 0xFF0
movq %r8, 0x40(%r14)
testl %r9d, %r9d
je 0x7a90d
leaq 0x61f88(%rip), %rdx     # 0xdc888
movq (%rdx), %r10
jmp 0x7a95a
xorl %r14d, %r14d
jmp 0x7a991
imulq $0x18, %rcx, %r8
addq %r14, %r8
addq $0x58, %r8
incq %rcx
leaq 0x61f66(%rip), %r9      # 0xdc888
movq (%r9), %r10
leaq -0x1(%r10), %r11
cmpq %r11, %rcx
jae 0x7a94a
imulq $-0x18, (%rsi), %r10
movq (%r8,%r10), %r11
andq $-0x5, %r11
orq %rdx, %r11
movq %r11, (%r8,%r10)
addq $0x18, %r8
incq %rcx
jmp 0x7a922
movq (%rsi), %rcx
orq (%rdi), %rdx
orq $0xff0, %rdx            # imm = 0xFF0
movq %rdx, %r8
notq %rcx
addq %r10, %rcx
imulq $0x18, %rcx, %rcx
movq %r8, 0x10(%rax,%rcx)
leaq 0x61fb8(%rip), %rax     # 0xdc928
movq (%rax), %rdx
leaq 0x61f0e(%rip), %rax     # 0xdc888
movq (%rax), %rcx
subq %rdx, %rcx
movq %rbx, %rdi
movq %r14, %rsi
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x7ad71
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq