// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/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())) {
		result = NULL;
		goto label_oom;
	}
	tsd = tsd_fetch();
	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)) {
		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(result, config_prof));
		*tsd_thread_allocatedp_get(tsd) += usize;
	}
	UTRACE(0, size, result);
	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;
	goto label_return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
cmpl $0x0, 0x37b48(%rip)     # 0x5a358
jne 0x22a08
movq %fs:0x0, %r10
addq 0x357ca(%rip), %r10     # 0x57ff0
cmpq $0x0, 0x37dfa(%rip)     # 0x5a628
jne 0x22a1c
movq 0x357b5(%rip), %r8      # 0x57ff0
movl %fs:(%r8), %eax
testl %eax, %eax
je 0x22a2f
cmpl $0x2, %eax
je 0x22a76
leaq -0x1(%r14), %rax
movl $0x16, %ebx
testq %rax, %r14
jne 0x229f7
cmpq %r13, %r14
jb 0x229f7
cmpq $0x1, %r12
movq %r12, %r13
adcq $0x0, %r13
cmpq $0x3801, %r12           # imm = 0x3801
setae %al
cmpq $0x1000, %r14           # imm = 0x1000
setae %cl
orb %al, %cl
jne 0x228d5
leaq (%r14,%r13), %rax
decq %rax
movq %r14, %rdi
negq %rdi
andq %rax, %rdi
cmpq $0x1000, %rdi           # imm = 0x1000
ja 0x22a39
decq %rdi
shrq $0x3, %rdi
leaq 0x25707(%rip), %rax     # 0x47fc0
movzbl (%rdi,%rax), %eax
leaq 0x24f7c(%rip), %rcx     # 0x47840
movq (%rcx,%rax,8), %rcx
cmpq $0x4000, %rcx           # imm = 0x4000
jb 0x229c5
leaq 0x38c64(%rip), %rcx     # 0x5b540
leaq 0x38dc5(%rip), %rax     # 0x5b6a8
movq (%rax), %rbp
movq %r14, %rax
cmpq %r13, (%rcx)
jb 0x2295d
movq %r14, %rax
cmpq %r14, %rbp
jbe 0x2295d
leaq 0xfff(%r14), %rax
andq $-0x1000, %rax          # imm = 0xF000
movl $0x4000, %ecx           # imm = 0x4000
cmpq $0x4001, %r12           # imm = 0x4001
jb 0x2294d
testq %r13, %r13
js 0x22a5c
leaq -0x1(,%r13,2), %rcx
bsrq %rcx, %rdx
leal -0x3(%rdx), %ecx
movq $-0x1, %rsi
shlq %cl, %rsi
cmpq $0x6, %rdx
notq %rsi
movl $0x7, %ecx
cmovaeq %rsi, %rcx
leaq (%rcx,%r13), %rdx
notq %rcx
andq %rdx, %rcx
leaq (%rcx,%rax), %rdx
leaq 0x38c10(%rip), %rsi     # 0x5b568
cmpq (%rsi), %rdx
jbe 0x229c5
movq %r15, 0x10(%rsp)
leaq 0x38d47(%rip), %rcx     # 0x5b6b0
movq (%rcx), %r15
addq %r15, %rax
notq %r15
movl $0xc, %ebx
andq %rax, %r15
je 0x229f7
cmpq %r13, %rbp
jae 0x229b1
cmpq $0x1000, %r12           # imm = 0x1000
ja 0x22ac7
leaq -0x1(%r13), %rax
shrq $0x3, %rax
leaq 0x25623(%rip), %rcx     # 0x47fc0
movzbl (%rax,%rcx), %eax
leaq 0x24e98(%rip), %rcx     # 0x47840
movq (%rcx,%rax,8), %rbp
cmpq %r13, %rbp
jb 0x229f7
movl $0xfff, %eax            # imm = 0xFFF
subq %r15, %rax
cmpq %rbp, %rax
movq 0x10(%rsp), %r15
jae 0x229cd
jmp 0x229f7
movq %rcx, %rbp
testq %rcx, %rcx
je 0x22a15
movq %fs:0x8(%r8), %r9
xorl %ebx, %ebx
movq %r10, %rdi
xorl %esi, %esi
movq %rbp, %rdx
movq %r14, %rcx
movq %r8, %r14
xorl %r8d, %r8d
callq 0x28c3d
testq %rax, %rax
je 0x22a15
movq %rax, (%r15)
addq %rbp, %fs:0x10(%r14)
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x26e29
testb %al, %al
je 0x22816
movl $0xc, %ebx
jmp 0x229f7
movq %r10, %rdi
movq %r10, %rbx
callq 0x111e7
movq %rbx, %r10
jmp 0x22834
movl $0x1, %fs:(%r8)
jmp 0x22a7e
leaq 0x8(%rsp), %rsi
movq %r8, %rbp
movq %r10, %rbx
callq 0x11245
movq %rbx, %r10
movq %rbp, %r8
leaq 0x8(%rsp), %rax
movq (%rax), %rcx
jmp 0x228c8
movq %r13, %rcx
btrq $0x3f, %rcx
cmpq $0x1, %rcx
movl $0x40, %edx
sbbq $0x0, %rdx
jmp 0x22926
movl $0x3, %fs:(%r8)
leaq 0x3938f(%rip), %rax     # 0x5be14
movl (%rax), %edi
movq %r10, %rsi
movq %r8, %rbx
movq %r10, %rbp
callq 0x106f0
movq %rbp, %r10
movq %rbx, %r8
testl %eax, %eax
je 0x22850
leaq 0x258cf(%rip), %rdi     # 0x48379
callq 0x3d37c
movq %rbp, %r10
movq %rbx, %r8
cmpb $0x1, 0x37b64(%rip)     # 0x5a620
jne 0x22850
callq 0x10090
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
movq %r8, %rbp
movq %r10, %r12
callq 0x11275
movq %r12, %r10
movq %rbp, %r8
leaq 0x8(%rsp), %rax
movq (%rax), %rbp
jmp 0x229ac