// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/jemalloc.c
// Function: imemalign
static int
imemalign(void **memptr, size_t alignment, size_t size, size_t min_alignment)
{
	int ret;
	tsd_t *tsd;
	size_t usize;
	void *result;

	assert(min_alignment != 0);

	if (unlikely(malloc_init())) {
		tsd = NULL;
		result = NULL;
		goto label_oom;
	}
	tsd = tsd_fetch();
	witness_assert_lockless(tsd_tsdn(tsd));
	if (size == 0)
		size = 1;

	/* Make sure that alignment is a large enough power of 2. */
	if (unlikely(((alignment - 1) & alignment) != 0
	    || (alignment < min_alignment))) {
		if (config_xmalloc && unlikely(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 (unlikely(usize == 0 || usize > HUGE_MAXCLASS)) {
		result = NULL;
		goto label_oom;
	}

	if (config_prof && opt_prof)
		result = imemalign_prof(tsd, alignment, usize);
	else
		result = ipalloc(tsd, usize, alignment, false);
	if (unlikely(result == NULL))
		goto label_oom;
	assert(((uintptr_t)result & (alignment - 1)) == ZU(0));

	*memptr = result;
	ret = 0;
label_return:
	if (config_stats && likely(result != NULL)) {
		assert(usize == isalloc(tsd_tsdn(tsd), result, config_prof));
		*tsd_thread_allocatedp_get(tsd) += usize;
	}
	UTRACE(0, size, result);
	JEMALLOC_VALGRIND_MALLOC(result != NULL, tsd_tsdn(tsd), result, usize,
	    false);
	witness_assert_lockless(tsd_tsdn(tsd));
	return (ret);
label_oom:
	assert(result == NULL);
	if (config_xmalloc && unlikely(opt_xmalloc)) {
		malloc_write("<jemalloc>: Error allocating aligned memory: "
		    "out of memory\n");
		abort();
	}
	ret = ENOMEM;
	witness_assert_lockless(tsd_tsdn(tsd));
	goto label_return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
cmpl $0x0, 0x30657(%rip)     # 0x4c35c
jne 0x1bf8e
cmpq $0x0, 0x30815(%rip)     # 0x4c528
jne 0x1bfaa
movq 0x302c8(%rip), %rdi     # 0x4bfe8
movq %fs:0x0, %rbx
addq %rdi, %rbx
movl %fs:(%rdi), %eax
testl %eax, %eax
movq %r14, (%rsp)
je 0x1bfb9
cmpl $0x2, %eax
je 0x1bff0
leaq -0x1(%r15), %rax
xorl %r14d, %r14d
movl $0x16, %ebp
testq %rax, %r15
jne 0x1bfb4
cmpq %r13, %r15
jb 0x1bfb4
cmpq $0x1, %r12
movq %r12, %rbp
adcq $0x0, %rbp
cmpq $0x3801, %r12           # imm = 0x3801
setae %al
cmpq $0x1000, %r15           # imm = 0x1000
setae %cl
orb %al, %cl
je 0x1bede
leaq 0x31210(%rip), %rcx     # 0x4cfa0
leaq 0x31331(%rip), %rax     # 0x4d0c8
movq (%rax), %rax
movq %r15, %r14
cmpq %rbp, (%rcx)
jb 0x1be21
movq %r15, %r14
cmpq %r15, %rax
jbe 0x1be21
leaq 0xfff(%r15), %r14
andq $-0x1000, %r14          # imm = 0xF000
movl $0x4000, %r13d          # imm = 0x4000
cmpq $0x4001, %r12           # imm = 0x4001
jb 0x1be11
movabsq $0x7000000000000000, %rcx # imm = 0x7000000000000000
cmpq %rcx, %r12
ja 0x1bfe8
leaq -0x1(,%rbp,2), %rcx
bsrq %rcx, %rdx
movl %edx, %ecx
addb $-0x3, %cl
movq $-0x1, %rsi
shlq %cl, %rsi
cmpl $0x6, %edx
notq %rsi
movl $0x7, %r13d
cmovaeq %rsi, %r13
movq %r13, %rcx
addq %rbp, %rcx
notq %r13
andq %rcx, %r13
leaq (%r14,%r13), %rcx
leaq 0x311b4(%rip), %rdx     # 0x4cfd0
cmpq (%rdx), %rcx
jbe 0x1be62
movabsq $0x7000000000000000, %rcx # imm = 0x7000000000000000
cmpq %rcx, %r14
ja 0x1bfe0
leaq 0x31295(%rip), %rcx     # 0x4d0d0
movq (%rcx), %r13
cmpq %rbp, %rax
jb 0x1bf06
addq %r13, %r14
notq %r13
andq %r14, %r13
movl $0xfff, %ecx            # imm = 0xFFF
subq %r13, %rcx
xorl %r13d, %r13d
cmpq %rax, %rcx
cmovaeq %rax, %r13
movabsq $-0x7000000000000001, %rax # imm = 0x8FFFFFFFFFFFFFFF
leaq (%rax,%r13), %rcx
incq %rax
movl $0xc, %ebp
cmpq %rax, %rcx
jb 0x1bfa2
movq %fs:0x8(%rdi), %r9
testq %r9, %r9
je 0x1bfc2
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0xd4f0
testq %rax, %rax
je 0x1beb6
movq (%rsp), %rcx
movq %rax, (%rcx)
xorl %ebp, %ebp
movq %rax, %r14
testq %r14, %r14
je 0x1bebf
addq %r13, 0x10(%rbx)
testq %r14, %r14
je 0x1becd
cmpb $0x0, 0x306d1(%rip)     # 0x4c59c
jne 0x1bf3a
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10(%rsp), %rdx
movq %rdi, %r14
movq %r15, %rdi
movq %rbp, %rsi
callq 0xba43
movq %r14, %rdi
testb $0x1, %al
je 0x1bd89
movq 0x10(%rsp), %r13
jmp 0x1be62
leaq 0x10(%rsp), %rdx
movq %r12, %rdi
movq %rbp, %rsi
callq 0xbac9
testb $0x1, %al
je 0x1bf29
xorl %r13d, %r13d
movq 0x300c4(%rip), %rdi     # 0x4bfe8
jmp 0x1be62
movq 0x10(%rsp), %rax
movq 0x300b3(%rip), %rdi     # 0x4bfe8
jmp 0x1be47
leaq 0x10(%rsp), %r15
movq $0x1301, (%r15)         # imm = 0x1301
movq %r14, 0x8(%r15)
movq %r13, 0x10(%r15)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1bc38
movq %rax, 0x18(%r15)
xorl %eax, %eax
movq %rax, 0x20(%r15)
movq %rax, 0x28(%r15)
movq %r15, %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 0x1becd
callq 0x216e9
testb %al, %al
je 0x1bd0b
movl $0xc, %ebp
xorl %ebx, %ebx
xorl %r14d, %r14d
jmp 0x1beb6
callq 0xb9bf
jmp 0x1bd19
jmp 0x1beb6
movl $0x1, %fs:(%rdi)
jmp 0x1bff7
cmpl $0x1, %fs:(%rdi)
jne 0x1c037
movq %rdi, %r14
movq %rbx, %rdi
callq 0x3570e
movq %rax, %r9
movq %rax, %fs:0x8(%r14)
jmp 0x1be8f
xorl %r13d, %r13d
jmp 0x1be62
xorl %r13d, %r13d
jmp 0x1be11
movl $0x3, %fs:(%rdi)
leaq 0x314d6(%rip), %rax     # 0x4d4d4
movq %rdi, %r14
movl (%rax), %edi
movq %rbx, %rsi
callq 0xb5b0
movq %r14, %rdi
testl %eax, %eax
je 0x1bd44
leaq 0x20164(%rip), %rdi     # 0x3c181
callq 0x35efc
movq %r14, %rdi
cmpb $0x1, 0x304f4(%rip)     # 0x4c520
jne 0x1bd44
callq 0xb070
xorl %r9d, %r9d
jmp 0x1be8f