// File: /workspace/github_c_makefile_star2_O2/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
pushq %rax
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
cmpl $0x0, 0x39388(%rip)     # 0x56358
pushq $0xc
popq %r11
jne 0x1d1c5
movq %fs:0x0, %r15
addq 0x37006(%rip), %r15     # 0x53ff0
cmpq $0x0, 0x39636(%rip)     # 0x56628
jne 0x1d1da
movq 0x36ff1(%rip), %rbp     # 0x53ff0
movl %fs:(%rbp), %eax
testl %eax, %eax
je 0x1d215
cmpl $0x2, %eax
je 0x1d266
leaq -0x1(%r14), %rcx
pushq $0x16
popq %rax
testq %rcx, %r14
jne 0x1d1b6
cmpq %r13, %r14
jb 0x1d1b6
cmpq $0x1, %r12
movq %r12, %rax
adcq $0x0, %rax
cmpq $0x3801, %r12           # imm = 0x3801
setae %cl
cmpq $0x1000, %r14           # imm = 0x1000
setae %dl
orb %cl, %dl
pushq $-0x1
popq %rdx
pushq $0x7
popq %rsi
jne 0x1d09d
leaq (%r14,%rax), %rcx
decq %rcx
movq %r14, %rdi
negq %rdi
andq %rcx, %rdi
cmpq $0x1000, %rdi           # imm = 0x1000
ja 0x1d21f
decq %rdi
shrq $0x3, %rdi
leaq 0x25a7f(%rip), %rcx     # 0x42b00
movzbl (%rdi,%rcx), %ecx
leaq 0x252f4(%rip), %rdi     # 0x42380
movq (%rdi,%rcx,8), %r8
cmpq $0x4000, %r8            # imm = 0x4000
jb 0x1d17e
leaq 0x3a49c(%rip), %rcx     # 0x57540
leaq 0x3a5fd(%rip), %rdi     # 0x576a8
movq (%rdi), %r13
pushq $0x40
popq %rdi
movq %r14, %r9
cmpq %rax, (%rcx)
jb 0x1d122
movq %r14, %r9
cmpq %r14, %r13
jbe 0x1d122
leaq 0xfff(%r14), %r9
andq $-0x1000, %r9           # imm = 0xF000
movl $0x4000, %r8d           # imm = 0x4000
cmpq $0x4001, %r12           # imm = 0x4001
jb 0x1d112
testq %rax, %rax
js 0x1d24e
leaq -0x1(,%rax,2), %rcx
bsrq %rcx, %r10
leal -0x3(%r10), %ecx
movq %rdx, %r8
shlq %cl, %r8
cmpq $0x6, %r10
notq %r8
cmovbq %rsi, %r8
leaq (%r8,%rax), %rcx
notq %r8
andq %rcx, %r8
leaq (%r8,%r9), %rcx
leaq 0x3a44b(%rip), %r10     # 0x57568
cmpq (%r10), %rcx
jbe 0x1d17e
leaq 0x3a587(%rip), %rcx     # 0x576b0
movq (%rcx), %r8
addq %r8, %r9
notq %r8
andq %r9, %r8
je 0x1d179
cmpq %rax, %r13
jae 0x1d16c
cmpq $0x1000, %r12           # imm = 0x1000
ja 0x1d2ad
leaq -0x1(%rax), %rcx
shrq $0x3, %rcx
leaq 0x259a8(%rip), %rdx     # 0x42b00
movzbl (%rcx,%rdx), %ecx
leaq 0x2521d(%rip), %rdx     # 0x42380
movq (%rdx,%rcx,8), %r13
cmpq %rax, %r13
jb 0x1d179
movl $0xfff, %eax            # imm = 0xFFF
subq %r8, %rax
cmpq %r13, %rax
jae 0x1d186
movl %r11d, %eax
jmp 0x1d1b6
movq %r8, %r13
testq %r8, %r8
je 0x1d179
movq %fs:0x8(%rbp), %r9
movq %r15, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
movl %r11d, %r14d
callq 0x23953
movq %rax, %rcx
movl %r14d, %eax
testq %rcx, %rcx
je 0x1d1b6
movq %rcx, (%rbx)
addq %r13, %fs:0x10(%rbp)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r11d, %ebp
callq 0x21ece
movl %ebp, %r11d
testb %al, %al
je 0x1cfda
jmp 0x1d179
movq 0x36e0f(%rip), %rbp     # 0x53ff0
movl %fs:(%rbp), %eax
testl %eax, %eax
je 0x1d2e5
cmpl $0x2, %eax
je 0x1d2ef
cmpq $0x0, %fs:0x48(%rbp)
jne 0x1cff8
movq %r15, %rdi
movl %r11d, %ebp
callq 0x32f9c
movl %ebp, %r11d
jmp 0x1cff8
movl $0x1, %fs:(%rbp)
jmp 0x1d26e
leaq -0x1(,%rdi,2), %rcx
bsrq %rcx, %r9
leal -0x3(%r9), %ecx
movq %rdx, %r8
shlq %cl, %r8
cmpq $0x6, %r9
notq %r8
cmovbq %rsi, %r8
addq %r8, %rdi
notq %r8
andq %rdi, %r8
jmp 0x1d090
movq %rax, %rcx
btrq $0x3f, %rcx
cmpq $0x1, %rcx
movq %rdi, %r10
sbbq $0x0, %r10
jmp 0x1d0f3
movl $0x3, %fs:(%rbp)
leaq 0x3ab9f(%rip), %rax     # 0x57e14
movl (%rax), %edi
movq %r15, %rsi
callq 0x106f0
pushq $0xc
popq %r11
testl %eax, %eax
je 0x1d014
leaq 0x25c27(%rip), %rdi     # 0x42eb9
callq 0x37d1c
pushq $0xc
popq %r11
cmpb $0x1, 0x3937e(%rip)     # 0x56620
jne 0x1d014
callq 0x10090
testq %rax, %rax
js 0x1d336
leaq -0x1(,%rax,2), %rcx
bsrq %rcx, %rdi
leal -0x3(%rdi), %ecx
shlq %cl, %rdx
cmpq $0x6, %rdi
notq %rdx
cmovbq %rsi, %rdx
leaq (%rdx,%rax), %rcx
notq %rdx
andq %rcx, %rdx
movq %rdx, %r13
jmp 0x1d167
movl $0x1, %fs:(%rbp)
jmp 0x1d2f7
movl $0x3, %fs:(%rbp)
leaq 0x3ab16(%rip), %rax     # 0x57e14
movl (%rax), %edi
movq %r15, %rsi
callq 0x106f0
pushq $0xc
popq %r11
testl %eax, %eax
je 0x1d1f6
leaq 0x25b9e(%rip), %rdi     # 0x42eb9
callq 0x37d1c
pushq $0xc
popq %r11
cmpb $0x1, 0x392f5(%rip)     # 0x56620
jne 0x1d1f6
jmp 0x1d2a8
movq %rax, %rcx
btrq $0x3f, %rcx
cmpq $0x1, %rcx
sbbq $0x0, %rdi
jmp 0x1d2c2