// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/deps/jemalloc/src/chunk.c
// Function: chunk_alloc
void *
chunk_alloc(size_t size, size_t alignment, bool base, bool *zero,
    dss_prec_t dss_prec)
{
	void *ret;

	assert(size != 0);
	assert((size & chunksize_mask) == 0);
	assert(alignment != 0);
	assert((alignment & chunksize_mask) == 0);

	/* "primary" dss. */
	if (config_dss && dss_prec == dss_prec_primary) {
		if ((ret = chunk_recycle(&chunks_szad_dss, &chunks_ad_dss, size,
		    alignment, base, zero)) != NULL)
			goto label_return;
		if ((ret = chunk_alloc_dss(size, alignment, zero)) != NULL)
			goto label_return;
	}
	/* mmap. */
	if ((ret = chunk_recycle(&chunks_szad_mmap, &chunks_ad_mmap, size,
	    alignment, base, zero)) != NULL)
		goto label_return;
	if ((ret = chunk_alloc_mmap(size, alignment, zero)) != NULL)
		goto label_return;
	/* "secondary" dss. */
	if (config_dss && dss_prec == dss_prec_secondary) {
		if ((ret = chunk_recycle(&chunks_szad_dss, &chunks_ad_dss, size,
		    alignment, base, zero)) != NULL)
			goto label_return;
		if ((ret = chunk_alloc_dss(size, alignment, zero)) != NULL)
			goto label_return;
	}

	/* All strategies for allocation failed. */
	ret = NULL;
label_return:
	if (config_ivsalloc && base == false && ret != NULL) {
		if (rtree_set(chunks_rtree, (uintptr_t)ret, ret)) {
			chunk_dealloc(ret, size, true);
			return (NULL);
		}
	}
	if ((config_stats || config_prof) && ret != NULL) {
		bool gdump;
		malloc_mutex_lock(&chunks_mtx);
		if (config_stats)
			stats_chunks.nchunks += (size / chunksize);
		stats_chunks.curchunks += (size / chunksize);
		if (stats_chunks.curchunks > stats_chunks.highchunks) {
			stats_chunks.highchunks = stats_chunks.curchunks;
			if (config_prof)
				gdump = true;
		} else if (config_prof)
			gdump = false;
		malloc_mutex_unlock(&chunks_mtx);
		if (config_prof && opt_prof && opt_prof_gdump && gdump)
			prof_gdump();
	}
	if (config_debug && *zero && ret != NULL) {
		size_t i;
		size_t *p = (size_t *)(uintptr_t)ret;

		VALGRIND_MAKE_MEM_DEFINED(ret, size);
		for (i = 0; i < size / sizeof(size_t); i++)
			assert(p[i] == 0);
	}
	assert(CHUNK_ADDR2BASE(ret) == ret);
	return (ret);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
jmp 0xc0271
jmp 0xc0273
jmp 0xc0275
jmp 0xc0277
jmp 0xc0279
jmp 0xc027b
jmp 0xc027d
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rcx
movb -0x11(%rbp), %al
movq -0x20(%rbp), %r9
leaq 0x68e65(%rip), %rdi     # 0x1290f8
leaq 0x68ea6(%rip), %rsi     # 0x129140
andb $0x1, %al
movzbl %al, %r8d
callq 0xc0360
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0xc02b1
jmp 0xc02d6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xc0ec0
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0xc02ce
jmp 0xc02d6
movq $0x0, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xc0351
leaq 0x68ea4(%rip), %rdi     # 0x129188
callq 0xc0670
movq -0x8(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq 0x68eb8(%rip)           # 0x1291b0
addq 0x68eb9(%rip), %rax     # 0x1291b8
movq %rax, 0x68eb2(%rip)     # 0x1291b8
movq -0x8(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq 0x68e9b(%rip)           # 0x1291b0
addq 0x68eac(%rip), %rax     # 0x1291c8
movq %rax, 0x68ea5(%rip)     # 0x1291c8
movq 0x68e9e(%rip), %rax     # 0x1291c8
cmpq 0x68e8f(%rip), %rax     # 0x1291c0
jbe 0xc0343
movq 0x68e8e(%rip), %rax     # 0x1291c8
movq %rax, 0x68e7f(%rip)     # 0x1291c0
jmp 0xc0345
jmp 0xc0345
leaq 0x68e3c(%rip), %rdi     # 0x129188
callq 0xc0690
jmp 0xc0353
jmp 0xc0355
movq -0x30(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nop