// File: /workspace/github_c_makefile_star2_O1/erikdubbelboer[P]discnt/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, %r15
movq %rdi, %rbp
cmpl $0x0, 0x39e03(%rip)     # 0x6efe8
jne 0x353ea
cmpq $0x0, 0x4e545(%rip)     # 0x83738
jne 0x35402
movq 0x38de8(%rip), %r8      # 0x6dfe8
movq %fs:0x0, %rbx
addq %r8, %rbx
movl %fs:(%r8), %eax
testl %eax, %eax
je 0x35415
cmpl $0x2, %eax
je 0x35457
leaq -0x1(%r15), %rax
movb $0x1, %r9b
movl $0x16, %r14d
testq %rax, %r15
jne 0x35400
cmpq %r13, %r15
jb 0x35400
movq %rbp, 0x8(%rsp)
cmpq $0x1, %r12
movq %r12, %r13
adcq $0x0, %r13
cmpq $0x3801, %r12           # imm = 0x3801
setae %al
cmpq $0x1000, %r15           # imm = 0x1000
setae %cl
orb %al, %cl
jne 0x352af
leaq (%r15,%r13), %rax
decq %rax
movq %r15, %rdi
negq %rdi
andq %rax, %rdi
cmpq $0x1000, %rdi           # imm = 0x1000
ja 0x3541f
decq %rdi
shrq $0x3, %rdi
leaq 0x2456d(%rip), %rax     # 0x59800
movzbl (%rdi,%rax), %eax
leaq 0x23de2(%rip), %rcx     # 0x59080
movq (%rcx,%rax,8), %rbp
cmpq $0x4000, %rbp           # imm = 0x4000
jb 0x35399
leaq 0x4f27a(%rip), %rcx     # 0x84530
leaq 0x4f3db(%rip), %rax     # 0x84698
movq (%rax), %rax
movq %r15, %rdx
cmpq %r13, (%rcx)
jb 0x3533a
movq %r15, %rdx
cmpq %r15, %rax
jbe 0x3533a
leaq 0xfff(%r15), %rdx
andq $-0x1000, %rdx          # imm = 0xF000
movl $0x4000, %ebp           # imm = 0x4000
cmpq $0x4001, %r12           # imm = 0x4001
jb 0x3532a
testq %r13, %r13
js 0x3543d
leaq -0x1(,%r13,2), %rcx
bsrq %rcx, %rsi
leal -0x3(%rsi), %ecx
movq $-0x1, %rdi
shlq %cl, %rdi
cmpq $0x7, %rsi
notq %rdi
movl $0xf, %ebp
cmovaeq %rdi, %rbp
movq %rbp, %rcx
addq %r13, %rcx
notq %rbp
andq %rcx, %rbp
leaq (%rdx,%rbp), %rcx
leaq 0x4f223(%rip), %rsi     # 0x84558
cmpq (%rsi), %rcx
jbe 0x35399
leaq 0x4f35f(%rip), %rcx     # 0x846a0
movq (%rcx), %rbp
addq %rbp, %rdx
notq %rbp
andq %rdx, %rbp
je 0x35384
cmpq %r13, %rax
jae 0x35388
cmpq $0x1000, %r12           # imm = 0x1000
ja 0x3549f
leaq -0x1(%r13), %rax
shrq $0x3, %rax
leaq 0x24490(%rip), %rcx     # 0x59800
movzbl (%rax,%rcx), %eax
leaq 0x23d05(%rip), %rcx     # 0x59080
movq (%rcx,%rax,8), %rax
cmpq %r13, %rax
jae 0x35388
xorl %ebp, %ebp
jmp 0x35399
movl $0xfff, %ecx            # imm = 0xFFF
subq %rbp, %rcx
xorl %ebp, %ebp
cmpq %rax, %rcx
cmovaeq %rax, %rbp
movl $0xc, %r14d
testq %rbp, %rbp
je 0x3540c
movq %fs:0x8(%r8), %r9
movq %rbx, %rdi
xorl %esi, %esi
movq %rbp, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x13e13
testq %rax, %rax
je 0x35410
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
xorl %r14d, %r14d
xorl %r9d, %r9d
testb %r9b, %r9b
jne 0x353d8
addq %rbp, 0x10(%rbx)
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x398ac
testb %al, %al
je 0x351eb
movb $0x1, %r9b
movl $0xc, %r14d
jmp 0x353cf
callq 0x12ec4
jmp 0x351f9
xorl %ebp, %ebp
jmp 0x353cf
movb $0x1, %r9b
jmp 0x353cf
movl $0x1, %fs:(%r8)
jmp 0x3545f
leaq 0x10(%rsp), %r14
movq %r14, %rsi
movq %r8, %rbp
callq 0x12f48
movb $0x1, %r9b
movq %rbp, %r8
movq (%r14), %rbp
jmp 0x352a2
movq %r13, %rcx
btrq $0x3f, %rcx
cmpq $0x1, %rcx
movl $0x40, %esi
sbbq $0x0, %rsi
jmp 0x35301
movl $0x3, %fs:(%r8)
leaq 0x4f99e(%rip), %rax     # 0x84e04
movl (%rax), %edi
movq %rbx, %rsi
movq %r8, %r14
callq 0x12990
movq %r14, %r8
testl %eax, %eax
je 0x35221
leaq 0x2472f(%rip), %rdi     # 0x59bb4
callq 0x4f37c
movq %r14, %r8
cmpb $0x1, 0x4e29c(%rip)     # 0x83730
jne 0x35221
callq 0x120c0
leaq 0x10(%rsp), %r14
movq %r13, %rdi
movq %r14, %rsi
movq %r8, %r12
callq 0x12f92
movb $0x1, %r9b
movq %r12, %r8
movq (%r14), %rax
jmp 0x3537f