// File: /workspace/github_c_makefile_star2_O3/mmcco[P]sljit/sljit_src/sljitNativeX86_common.c
// Function: emit_shift
static int emit_shift(struct sljit_compiler *compiler,
	u_char mode,
	int dst, long dstw,
	int src1, long src1w,
	int src2, long src2w)
{
	u_char* inst;

	if ((src2 & SLJIT_IMM) || (src2 == SLJIT_PREF_SHIFT_REG)) {
		if (dst == src1 && dstw == src1w) {
			inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, dstw);
			FAIL_IF(!inst);
			*inst |= mode;
			return SLJIT_SUCCESS;
		}
		if (dst == SLJIT_UNUSED) {
			EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
			inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0);
			FAIL_IF(!inst);
			*inst |= mode;
			return SLJIT_SUCCESS;
		}
		if (dst == SLJIT_PREF_SHIFT_REG && src2 == SLJIT_PREF_SHIFT_REG) {
			EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
			inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
			FAIL_IF(!inst);
			*inst |= mode;
			EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
			return SLJIT_SUCCESS;
		}
		if (FAST_IS_REG(dst)) {
			EMIT_MOV(compiler, dst, 0, src1, src1w);
			inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, 0);
			FAIL_IF(!inst);
			*inst |= mode;
			return SLJIT_SUCCESS;
		}

		EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
		inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0);
		FAIL_IF(!inst);
		*inst |= mode;
		EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
		return SLJIT_SUCCESS;
	}

	if (dst == SLJIT_PREF_SHIFT_REG) {
		EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
		EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
		inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
		FAIL_IF(!inst);
		*inst |= mode;
		EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
	}
	else if (FAST_IS_REG(dst) && dst != src2 && !ADDRESSING_DEPENDS_ON(src2, dst)) {
		if (src1 != dst)
			EMIT_MOV(compiler, dst, 0, src1, src1w);
		EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
		EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
		inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, dst, 0);
		FAIL_IF(!inst);
		*inst |= mode;
		EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
	}
	else {
		/* This case is really difficult, since ecx itself may used for
		   addressing, and we must ensure to work even in that case. */
		EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
		EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_PREF_SHIFT_REG, 0);
#else
		/* [esp+0] contains the flags. */
		EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), sizeof(long), SLJIT_PREF_SHIFT_REG, 0);
#endif
		EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
		inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
		FAIL_IF(!inst);
		*inst |= mode;
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
		EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG2, 0);
#else
		EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, SLJIT_MEM1(SLJIT_SP), sizeof(long));
#endif
		EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
	}

	return SLJIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r13
