// File: /workspace/github_c_makefile_star2_O0/mmcco[P]sljit/sljit_src/sljitUtils.c
// Function: sljit_allocate_stack
struct sljit_stack* SLJIT_CALL sljit_allocate_stack(unsigned long limit, unsigned long max_limit)
{
	struct sljit_stack *stack;
	union {
		void *ptr;
		unsigned long uw;
	} base;
#ifdef _WIN32
	SYSTEM_INFO si;
#endif

	if (limit > max_limit || limit < 1)
		return NULL;

#ifdef _WIN32
	if (!uintptr_tage_align) {
		GetSystemInfo(&si);
		uintptr_tage_align = si.dwPageSize - 1;
	}
#else
	if (!uintptr_tage_align) {
		uintptr_tage_align = sysconf(_SC_PAGESIZE);
		/* Should never happen. */
		if (uintptr_tage_align < 0)
			uintptr_tage_align = 4096;
		uintptr_tage_align--;
	}
#endif

	/* Align limit and max_limit. */
	max_limit = (max_limit + uintptr_tage_align) & ~uintptr_tage_align;

	stack = malloc(sizeof(struct sljit_stack));
	if (!stack)
		return NULL;

#ifdef _WIN32
	base.ptr = VirtualAlloc(NULL, max_limit, MEM_RESERVE, PAGE_READWRITE);
	if (!base.ptr) {
		free(stack);
		return NULL;
	}
	stack->base = base.uw;
	stack->limit = stack->base;
	stack->max_limit = stack->base + max_limit;
	if (sljit_stack_resize(stack, stack->base + limit)) {
		sljit_free_stack(stack);
		return NULL;
	}
#else
#ifdef MAP_ANON
	base.ptr = mmap(NULL, max_limit, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
#else
	if (dev_zero < 0) {
		if (open_dev_zero()) {
			free(stack);
			return NULL;
		}
	}
	base.ptr = mmap(NULL, max_limit, PROT_READ | PROT_WRITE, MAP_PRIVATE, dev_zero, 0);
#endif
	if (base.ptr == MAP_FAILED) {
		free(stack);
		return NULL;
	}
	stack->base = base.uw;
	stack->limit = stack->base + limit;
	stack->max_limit = stack->base + max_limit;
#endif
	stack->top = stack->base;
	return stack;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpq -0x18(%rbp), %rax
ja 0x182d1
cmpq $0x1, -0x10(%rbp)
jae 0x182de
movq $0x0, -0x8(%rbp)
jmp 0x183ef
cmpq $0x0, 0x1c0a2(%rip)     # 0x34388
jne 0x18320
movl $0x1e, %edi
callq 0x2110
movq %rax, 0x1c08f(%rip)     # 0x34388
cmpq $0x0, 0x1c087(%rip)     # 0x34388
jge 0x1830e
movq $0x1000, 0x1c07a(%rip) # imm = 0x1000
movq 0x1c073(%rip), %rax     # 0x34388
addq $-0x1, %rax
movq %rax, 0x1c068(%rip)     # 0x34388
movq -0x18(%rbp), %rax
addq 0x1c05d(%rip), %rax     # 0x34388
movq 0x1c056(%rip), %rcx     # 0x34388
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x18(%rbp)
movl $0x20, %edi
callq 0x20d0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x1835f
movq $0x0, -0x8(%rbp)
jmp 0x183ef
movq -0x18(%rbp), %rsi
xorl %eax, %eax
movl %eax, %r9d
movl $0x3, %edx
movl $0x22, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %r9, %rdi
callq 0x2050
movq %rax, -0x28(%rbp)
movq $-0x1, %rax
cmpq %rax, -0x28(%rbp)
jne 0x183a4
movq -0x20(%rbp), %rdi
callq 0x2030
movq $0x0, -0x8(%rbp)
jmp 0x183ef
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
addq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
addq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)