// File: /workspace/github_c_makefile_star2_O1/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 0x855f6
leaq (%r15,%rbx), %rax
subq 0x5a423(%rip), %rax     # 0xdf860
cmpq %rbx, %rax
jb 0x855f6
leaq 0x58(%rsp), %r12
movq $0x0, 0x28(%r12)
movq %rax, 0x30(%r12)
leaq 0x5a3d8(%rip), %rdi     # 0xdf838
callq 0x1faa0
leaq 0x5a33c(%rip), %rdi     # 0xdf7a8
movq %r12, %rsi
callq 0x8a273
testq %rax, %rax
je 0x855ea
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 0x5a2f6(%rip), %rdi     # 0xdf7a8
movq %r13, %rsi
callq 0x8a4bf
leaq 0x5a32f(%rip), %rdi     # 0xdf7f0
movq %r13, %rsi
callq 0x8af83
movq %r12, %rax
subq %rbp, %rax
je 0x854f6
movq %rax, 0x30(%r13)
leaq 0x5a2cc(%rip), %rdi     # 0xdf7a8
movq %r13, %rsi
callq 0x8a344
leaq 0x5a305(%rip), %rdi     # 0xdf7f0
movq %r13, %rsi
callq 0x8ae18
xorl %r13d, %r13d
movq 0x10(%rsp), %rbp
movq 0x8(%rsp), %rax
cmpq %rax, %rbp
je 0x85568
testq %r13, %r13
jne 0x85538
leaq 0x5a327(%rip), %rdi     # 0xdf838
callq 0x1fbb0
callq 0x8523f
testq %rax, %rax
je 0x85672
movq %rax, %r13
leaq 0x5a30a(%rip), %rdi     # 0xdf838
callq 0x1faa0
movq 0x8(%rsp), %rax
subq %rax, %rbp
leaq (%r12,%rbx), %rax
movq %rax, 0x28(%r13)
movq %rbp, 0x30(%r13)
leaq 0x5a25a(%rip), %rdi     # 0xdf7a8
movq %r13, %rsi
callq 0x8a344
leaq 0x5a293(%rip), %rdi     # 0xdf7f0
movq %r13, %rsi
callq 0x8ae18
xorl %r13d, %r13d
leaq 0x5a2c9(%rip), %rdi     # 0xdf838
callq 0x1fbb0
testq %r13, %r13
je 0x85594
movb 0x38(%r13), %bpl
cmpb $0x1, %bpl
jne 0x85587
movb $0x1, (%r14)
movq %r13, %rdi
callq 0x8528a
testb %bpl, %bpl
jne 0x855f9
cmpb $0x1, (%r14)
jne 0x855f9
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
jmp 0x855f9
leaq 0x5a247(%rip), %rdi     # 0xdf838
callq 0x1fbb0
xorl %r12d, %r12d
testq %r12, %r12
jne 0x8560f
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x85b42
movq %rax, %r12
testq %r12, %r12
je 0x8565d
leaq 0x5a21d(%rip), %rdi     # 0xdf838
callq 0x1faa0
movq %rbx, %rax
xorl %edx, %edx
divq 0x5a234(%rip)           # 0xdf860
addq %rax, 0x5a235(%rip)     # 0xdf868
addq 0x5a23e(%rip), %rax     # 0xdf878
movq %rax, 0x5a237(%rip)     # 0xdf878
cmpq 0x5a228(%rip), %rax     # 0xdf870
jbe 0x85651
movq %rax, 0x5a21f(%rip)     # 0xdf870
leaq 0x5a1e0(%rip), %rdi     # 0xdf838
callq 0x1fbb0
movq %r12, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x85810
jmp 0x855f6