// File: /workspace/github_c_makefile_star2_O0/mmcco[P]sljit/sljit_src/sljitNativeX86_64.c
// Function: sljit_emit_enter
int sljit_emit_enter(struct sljit_compiler *compiler,
	int options, int args, int scratches, int saveds,
	int fscratches, int fsaveds, int local_size)
{
	int i, tmp, size, saved_reg_size;
	u_char *inst;

	CHECK_ERROR();
	CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
	set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);

	compiler->flags_saved = 0;

	/* Including the return address saved by the call instruction. */
	saved_reg_size = GET_SAVED_REGS_SIZE(scratches, saveds, 1);

	tmp = saveds < SLJIT_NUM_SAVED_REGS ? (SLJIT_S0 + 1 - saveds) : SLJIT_FIRST_SAVED_REG;
	for (i = SLJIT_S0; i >= tmp; i--) {
		size = reg_map[i] >= 8 ? 2 : 1;
		inst = ensure_buf(compiler, 1 + size);
		FAIL_IF(!inst);
		INC_SIZE(size);
		if (reg_map[i] >= 8)
			*inst++ = REX_B;
		PUSH_REG(reg_lmap[i]);
	}

	for (i = scratches; i >= SLJIT_FIRST_SAVED_REG; i--) {
		size = reg_map[i] >= 8 ? 2 : 1;
		inst = ensure_buf(compiler, 1 + size);
		FAIL_IF(!inst);
		INC_SIZE(size);
		if (reg_map[i] >= 8)
			*inst++ = REX_B;
		PUSH_REG(reg_lmap[i]);
	}

	if (args > 0) {
		size = args * 3;
		inst = ensure_buf(compiler, 1 + size);
		FAIL_IF(!inst);

		INC_SIZE(size);

#ifndef _WIN64
		if (args > 0) {
			*inst++ = REX_W;
			*inst++ = MOV_r_rm;
			*inst++ = MOD_REG | (reg_map[SLJIT_S0] << 3) | 0x7 /* rdi */;
		}
		if (args > 1) {
			*inst++ = REX_W | REX_R;
			*inst++ = MOV_r_rm;
			*inst++ = MOD_REG | (reg_lmap[SLJIT_S1] << 3) | 0x6 /* rsi */;
		}
		if (args > 2) {
			*inst++ = REX_W | REX_R;
			*inst++ = MOV_r_rm;
			*inst++ = MOD_REG | (reg_lmap[SLJIT_S2] << 3) | 0x2 /* rdx */;
		}
#else
		if (args > 0) {
			*inst++ = REX_W;
			*inst++ = MOV_r_rm;
			*inst++ = MOD_REG | (reg_map[SLJIT_S0] << 3) | 0x1 /* rcx */;
		}
		if (args > 1) {
			*inst++ = REX_W;
			*inst++ = MOV_r_rm;
			*inst++ = MOD_REG | (reg_map[SLJIT_S1] << 3) | 0x2 /* rdx */;
		}
		if (args > 2) {
			*inst++ = REX_W | REX_B;
			*inst++ = MOV_r_rm;
			*inst++ = MOD_REG | (reg_map[SLJIT_S2] << 3) | 0x0 /* r8 */;
		}
#endif
	}

	local_size = ((local_size + SLJIT_LOCALS_OFFSET + saved_reg_size + 15) & ~15) - saved_reg_size;
	compiler->local_size = local_size;

#ifdef _WIN64
	if (local_size > 1024) {
		/* Allocate stack for the callback, which grows the stack. */
		inst = ensure_buf(compiler, 1 + 4 + (3 + sizeof(int)));
		FAIL_IF(!inst);
		INC_SIZE(4 + (3 + sizeof(int)));
		*inst++ = REX_W;
		*inst++ = GROUP_BINARY_83;
		*inst++ = MOD_REG | SUB | 4;
		/* Allocated size for regs must be divisible by 8. */
		SLJIT_ASSERT(!(saved_reg_size & 0x7));
		/* Aligned to 16 byte. */
		if (saved_reg_size & 0x8) {
			*inst++ = 5 * sizeof(long);
			local_size -= 5 * sizeof(long);
		} else {
			*inst++ = 4 * sizeof(long);
			local_size -= 4 * sizeof(long);
		}
		/* Second instruction */
		SLJIT_COMPILE_ASSERT(reg_map[SLJIT_R0] < 8, temporary_reg1_is_loreg);
		*inst++ = REX_W;
		*inst++ = MOV_rm_i32;
		*inst++ = MOD_REG | reg_lmap[SLJIT_R0];
		*(int*)inst = local_size;
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
			|| (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
		compiler->skip_checks = 1;
#endif
		FAIL_IF(sljit_emit_ijump(compiler, SLJIT_CALL1, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_grow_stack)));
	}
#endif

	SLJIT_ASSERT(local_size > 0);
	if (local_size <= 127) {
		inst = ensure_buf(compiler, 1 + 4);
		FAIL_IF(!inst);
		INC_SIZE(4);
		*inst++ = REX_W;
		*inst++ = GROUP_BINARY_83;
		*inst++ = MOD_REG | SUB | 4;
		*inst++ = local_size;
	}
	else {
		inst = ensure_buf(compiler, 1 + 7);
		FAIL_IF(!inst);
		INC_SIZE(7);
		*inst++ = REX_W;
		*inst++ = GROUP_BINARY_81;
		*inst++ = MOD_REG | SUB | 4;
		*(int*)inst = local_size;
		inst += sizeof(int);
	}

#ifdef _WIN64
	/* Save xmm6 reg: movaps [rsp + 0x20], xmm6 */
	if (fscratches >= 6 || fsaveds >= 1) {
		inst = ensure_buf(compiler, 1 + 5);
		FAIL_IF(!inst);
		INC_SIZE(5);
		*inst++ = GROUP_0F;
		*(int*)inst = 0x20247429;
	}
#endif

	return SLJIT_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x19b5a
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1a0c1
jmp 0x19b5c
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
movl -0x24(%rbp), %r9d
movl 0x10(%rbp), %r10d
movl 0x18(%rbp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x1a0d0
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
movl -0x24(%rbp), %r9d
movl 0x10(%rbp), %r10d
movl 0x18(%rbp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x1a2d0
movq -0x10(%rbp), %rax
movl $0x0, 0x74(%rax)
cmpl $0x6, -0x1c(%rbp)
jge 0x19bc6
xorl %eax, %eax
movl %eax, -0x44(%rbp)
jmp 0x19bcf
movl -0x1c(%rbp), %eax
subl $0x6, %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x48(%rbp)
cmpl $0x6, -0x20(%rbp)
jge 0x19be3
movl -0x20(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0x19bed
movl $0x6, %eax
movl %eax, -0x4c(%rbp)
jmp 0x19bed
movl -0x48(%rbp), %eax
movl -0x4c(%rbp), %ecx
addl %ecx, %eax
addl $0x1, %eax
cltq
shlq $0x3, %rax
movl %eax, -0x34(%rbp)
cmpl $0x6, -0x20(%rbp)
jge 0x19c14
movl $0xd, %eax
subl -0x20(%rbp), %eax
movl %eax, -0x50(%rbp)
jmp 0x19c1e
movl $0x7, %eax
movl %eax, -0x50(%rbp)
jmp 0x19c1e
movl -0x50(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl $0xc, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jl 0x19d05
movslq -0x28(%rbp), %rcx
leaq 0x16b1e(%rip), %rax     # 0x30760
movzbl (%rax,%rcx), %edx
movl $0x1, %eax
movl $0x2, %ecx
cmpl $0x8, %edx
cmovgel %ecx, %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl -0x30(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x1a330
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x19c84
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1a0c1
jmp 0x19c86
movl -0x30(%rbp), %eax
movb %al, %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
movslq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x60(%rax), %rcx
movq %rcx, 0x60(%rax)
movslq -0x28(%rbp), %rcx
leaq 0x16aa9(%rip), %rax     # 0x30760
movzbl (%rax,%rcx), %eax
cmpl $0x8, %eax
jl 0x19cd2
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $0x41, (%rax)
movslq -0x28(%rbp), %rcx
leaq 0x16aa3(%rip), %rax     # 0x30780
movzbl (%rax,%rcx), %eax
addl $0x50, %eax
movb %al, %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
movl -0x28(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x19c2b
movl -0x1c(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $0x7, -0x28(%rbp)
jl 0x19de3
movslq -0x28(%rbp), %rcx
leaq 0x16a40(%rip), %rax     # 0x30760
movzbl (%rax,%rcx), %edx
movl $0x1, %eax
movl $0x2, %ecx
cmpl $0x8, %edx
cmovgel %ecx, %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl -0x30(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x1a330
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x19d62
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1a0c1
jmp 0x19d64
movl -0x30(%rbp), %eax
movb %al, %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
movslq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x60(%rax), %rcx
movq %rcx, 0x60(%rax)
movslq -0x28(%rbp), %rcx
leaq 0x169cb(%rip), %rax     # 0x30760
movzbl (%rax,%rcx), %eax
cmpl $0x8, %eax
jl 0x19db0
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $0x41, (%rax)
movslq -0x28(%rbp), %rcx
leaq 0x169c5(%rip), %rax     # 0x30780
movzbl (%rax,%rcx), %eax
addl $0x50, %eax
movb %al, %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
movl -0x28(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x19d0b
cmpl $0x0, -0x18(%rbp)
jle 0x19f36
imull $0x3, -0x18(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl -0x30(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x1a330
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x19e1f
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1a0c1
jmp 0x19e21
movl -0x30(%rbp), %eax
movb %al, %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
movslq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x60(%rax), %rcx
movq %rcx, 0x60(%rax)
cmpl $0x0, -0x18(%rbp)
jle 0x19e96
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $0x48, (%rax)
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $-0x75, (%rax)
movzbl 0x168f4(%rip), %eax     # 0x3076c
shll $0x3, %eax
orl $0xc0, %eax
orl $0x7, %eax
movb %al, %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
cmpl $0x1, -0x18(%rbp)
jle 0x19ee5
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $0x4c, (%rax)
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $-0x75, (%rax)
movzbl 0x168c4(%rip), %eax     # 0x3078b
shll $0x3, %eax
orl $0xc0, %eax
orl $0x6, %eax
movb %al, %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
cmpl $0x2, -0x18(%rbp)
jle 0x19f34
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $0x4c, (%rax)
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $-0x75, (%rax)
movzbl 0x16874(%rip), %eax     # 0x3078a
shll $0x3, %eax
orl $0xc0, %eax
orl $0x2, %eax
movb %al, %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
jmp 0x19f36
movslq 0x18(%rbp), %rax
addq $0x8, %rax
movslq -0x34(%rbp), %rcx
addq %rcx, %rax
addq $0xf, %rax
andq $-0x10, %rax
movslq -0x34(%rbp), %rcx
subq %rcx, %rax
movl %eax, 0x18(%rbp)
movl 0x18(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x58(%rax)
cmpl $0x0, 0x18(%rbp)
jg 0x19f7f
leaq 0x168ba(%rip), %rdi     # 0x30828
movl $0xcd, %esi
movb $0x0, %al
callq 0x2070
callq 0x2040
jmp 0x19f81
cmpl $0x7f, 0x18(%rbp)
jg 0x1a027
movq -0x10(%rbp), %rdi
movl $0x5, %esi
callq 0x1a330
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x19fb2
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1a0c1
jmp 0x19fb4
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $0x4, (%rax)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rcx
addq $0x4, %rcx
movq %rcx, 0x60(%rax)
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $0x48, (%rax)
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $-0x7d, (%rax)
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $-0x14, (%rax)
movl 0x18(%rbp), %eax
movb %al, %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
jmp 0x1a0ba
movq -0x10(%rbp), %rdi
movl $0x8, %esi
callq 0x1a330
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x1a04b
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1a0c1
jmp 0x1a04d
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $0x7, (%rax)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rcx
addq $0x7, %rcx
movq %rcx, 0x60(%rax)
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $0x48, (%rax)
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $-0x7f, (%rax)
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $-0x14, (%rax)
movl 0x18(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)