// File: /workspace/github_c_makefile_star2_O1/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 0x7c61b
testb %al, %al
je 0x7d398
xorl %eax, %eax
testq %rax, %rax
je 0x7d417
movq %rax, (%rbx)
xorl %eax, %eax
xorl %ecx, %ecx
jmp 0x7d480
cmpq $0x1, %r12
adcq $0x0, %r12
leaq -0x1(%r15), %rax
testq %rax, %r15
setne %al
cmpq %r14, %r15
setb %cl
orb %al, %cl
movb $0x1, %cl
je 0x7d3c0
movl $0x16, %eax
jmp 0x7d480
leaq (%r15,%r12), %rax
decq %rax
movq %r15, %r14
negq %r14
andq %rax, %r14
cmpq %r12, %r14
jae 0x7d420
xorl %r14d, %r14d
testq %r14, %r14
je 0x7d478
leaq 0x62548(%rip), %rax     # 0xdf930
movq (%rax), %rax
cmpq $0x1000, %r15           # imm = 0x1000
ja 0x7d499
cmpq %r14, %rax
jb 0x7d499
xorl %edi, %edi
movq %r14, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x7f908
jmp 0x7d383
movb $0x1, %cl
movl $0xc, %eax
jmp 0x7d480
leaq 0x62509(%rip), %rax     # 0xdf930
movq (%rax), %rax
cmpq %rax, %r14
seta %dl
cmpq $0x1001, %r15           # imm = 0x1001
setae %sil
orb %dl, %sil
jne 0x7d4c6
cmpq $0xe00, %r14            # imm = 0xE00
ja 0x7d53b
decq %r14
shrq $0x3, %r14
leaq 0x25c61(%rip), %rax     # 0xa30c0
movzbl (%rax,%r14), %eax
imulq $0x68, %rax, %rax
leaq 0x61791(%rip), %rdx     # 0xdec00
movq (%rdx,%rax), %r14
jmp 0x7d3d8
movl $0xc, %eax
xorl %r14d, %r14d
testb %cl, %cl
jne 0x7d48d
addq %r14, %fs:-0x28
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
cmpq %r14, %rax
jb 0x7d51d
movq %fs:-0x30, %rdi
testq %rdi, %rdi
jne 0x7d4b4
callq 0x7c332
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x80d53
jmp 0x7d383
leaq 0xfff(%r12), %r14
andq $-0x1000, %r14          # imm = 0xF000
cmpq %r12, %r14
jb 0x7d3d5
leaq 0xfff(%r15), %rdx
andq $-0x1000, %rdx          # imm = 0xF000
addq %r14, %rdx
jb 0x7d3d5
addq $-0x1000, %rdx          # imm = 0xF000
cmpq %rax, %rdx
jbe 0x7d3d8
leaq 0x62374(%rip), %rax     # 0xdf880
movq (%rax), %rax
addq %rax, %r14
notq %rax
andq %rax, %r14
jmp 0x7d3d8
leaq 0x6233c(%rip), %rax     # 0xdf860
cmpq %r15, (%rax)
jae 0x7d54e
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x8b6b5
jmp 0x7d383
addq $0xfff, %r14            # imm = 0xFFF
andq $-0x1000, %r14          # imm = 0xF000
jmp 0x7d3d8
movq %r14, %rdi
xorl %esi, %esi
callq 0x8b6a4
jmp 0x7d383