// File: /workspace/github_c_makefile_star2_O2/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, %r12
movl %edx, %r14d
movl %esi, %ebp
movq %rdi, %rbx
movq 0x48(%rsp), %r15
movl 0x40(%rsp), %r13d
testb $0x40, %r13b
sete %al
cmpl $0x3, %r13d
setne %cl
testb %al, %cl
jne 0x1ce8a
cmpl %r8d, %r14d
setne %al
cmpq %r9, %r12
setne %cl
orb %al, %cl
jne 0x1cebf
pushq $0x21
popq %rsi
movq %rbx, %rdi
movl %r13d, %edx
movq %r15, %rcx
movl %r14d, %r8d
movq %r12, %r9
callq 0x14061
testq %rax, %rax
je 0x1d13b
orb %bpl, (%rax)
xorl %r15d, %r15d
jmp 0x1d13e
cmpl $0x3, %r14d
jne 0x1cf2d
pushq $0xe
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
movl %r8d, %ecx
movq %r9, %r8
callq 0x14d14
testl %eax, %eax
jne 0x1d13b
pushq $0x3
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
movl %r13d, %ecx
movq %r15, %r8
jmp 0x1ceea
testl %r14d, %r14d
je 0x1d04e
movl %r13d, %eax
xorl $0x3, %eax
movl %r14d, %ecx
xorl $0x3, %ecx
orl %eax, %ecx
jne 0x1d07e
pushq $0xe
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
movl %r8d, %ecx
movq %r9, %r8
callq 0x14d14
testl %eax, %eax
jne 0x1d13b
xorl %r15d, %r15d
pushq $0x21
popq %rsi
pushq $0x3
popq %rdx
pushq $0xe
popq %r8
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %r9d, %r9d
callq 0x14061
testq %rax, %rax
je 0x1d13b
orb %bpl, (%rax)
pushq $0x3
popq %rsi
pushq $0xe
popq %rcx
movq %rbx, %rdi
xorl %edx, %edx
jmp 0x1d12f
cmpl $0x40, %r14d
setge %al
cmpl %r13d, %r14d
sete %cl
orb %al, %cl
je 0x1cfd9
pushq $0xe
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
movl %r8d, %ecx
movq %r9, %r8
callq 0x14d14
testl %eax, %eax
jne 0x1d13b
pushq $0xf
popq %rsi
pushq $0x3
popq %rcx
movq %rbx, %rdi
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x14d14
testl %eax, %eax
jne 0x1d13b
pushq $0x3
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
movl %r13d, %ecx
movq %r15, %r8
callq 0x14d14
testl %eax, %eax
jne 0x1d13b
pushq $0x21
popq %rsi
pushq $0x3
popq %rdx
pushq $0xe
popq %r8
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %r9d, %r9d
callq 0x14061
testq %rax, %rax
je 0x1d13b
orb %bpl, (%rax)
xorl %r15d, %r15d
pushq $0x3
popq %rsi
pushq $0xf
popq %rcx
movq %rbx, %rdi
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x14d14
testl %eax, %eax
jne 0x1d13b
jmp 0x1d123
testb %r13b, %r13b
js 0x1d0c3
cmpl %r14d, %r8d
je 0x1d002
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
movl %r8d, %ecx
movq %r9, %r8
callq 0x14d14
testl %eax, %eax
jne 0x1d13b
pushq $0xe
popq %rsi
pushq $0x3
popq %rcx
movq %rbx, %rdi
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x14d14
testl %eax, %eax
jne 0x1d13b
pushq $0x3
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
movl %r13d, %ecx
movq %r15, %r8
callq 0x14d14
testl %eax, %eax
jne 0x1d13b
xorl %r15d, %r15d
pushq $0x21
popq %rsi
pushq $0x3
popq %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
movl %r14d, %r8d
jmp 0x1cf09
pushq $0xe
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
movl %r8d, %ecx
movq %r9, %r8
callq 0x14d14
testl %eax, %eax
jne 0x1d13b
movq %r15, %rcx
xorl %r15d, %r15d
pushq $0x21
popq %rsi
pushq $0xe
popq %r8
movq %rbx, %rdi
movl %r13d, %edx
jmp 0x1d0b1
cmpl $0x3f, %r14d
jg 0x1d0e9
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
movl %r8d, %ecx
movq %r9, %r8
callq 0x14d14
testl %eax, %eax
jne 0x1d13b
movq %r15, %rcx
xorl %r15d, %r15d
pushq $0x21
popq %rsi
movq %rbx, %rdi
movl %r13d, %edx
movl %r14d, %r8d
xorl %r9d, %r9d
callq 0x14061
testq %rax, %rax
je 0x1d13b
orb %bpl, (%rax)
jmp 0x1d13e
movl %r13d, %eax
andl $0x3f, %eax
cmpl %r14d, %eax
je 0x1cf42
movl %r13d, %eax
shrl $0x8, %eax
andl $0x3f, %eax
cmpl %r14d, %eax
je 0x1cf42
jmp 0x1cfe2
pushq $0xe
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
movl %r8d, %ecx
movq %r9, %r8
callq 0x14d14
testl %eax, %eax
jne 0x1d13b
movq %r15, %rcx
xorl %r15d, %r15d
pushq $0x21
popq %rsi
pushq $0xe
popq %r8
movq %rbx, %rdi
movl %r13d, %edx
xorl %r9d, %r9d
callq 0x14061
testq %rax, %rax
je 0x1d13b
orb %bpl, (%rax)
pushq $0xe
popq %rcx
movq %rbx, %rdi
movl %r14d, %esi
movq %r12, %rdx
xorl %r8d, %r8d
callq 0x14d14
testl %eax, %eax
je 0x1d13e
movl (%rbx), %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq