// File: /workspace/github_c_makefile_star2_O2/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, %rbx
cmpl $0x0, 0x34b48(%rip)     # 0x4835c
pushq $0xc
popq %r11
jne 0x13a3c
movq %fs:0x0, %r14
addq 0x347c2(%rip), %r14     # 0x47ff0
cmpq $0x0, 0x34cf2(%rip)     # 0x48528
jne 0x13a54
movq 0x347ad(%rip), %rbp     # 0x47ff0
movl %fs:(%rbp), %eax
testl %eax, %eax
je 0x13ae3
cmpl $0x2, %eax
je 0x13b42
leaq -0x1(%r15), %rax
pushq $0x16
popq %rcx
testq %rax, %r15
jne 0x13a2b
cmpq %r13, %r15
jb 0x13a2b
cmpq $0x1, %r12
movq %r12, %rax
adcq $0x0, %rax
cmpq $0x3801, %r12           # imm = 0x3801
setae %cl
cmpq $0x1000, %r15           # imm = 0x1000
setae %dl
orb %cl, %dl
pushq $-0x1
popq %rdx
pushq $0x7
popq %rsi
jne 0x138e1
leaq (%r15,%rax), %rcx
decq %rcx
movq %r15, %rdi
negq %rdi
andq %rcx, %rdi
cmpq $0x1000, %rdi           # imm = 0x1000
ja 0x13aed
decq %rdi
shrq $0x3, %rdi
leaq 0x230fb(%rip), %rcx     # 0x369c0
movzbl (%rdi,%rcx), %ecx
leaq 0x22970(%rip), %rdi     # 0x36240
movq (%rdi,%rcx,8), %r13
cmpq $0x4000, %r13           # imm = 0x4000
jb 0x139d3
leaq 0x356b8(%rip), %rcx     # 0x48fa0
leaq 0x357d9(%rip), %rdi     # 0x490c8
movq (%rdi), %r8
movabsq $0x7000000000000000, %r9 # imm = 0x7000000000000000
movq %r15, %rdi
cmpq %rax, (%rcx)
jb 0x1396f
movq %r15, %rdi
cmpq %r15, %r8
jbe 0x1396f
leaq 0xfff(%r15), %rdi
andq $-0x1000, %rdi          # imm = 0xF000
movl $0x4000, %r13d          # imm = 0x4000
cmpq $0x4001, %r12           # imm = 0x4001
jb 0x1395f
cmpq %r9, %r12
ja 0x13b3a
leaq -0x1(,%rax,2), %rcx
bsrq %rcx, %r10
movl %r10d, %ecx
addb $-0x3, %cl
movq %rdx, %r13
shlq %cl, %r13
cmpl $0x6, %r10d
notq %r13
cmovbq %rsi, %r13
leaq (%rax,%r13), %rcx
notq %r13
andq %rcx, %r13
leaq (%rdi,%r13), %rcx
leaq 0x35666(%rip), %r10     # 0x48fd0
cmpq (%r10), %rcx
jbe 0x139d3
cmpq %r9, %rdi
ja 0x139b3
leaq 0x35755(%rip), %rcx     # 0x490d0
movq (%rcx), %r10
cmpq %rax, %r8
jae 0x139b8
cmpq $0x1000, %r12           # imm = 0x1000
ja 0x13b91
leaq -0x1(%rax), %rcx
shrq $0x3, %rcx
leaq 0x23021(%rip), %rdx     # 0x369c0
movzbl (%rcx,%rdx), %ecx
leaq 0x22896(%rip), %rdx     # 0x36240
movq (%rdx,%rcx,8), %r8
cmpq %rax, %r8
jae 0x139b8
movl %r11d, %ecx
jmp 0x13a2b
addq %r10, %rdi
notq %r10
andq %rdi, %r10
movl $0xfff, %eax            # imm = 0xFFF
subq %r10, %rax
xorl %r13d, %r13d
cmpq %r8, %rax
cmovaeq %r8, %r13
movabsq $-0x7000000000000001, %rax # imm = 0x8FFFFFFFFFFFFFFF
leaq (%rax,%r13), %rcx
incq %rax
cmpq %rax, %rcx
jb 0x139b3
movl %r11d, %r12d
movq %fs:0x8(%rbp), %r9
testq %r9, %r9
je 0x13b1e
movq %r14, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x1be89
movl %r12d, %ecx
testq %rax, %rax
je 0x13a2b
movq %rax, (%rbx)
addq %r13, %fs:0x10(%rbp)
cmpb $0x1, 0x34b78(%rip)     # 0x4859c
movl $0x0, %ecx
je 0x13a8f
movl %ecx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r11d, %ebp
callq 0x19ad3
movl %ebp, %r11d
testb %al, %al
je 0x1381e
jmp 0x139b3
movq 0x34595(%rip), %rbp     # 0x47ff0
movl %fs:(%rbp), %eax
testl %eax, %eax
je 0x13bcc
cmpl $0x2, %eax
je 0x13bd6
cmpq $0x0, %fs:0x50(%rbp)
jne 0x1383c
movq %r14, %rdi
movl %r11d, %ebp
callq 0x2ac50
movl %ebp, %r11d
jmp 0x1383c
leaq 0x10(%rsp), %rbx
movq $0x1301, (%rbx)         # imm = 0x1301
movq %rax, 0x8(%rbx)
movq %r13, 0x10(%rbx)
movq %r14, %rdi
movq %rax, %rsi
callq 0x13779
movq %rax, 0x18(%rbx)
xorl %ecx, %ecx
movq %rcx, 0x20(%rbx)
movq %rcx, 0x28(%rbx)
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 0x13a2b
movl $0x1, %fs:(%rbp)
jmp 0x13b4a
leaq -0x1(,%rdi,2), %rcx
bsrq %rcx, %r8
movl %r8d, %ecx
addb $-0x3, %cl
movq %rdx, %r13
shlq %cl, %r13
cmpl $0x6, %r8d
notq %r13
cmovbq %rsi, %r13
addq %r13, %rdi
notq %r13
andq %rdi, %r13
jmp 0x138d4
cmpl $0x1, %fs:(%rbp)
jne 0x13b89
movq %r14, %rdi
callq 0x306cb
movq %rax, %r9
movq %rax, %fs:0x8(%rbp)
jmp 0x139fa
xorl %r13d, %r13d
jmp 0x1395f
movl $0x3, %fs:(%rbp)
leaq 0x35983(%rip), %rax     # 0x494d4
movl (%rax), %edi
movq %r14, %rsi
callq 0xb5b0
pushq $0xc
popq %r11
testl %eax, %eax
je 0x13858
leaq 0x23213(%rip), %rdi     # 0x36d81
callq 0x3126c
pushq $0xc
popq %r11
cmpb $0x1, 0x349a2(%rip)     # 0x48520
jne 0x13858
callq 0xb070
xorl %r9d, %r9d
jmp 0x139fa
cmpq %r9, %r12
ja 0x139b3
leaq -0x1(,%rax,2), %rcx
bsrq %rcx, %r8
movl %r8d, %ecx
addb $-0x3, %cl
shlq %cl, %rdx
cmpl $0x6, %r8d
notq %rdx
cmovbq %rsi, %rdx
leaq (%rdx,%rax), %rcx
notq %rdx
andq %rcx, %rdx
movq %rdx, %r8
jmp 0x139ae
movl $0x1, %fs:(%rbp)
jmp 0x13bde
movl $0x3, %fs:(%rbp)
leaq 0x358ef(%rip), %rax     # 0x494d4
movl (%rax), %edi
movq %r14, %rsi
callq 0xb5b0
pushq $0xc
popq %r11
testl %eax, %eax
je 0x13a70
leaq 0x2317f(%rip), %rdi     # 0x36d81
callq 0x3126c
pushq $0xc
popq %r11
cmpb $0x1, 0x3490e(%rip)     # 0x48520
jne 0x13a70
jmp 0x13b84