// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rcx, %r14
movq %rsi, %r15
movq %rdi, %rbx
testl %edx, %edx
jne 0x7cb8b
leaq (%r15,%rbx), %rax
subq 0x5feab(%rip), %rax     # 0xdc860
cmpq %rbx, %rax
jb 0x7cb8b
leaq 0x58(%rsp), %r12
andq $0x0, 0x28(%r12)
movq %rax, 0x30(%r12)
leaq 0x5fe63(%rip), %rdi     # 0xdc838
callq 0x1faa0
leaq 0x5fdc7(%rip), %rdi     # 0xdc7a8
movq %r12, %rsi
callq 0x8127c
testq %rax, %rax
je 0x7ca56
movq %rax, %r13
movq 0x28(%rax), %rbp
movq 0x30(%rax), %rax
movq %rax, 0x10(%rsp)
leaq (%r15,%rbp), %rax
decq %rax
movq %r15, %r12
negq %r12
andq %rax, %r12
movq %r12, %rax
subq %rbp, %rax
addq %rbx, %rax
movq %rax, 0x8(%rsp)
leaq 0x5fd85(%rip), %rdi     # 0xdc7a8
movq %r13, %rsi
callq 0x81491
leaq 0x5fdbe(%rip), %rdi     # 0xdc7f0
movq %r13, %rsi
callq 0x81e79
movq %r12, %rax
subq %rbp, %rax
jne 0x7ca67
movq 0x10(%rsp), %rbp
movq 0x8(%rsp), %rax
cmpq %rax, %rbp
jne 0x7cac6
jmp 0x7caf6
leaq 0x5fddb(%rip), %rdi     # 0xdc838
callq 0x1fbb0
jmp 0x7cb8b
movq %rax, 0x30(%r13)
leaq 0x5fd36(%rip), %rdi     # 0xdc7a8
movq %r13, %rsi
callq 0x8132c
leaq 0x5fd6f(%rip), %rdi     # 0xdc7f0
movq %r13, %rsi
callq 0x81d1f
movq 0x10(%rsp), %rbp
movq 0x8(%rsp), %rax
cmpq %rax, %rbp
je 0x7caf3
leaq 0x5fd99(%rip), %rdi     # 0xdc838
callq 0x1fbb0
callq 0x7c7e6
testq %rax, %rax
je 0x7cb7d
movq %rax, %r13
leaq 0x5fd7c(%rip), %rdi     # 0xdc838
callq 0x1faa0
movq 0x8(%rsp), %rax
subq %rax, %rbp
leaq (%r12,%rbx), %rax
movq %rax, 0x28(%r13)
movq %rbp, 0x30(%r13)
leaq 0x5fccc(%rip), %rdi     # 0xdc7a8
movq %r13, %rsi
callq 0x8132c
leaq 0x5fd05(%rip), %rdi     # 0xdc7f0
movq %r13, %rsi
callq 0x81d1f
xorl %r13d, %r13d
leaq 0x5fd3b(%rip), %rdi     # 0xdc838
callq 0x1fbb0
testq %r13, %r13
je 0x7cb22
movb 0x38(%r13), %bpl
cmpb $0x1, %bpl
jne 0x7cb15
movb $0x1, (%r14)
movq %r13, %rdi
callq 0x7c82f
testb %bpl, %bpl
jne 0x7cb76
cmpb $0x1, (%r14)
jne 0x7cb76
leaq 0x20(%rsp), %rax
movq $0x4d430001, (%rax)     # imm = 0x4D430001
movq %r12, 0x8(%rax)
movq %rbx, 0x10(%rax)
xorl %ecx, %ecx
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq %rcx, 0x28(%rax)
xorl %edx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
movq %rdx, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq %r12, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x1f110
testq %r12, %r12
jne 0x7cba1
jmp 0x7cb8b
pushq $0x1
popq %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x7cd8d
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x7d094
movq %rax, %r12
testq %rax, %rax
je 0x7cbec
leaq 0x5fc90(%rip), %rdi     # 0xdc838
callq 0x1faa0
movq %rbx, %rax
xorl %edx, %edx
divq 0x5fca7(%rip)           # 0xdc860
addq %rax, 0x5fca8(%rip)     # 0xdc868
addq 0x5fcb1(%rip), %rax     # 0xdc878
movq %rax, 0x5fcaa(%rip)     # 0xdc878
cmpq 0x5fc9b(%rip), %rax     # 0xdc870
jbe 0x7cbde
movq %rax, 0x5fc92(%rip)     # 0xdc870
leaq 0x5fc53(%rip), %rdi     # 0xdc838
callq 0x1fbb0
jmp 0x7cbef
xorl %r12d, %r12d
movq %r12, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq