// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/deps/jemalloc/src/jemalloc.c
// Function: je_allocm
int
je_allocm(void **ptr, size_t *rsize, size_t size, int flags)
{
	void *p;
	size_t usize;
	size_t alignment = (ZU(1) << (flags & ALLOCM_LG_ALIGN_MASK)
	    & (SIZE_T_MAX-1));
	bool zero = flags & ALLOCM_ZERO;
	unsigned arena_ind = ((unsigned)(flags >> 8)) - 1;
	arena_t *arena;
	bool try_tcache;

	assert(ptr != NULL);
	assert(size != 0);

	if (malloc_init())
		goto label_oom;

	if (arena_ind != UINT_MAX) {
		arena = arenas[arena_ind];
		try_tcache = false;
	} else {
		arena = NULL;
		try_tcache = true;
	}

	usize = (alignment == 0) ? s2u(size) : sa2u(size, alignment);
	if (usize == 0)
		goto label_oom;

	if (config_prof && opt_prof) {
		prof_thr_cnt_t *cnt;

		PROF_ALLOC_PREP(1, usize, cnt);
		if (cnt == NULL)
			goto label_oom;
		if (prof_promote && (uintptr_t)cnt != (uintptr_t)1U && usize <=
		    SMALL_MAXCLASS) {
			size_t usize_promoted = (alignment == 0) ?
			    s2u(SMALL_MAXCLASS+1) : sa2u(SMALL_MAXCLASS+1,
			    alignment);
			assert(usize_promoted != 0);
			p = iallocm(usize_promoted, alignment, zero,
			    try_tcache, arena);
			if (p == NULL)
				goto label_oom;
			arena_prof_promoted(p, usize);
		} else {
			p = iallocm(usize, alignment, zero, try_tcache, arena);
			if (p == NULL)
				goto label_oom;
		}
		prof_malloc(p, usize, cnt);
	} else {
		p = iallocm(usize, alignment, zero, try_tcache, arena);
		if (p == NULL)
			goto label_oom;
	}
	if (rsize != NULL)
		*rsize = usize;

	*ptr = p;
	if (config_stats) {
		assert(usize == isalloc(p, config_prof));
		thread_allocated_tsd_get()->allocated += usize;
	}
	UTRACE(0, size, p);
	JEMALLOC_VALGRIND_MALLOC(true, p, usize, zero);
	return (ALLOCM_SUCCESS);
label_oom:
	if (config_xmalloc && opt_xmalloc) {
		malloc_write("<jemalloc>: Error in allocm(): "
		    "out of memory\n");
		abort();
	}
	*ptr = NULL;
	UTRACE(0, size, 0);
	return (ALLOCM_ERR_OOM);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %ebp
movq %rdx, %r15
movq %rsi, (%rsp)
movq %rdi, %rbx
pushq $0x1
popq %r13
shlq %cl, %r13
callq 0x75442
testb %al, %al
je 0x769c5
andq $0x0, (%rbx)
pushq $0x1
popq %rcx
movl %ecx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
andq $-0x2, %r13
cmpl $0x100, %ebp            # imm = 0x100
jae 0x769d6
xorl %r12d, %r12d
jmp 0x769ea
movl %ebp, %eax
sarl $0x8, %eax
decl %eax
movq 0x65194(%rip), %rcx     # 0xdbb78
movl %eax, %eax
movq (%rcx,%rax,8), %r12
movl %ebp, %r14d
andl $0x40, %r14d
movq %r15, %rdi
testq %r13, %r13
je 0x76a2c
movq %r13, %rsi
callq 0x76af9
testq %rax, %rax
je 0x769ad
movq %rax, %r15
xorl %ecx, %ecx
cmpl $0x100, %ebp            # imm = 0x100
setb %cl
xorl %edx, %edx
testl %r14d, %r14d
setne %dl
movq %rax, %rdi
movq %r13, %rsi
movq %r12, %r8
callq 0x779f0
jmp 0x76a70
callq 0x760c0
testq %rax, %rax
je 0x769ad
movq %rax, %r15
xorl %esi, %esi
testl %r14d, %r14d
je 0x76a5b
cmpl $0x100, %ebp            # imm = 0x100
setb %sil
movq %r15, %rdi
movq %r12, %rdx
callq 0x77a84
jmp 0x76a70
cmpl $0x100, %ebp            # imm = 0x100
setb %sil
movq %r15, %rdi
movq %r12, %rdx
callq 0x77603
testq %rax, %rax
je 0x769ad
movq (%rsp), %rcx
testq %rcx, %rcx
je 0x76a85
movq %r15, (%rcx)
movq %rax, (%rbx)
addq %r15, %fs:-0x28
xorl %ecx, %ecx
cmpb $0x1, 0x650d0(%rip)     # 0xdbb6a
jne 0x769b4
leaq 0x10(%rsp), %rbx
movq $0x1301, (%rbx)         # imm = 0x1301
movq %rax, 0x8(%rbx)
movq %r15, 0x10(%rbx)
movq %rax, %rdi
callq 0x76125
movq %rax, 0x18(%rbx)
shrl $0x6, %r14d
movq %r14, 0x20(%rbx)
movq $0x0, 0x28(%rbx)
xorl %ecx, %ecx
movq %rbx, %rax
xorl %edx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
movq %rdx, 0x8(%rsp)
movq 0x8(%rsp), %rax
jmp 0x769b4