movl %edx, %r14d
movl %esi, %ebp
movq %rdi, %rbx
movq 0x48(%rsp), %r15
movl 0x40(%rsp), %r12d
testb $0x40, %r12b
sete %al
cmpl $0x3, %r12d
setne %cl
testb %al, %cl
jne 0x1f64f
cmpl %r8d, %r14d
setne %al
cmpq %r9, %r13
setne %cl
orb %al, %cl
jne 0x1f688
movq %rbx, %rdi
movl $0x21, %esi
movl %r12d, %edx
movq %r15, %rcx
movl %r14d, %r8d
movq %r13, %r9
callq 0x15da2
testq %rax, %rax
je 0x1f976
orb %bpl, (%rax)
xorl %r15d, %r15d
jmp 0x1f979
cmpl $0x3, %r14d
jne 0x1f70b
movq %rbx, %rdi
movl $0xe, %esi
xorl %edx, %edx
movl %r8d, %ecx
movq %r9, %r8
callq 0x16ad7
testl %eax, %eax
jne 0x1f976
movq %rbx, %rdi
movl $0x3, %esi
xorl %edx, %edx
movl %r12d, %ecx
movq %r15, %r8
jmp 0x1f6b5
testl %r14d, %r14d
je 0x1f86e
movl %r12d, %eax
xorl $0x3, %eax
movl %r14d, %ecx
xorl $0x3, %ecx
movq %rbx, %rdi
orl %eax, %ecx
jne 0x1f8a4
movl $0xe, %esi
xorl %edx, %edx
movl %r8d, %ecx
movq %r9, %r8
callq 0x16ad7
testl %eax, %eax
jne 0x1f976
movq %rbx, %rdi
movl $0x21, %esi
movl $0x3, %edx
xorl %ecx, %ecx
movl $0xe, %r8d
xorl %r9d, %r9d
callq 0x15da2
testq %rax, %rax
je 0x1f976
orb %bpl, (%rax)
xorl %r15d, %r15d
movq %rbx, %rdi
movl $0x1, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movl $0x3, %r8d
xorl %r9d, %r9d
jmp 0x1f967
cmpl $0x40, %r14d
setge %al
cmpl %r12d, %r14d
sete %cl
orb %al, %cl
je 0x1f7e5
movq %rbx, %rdi
movl $0xe, %esi
xorl %edx, %edx
movl %r8d, %ecx
movq %r9, %r8
callq 0x16ad7
testl %eax, %eax
jne 0x1f976
movq %rbx, %rdi
movl $0x1, %esi
movl $0x3, %edx
xorl %ecx, %ecx
movl $0xf, %r8d
xorl %r9d, %r9d
callq 0x15da2
testq %rax, %rax
je 0x1f98b
movb $-0x77, (%rax)
movq %rbx, %rdi
movl $0x3, %esi
xorl %edx, %edx
movl %r12d, %ecx
movq 0x48(%rsp), %r8
callq 0x16ad7
testl %eax, %eax
jne 0x1f976
movq %rbx, %rdi
movl $0x21, %esi
movl $0x3, %edx
xorl %ecx, %ecx
movl $0xe, %r8d
xorl %r9d, %r9d
callq 0x15da2
testq %rax, %rax
je 0x1f976
orb %bpl, (%rax)
movq %rbx, %rdi
movl $0x1, %esi
movl $0xf, %edx
xorl %ecx, %ecx
movl $0x3, %r8d
xorl %r9d, %r9d
callq 0x15da2
testq %rax, %rax
je 0x1f9a5
movb $-0x77, (%rax)
testl %r14d, %r14d
jne 0x1f94f
jmp 0x1f647
testb %r12b, %r12b
js 0x1f8ef
cmpl %r14d, %r8d
je 0x1f80e
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
movl %r8d, %ecx
movq %r9, %r8
callq 0x16ad7
testl %eax, %eax
jne 0x1f976
movq %r15, %r13
movq %rbx, %rdi
movl $0x1, %esi
movl $0x3, %edx
xorl %ecx, %ecx
movl $0xe, %r8d
xorl %r9d, %r9d
callq 0x15da2
testq %rax, %rax
je 0x1f998
movb $-0x77, (%rax)
movq %rbx, %rdi
movl $0x3, %esi
xorl %edx, %edx
movl %r12d, %ecx
movq %r13, %r8
callq 0x16ad7
testl %eax, %eax
jne 0x1f976
movq %rbx, %rdi
movl $0x21, %esi
movl $0x3, %edx
xorl %ecx, %ecx
movl %r14d, %r8d
jmp 0x1f6d7
movq %rbx, %rdi
movl $0xe, %esi
xorl %edx, %edx
movl %r8d, %ecx
movq %r9, %r8
callq 0x16ad7
testl %eax, %eax
jne 0x1f976
movq %r15, %rcx
xorl %r15d, %r15d
movq %rbx, %rdi
movl $0x21, %esi
movl %r12d, %edx
movl $0xe, %r8d
jmp 0x1f8d6
cmpl $0x3f, %r14d
jg 0x1f915
movl %r14d, %esi
xorl %edx, %edx
movl %r8d, %ecx
movq %r9, %r8
callq 0x16ad7
testl %eax, %eax
jne 0x1f976
movq %r15, %rcx
xorl %r15d, %r15d
movq %rbx, %rdi
movl $0x21, %esi
movl %r12d, %edx
movl %r14d, %r8d
xorl %r9d, %r9d
callq 0x15da2
testq %rax, %rax
je 0x1f976
orb %bpl, (%rax)
jmp 0x1f979
movl %r12d, %eax
andl $0x3f, %eax
cmpl %r14d, %eax
je 0x1f720
movl %r12d, %eax
shrl $0x8, %eax
andl $0x3f, %eax
cmpl %r14d, %eax
je 0x1f720
jmp 0x1f7ee
movl $0xe, %esi
xorl %edx, %edx
movl %r8d, %ecx
movq %r9, %r8
callq 0x16ad7
testl %eax, %eax
jne 0x1f976
movq %rbx, %rdi
movl $0x21, %esi
movl %r12d, %edx
movq %r15, %rcx
movl $0xe, %r8d
xorl %r9d, %r9d
callq 0x15da2
testq %rax, %rax
je 0x1f976
orb %bpl, (%rax)
xorl %r15d, %r15d
movq %rbx, %rdi
movl $0x1, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movl %r14d, %r8d
movq %r13, %r9
callq 0x15da2
testq %rax, %rax
je 0x1f976
movb $-0x77, (%rax)
jmp 0x1f979
movl (%rbx), %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%rbx), %r15d
testl %r15d, %r15d
jne 0x1f979
jmp 0x1f766
movl (%rbx), %r15d
testl %r15d, %r15d
jne 0x1f979
jmp 0x1f83a
movl (%rbx), %r15d
testl %r15d, %r15d
jne 0x1f979
jmp 0x1f7d7