// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/deps/jemalloc/src/jemalloc.c
// Function: imemalign
static int
imemalign(void **memptr, size_t alignment, size_t size,
    size_t min_alignment)
{
	int ret;
	size_t usize;
	void *result;
	prof_thr_cnt_t *cnt JEMALLOC_CC_SILENCE_INIT(NULL);

	assert(min_alignment != 0);

	if (malloc_init())
		result = NULL;
	else {
		if (size == 0)
			size = 1;

		/* Make sure that alignment is a large enough power of 2. */
		if (((alignment - 1) & alignment) != 0
		    || (alignment < min_alignment)) {
			if (config_xmalloc && opt_xmalloc) {
				malloc_write("<jemalloc>: Error allocating "
				    "aligned memory: invalid alignment\n");
				abort();
			}
			result = NULL;
			ret = EINVAL;
			goto label_return;
		}

		usize = sa2u(size, alignment);
		if (usize == 0) {
			result = NULL;
			ret = ENOMEM;
			goto label_return;
		}

		if (config_prof && opt_prof) {
			PROF_ALLOC_PREP(2, usize, cnt);
			if (cnt == NULL) {
				result = NULL;
				ret = EINVAL;
			} else {
				if (prof_promote && (uintptr_t)cnt !=
				    (uintptr_t)1U && usize <= SMALL_MAXCLASS) {
					assert(sa2u(SMALL_MAXCLASS+1,
					    alignment) != 0);
					result = ipalloc(sa2u(SMALL_MAXCLASS+1,
					    alignment), alignment, false);
					if (result != NULL) {
						arena_prof_promoted(result,
						    usize);
					}
				} else {
					result = ipalloc(usize, alignment,
					    false);
				}
			}
		} else
			result = ipalloc(usize, alignment, false);
	}

	if (result == NULL) {
		if (config_xmalloc && opt_xmalloc) {
			malloc_write("<jemalloc>: Error allocating aligned "
			    "memory: out of memory\n");
			abort();
		}
		ret = ENOMEM;
		goto label_return;
	}

	*memptr = result;
	ret = 0;

label_return:
	if (config_stats && result != NULL) {
		assert(usize == isalloc(result, config_prof));
		thread_allocated_tsd_get()->allocated += usize;
	}
	if (config_prof && opt_prof && result != NULL)
		prof_malloc(result, usize, cnt);
	UTRACE(0, size, result);
	return (ret);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
callq 0x7c7b5
testb %al, %al
je 0x7d682
movl $0xc, %ecx
jmp 0x7d6a3
cmpq $0x1, %r12
adcq $0x0, %r12
leaq -0x1(%r15), %rax
testq %rax, %r15
setne %al
cmpq %r14, %r15
setb %cl
orb %al, %cl
movl $0x16, %ecx
je 0x7d6b1
movl %ecx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq (%r15,%r12), %rax
decq %rax
movq %r15, %r14
negq %r14
andq %rax, %r14
cmpq %r12, %r14
jb 0x7d67b
leaq 0x62263(%rip), %rax     # 0xdf930
movq (%rax), %rax
cmpq %rax, %r14
seta %cl
cmpq $0x1001, %r15           # imm = 0x1001
setae %dl
orb %cl, %dl
jne 0x7d711
cmpq $0xe00, %r14            # imm = 0xE00
ja 0x7d761
decq %r14
shrq $0x3, %r14
leaq 0x25ac5(%rip), %rcx     # 0xa31c0
movzbl (%rcx,%r14), %ecx
imulq $0x68, %rcx, %rcx
leaq 0x614f5(%rip), %rdx     # 0xdec00
movq (%rdx,%rcx), %r14
jmp 0x7d76f
leaq 0xfff(%r12), %r14
andq $-0x1000, %r14          # imm = 0xF000
cmpq %r12, %r14
jb 0x7d67b
leaq 0xfff(%r15), %rcx
andq $-0x1000, %rcx          # imm = 0xF000
addq %r14, %rcx
jb 0x7d67b
addq $-0x1000, %rcx          # imm = 0xF000
cmpq %rax, %rcx
jbe 0x7d778
leaq 0x6212d(%rip), %rcx     # 0xdf880
movq (%rcx), %rcx
addq %rcx, %r14
notq %rcx
andq %rcx, %r14
jmp 0x7d76f
addq $0xfff, %r14            # imm = 0xFFF
andq $-0x1000, %r14          # imm = 0xF000
testq %r14, %r14
je 0x7d67b
cmpq $0x1000, %r15           # imm = 0x1000
ja 0x7d799
cmpq %r14, %rax
jb 0x7d799
xorl %edi, %edi
movq %r14, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x7fb8c
jmp 0x7d7e8
cmpq %r14, %rax
jb 0x7d7c3
movq %fs:-0x30, %rdi
testq %rdi, %rdi
jne 0x7d7b4
callq 0x7c4da
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x8104f
jmp 0x7d7e8
leaq 0x62096(%rip), %rax     # 0xdf860
cmpq %r15, (%rax)
jae 0x7d7de
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x8b92d
jmp 0x7d7e8
movq %r14, %rdi
xorl %esi, %esi
callq 0x8b91c
movl $0xc, %ecx
testq %rax, %rax
je 0x7d6a3
movq %rax, (%rbx)
addq %r14, %fs:-0x28
xorl %ecx, %ecx
jmp 0x7d6a3