// File: /workspace/github_c_makefile_star2_O3/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 $0x58, %rsp
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r15
cmpl $0x0, 0x308b6(%rip)     # 0x4c35c
jne 0x1bcfa
movq %fs:0x0, %rax
addq 0x3052c(%rip), %rax     # 0x4bfe8
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x30a5f(%rip)     # 0x4c528
jne 0x1bd0e
movq 0x30512(%rip), %rax     # 0x4bfe8
movl %fs:(%rax), %eax
testl %eax, %eax
movq %r15, 0x10(%rsp)
je 0x1bd1d
cmpl $0x2, %eax
je 0x1bd98
movq %rbx, %rdi
movq %r14, %rsi
callq 0xb8e6
movl $0x16, %ebp
testb $0x1, %al
jne 0x1bce9
cmpq $0x1, %r12
movq %r12, %r13
adcq $0x0, %r13
cmpq $0x3801, %r12           # imm = 0x3801
setae %al
cmpq $0x1000, %rbx           # imm = 0x1000
setae %cl
orb %al, %cl
jne 0x1bb71
leaq (%rbx,%r13), %rax
decq %rax
movq %rbx, %rdi
negq %rdi
andq %rax, %rdi
cmpq $0x1000, %rdi           # imm = 0x1000
ja 0x1bd83
decq %rdi
shrq $0x3, %rdi
leaq 0x202eb(%rip), %rax     # 0x3be40
movzbl (%rdi,%rax), %eax
leaq 0x1fb60(%rip), %rcx     # 0x3b6c0
movq (%rcx,%rax,8), %r14
cmpq $0x4000, %r14           # imm = 0x4000
jb 0x1bc7d
leaq 0x31428(%rip), %rcx     # 0x4cfa0
leaq 0x31549(%rip), %rax     # 0x4d0c8
movq (%rax), %rax
movq %rbx, %r15
cmpq %r13, (%rcx)
jb 0x1bc07
movq %rbx, %r15
cmpq %rbx, %rax
jbe 0x1bc07
leaq 0xfff(%rbx), %r15
andq $-0x1000, %r15          # imm = 0xF000
movl $0x4000, %r14d          # imm = 0x4000
cmpq $0x4001, %r12           # imm = 0x4001
jb 0x1bbf7
movabsq $0x7000000000000000, %rcx # imm = 0x7000000000000000
cmpq %rcx, %r12
ja 0x1be0a
leaq -0x1(,%r13,2), %rcx
bsrq %rcx, %rdx
movl %edx, %ecx
addb $-0x3, %cl
movq $-0x1, %rsi
shlq %cl, %rsi
cmpl $0x6, %edx
notq %rsi
movl $0x7, %r14d
cmovaeq %rsi, %r14
leaq (%r14,%r13), %rcx
notq %r14
andq %rcx, %r14
leaq (%r14,%r15), %rcx
leaq 0x313ce(%rip), %rdx     # 0x4cfd0
cmpq (%rdx), %rcx
jbe 0x1bc7d
movl $0xc, %ebp
movabsq $0x7000000000000000, %rcx # imm = 0x7000000000000000
cmpq %rcx, %r15
ja 0x1bce9
leaq 0x314aa(%rip), %rcx     # 0x4d0d0
movq (%rcx), %r14
cmpq %r13, %rax
jae 0x1bc62
cmpq $0x1000, %r12           # imm = 0x1000
ja 0x1be1a
leaq -0x1(%r13), %rax
shrq $0x3, %rax
leaq 0x201f6(%rip), %rcx     # 0x3be40
movzbl (%rax,%rcx), %eax
leaq 0x1fa6b(%rip), %rcx     # 0x3b6c0
movq (%rcx,%rax,8), %rax
cmpq %r13, %rax
jb 0x1bce9
addq %r14, %r15
notq %r14
andq %r15, %r14
movl $0xfff, %ecx            # imm = 0xFFF
subq %r14, %rcx
xorl %r14d, %r14d
cmpq %rax, %rcx
cmovaeq %rax, %r14
movabsq $-0x7000000000000001, %rax # imm = 0x8FFFFFFFFFFFFFFF
leaq (%r14,%rax), %rcx
incq %rax
movl $0xc, %ebp
cmpq %rax, %rcx
jb 0x1bce9
movq 0x30349(%rip), %rax     # 0x4bfe8
movq %fs:0x8(%rax), %r9
testq %r9, %r9
je 0x1bddf
movq 0x8(%rsp), %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0xcfd4
testq %rax, %rax
je 0x1bce9
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq 0x30312(%rip), %rcx     # 0x4bfe8
addq %r14, %fs:0x10(%rcx)
cmpb $0x1, 0x308ba(%rip)     # 0x4c59c
movl $0x0, %ebp
je 0x1bd2d
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2158b
testb %al, %al
je 0x1baac
movl $0xc, %ebp
jmp 0x1bce9
movq 0x8(%rsp), %rdi
callq 0xb812
jmp 0x1bacf
movq 0x302c4(%rip), %rax     # 0x4bfe8
movl $0x1, %fs:(%rax)
jmp 0x1bda6
leaq 0x20(%rsp), %r15
movq $0x1301, (%r15)         # imm = 0x1301
movq %rax, 0x8(%r15)
movq %r14, 0x10(%r15)
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x1b9d9
movq %rax, 0x18(%r15)
xorl %ebp, %ebp
movq %rbp, 0x20(%r15)
movq %rbp, 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, 0x18(%rsp)
movq 0x18(%rsp), %rax
jmp 0x1bce9
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0xb870
movq (%r14), %r14
jmp 0x1bb64
movq 0x30249(%rip), %rax     # 0x4bfe8
movl $0x3, %fs:(%rax)
leaq 0x31727(%rip), %rax     # 0x4d4d4
movl (%rax), %edi
movq 0x8(%rsp), %rsi
callq 0xb5b0
testl %eax, %eax
je 0x1baef
leaq 0x20439(%rip), %rdi     # 0x3c201
callq 0x3645c
cmpb $0x1, 0x3074c(%rip)     # 0x4c520
jne 0x1baef
callq 0xb070
movq 0x30202(%rip), %rax     # 0x4bfe8
cmpl $0x1, %fs:(%rax)
jne 0x1be12
movq 0x8(%rsp), %rdi
callq 0x35bad
movq %rax, %r9
movq 0x301e8(%rip), %rax     # 0x4bfe8
movq %r9, %fs:0x8(%rax)
jmp 0x1bcad
xorl %r14d, %r14d
jmp 0x1bbf7
xorl %r9d, %r9d
jmp 0x1bcad
leaq 0x20(%rsp), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0xb8a1
testb $0x1, %al
jne 0x1bce9
movq 0x20(%rsp), %rax
jmp 0x1bc59