// File: /workspace/github_c_makefile_star2_O1/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 0x83135
movq $0x0, 0xe0(%rbx)
jmp 0x83247
leaq 0x7(%rsp), %r14
movb $0x0, (%r14)
leaq 0x8(%rbx), %r15
movq %r15, %rdi
callq 0x1fbb0
leaq 0x5c70f(%rip), %r12     # 0xdf860
movq (%r12), %rdi
movl 0x88(%rbx), %r8d
movq %rdi, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0x85410
movq %rax, %r14
movq %r15, %rdi
callq 0x1faa0
testq %r14, %r14
je 0x8327e
movq (%r12), %rax
addq %rax, 0x30(%rbx)
movq %rbx, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%r14)
movq $0x0, 0x28(%r14)
movzbl 0x7(%rsp), %edi
movl %edi, %eax
xorl $0x1, %eax
shll $0x2, %eax
leaq 0x5c77c(%rip), %rsi     # 0xdf928
movq (%rsi), %r9
leaq 0x5c77a(%rip), %rdx     # 0xdf930
leaq 0x30(%r14), %rcx
movq (%rdx), %r8
orq %rax, %r8
orq $0xff0, %r8             # imm = 0xFF0
movq %r8, 0x40(%r14)
testl %edi, %edi
jne 0x83225
leaq 0x1(%r9), %rdi
leaq 0x5c6ae(%rip), %r8      # 0xdf888
movq (%r8), %r10
decq %r10
cmpq %r10, %rdi
jae 0x83225
leaq (%r9,%r9,2), %r9
leaq (%r14,%r9,8), %r9
addq $0x58, %r9
movq (%rsi), %r10
shlq $0x3, %r10
leaq (%r10,%r10,2), %r10
movq %r9, %r11
subq %r10, %r11
negq %r10
movq (%r11), %r11
andq $-0x5, %r11
orq %rax, %r11
movq %r11, (%r9,%r10)
incq %rdi
movq (%r8), %r10
decq %r10
addq $0x18, %r9
cmpq %r10, %rdi
jb 0x831f1
leaq 0x5c65c(%rip), %rdi     # 0xdf888
movq (%rsi), %rsi
notq %rsi
addq (%rdi), %rsi
leaq (%rsi,%rsi,2), %rsi
orq (%rdx), %rax
orq $0xff0, %rax            # imm = 0xFF0
movq %rax, 0x10(%rcx,%rsi,8)
leaq 0x5c6da(%rip), %rax     # 0xdf928
movq (%rax), %rdx
leaq 0x5c630(%rip), %rax     # 0xdf888
movq (%rax), %rcx
subq %rdx, %rcx
movq %rbx, %rdi
movq %r14, %rsi
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x8366d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
xorl %r14d, %r14d
jmp 0x8326f