// File: /workspace/github_c_makefile_star2_O3/mmcco[P]sljit/sljit_src/sljitNativeX86_common.c
// Function: emit_mov
static int emit_mov(struct sljit_compiler *compiler,
	int dst, long dstw,
	int src, long srcw)
{
	u_char* inst;

	if (dst == SLJIT_UNUSED) {
		/* No destination, doesn't need to setup flags. */
		if (src & SLJIT_MEM) {
			inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src, srcw);
			FAIL_IF(!inst);
			*inst = MOV_r_rm;
		}
		return SLJIT_SUCCESS;
	}
	if (FAST_IS_REG(src)) {
		inst = emit_x86_instruction(compiler, 1, src, 0, dst, dstw);
		FAIL_IF(!inst);
		*inst = MOV_rm_r;
		return SLJIT_SUCCESS;
	}
	if (src & SLJIT_IMM) {
		if (FAST_IS_REG(dst)) {
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
			return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw);
#else
			if (!compiler->mode32) {
				if (NOT_HALFWORD(srcw))
					return emit_load_imm64(compiler, dst, srcw);
			}
			else
				return emit_do_imm32(compiler, (reg_map[dst] >= 8) ? REX_B : 0, MOV_r_i32 + reg_lmap[dst], srcw);
#endif
		}
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
		if (!compiler->mode32 && NOT_HALFWORD(srcw)) {
			FAIL_IF(emit_load_imm64(compiler, TMP_REG2, srcw));
			inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, dst, dstw);
			FAIL_IF(!inst);
			*inst = MOV_rm_r;
			return SLJIT_SUCCESS;
		}
#endif
		inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, dstw);
		FAIL_IF(!inst);
		*inst = MOV_rm_i32;
		return SLJIT_SUCCESS;
	}
	if (FAST_IS_REG(dst)) {
		inst = emit_x86_instruction(compiler, 1, dst, 0, src, srcw);
		FAIL_IF(!inst);
		*inst = MOV_r_rm;
		return SLJIT_SUCCESS;
	}

	/* Memory to memory move. Requires two instruction. */
	inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src, srcw);
	FAIL_IF(!inst);
	*inst = MOV_r_rm;
	inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
	FAIL_IF(!inst);
	*inst = MOV_rm_r;
	return SLJIT_SUCCESS;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r9
movl %ecx, %r8d
movq %rdi, %rbx
testl %esi, %esi
je 0x16b24
movq %rdx, %r12
movl %esi, %r15d
cmpl $0x3f, %r8d
jg 0x16b42
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x1, %esi
movl %r8d, %edx
xorl %ecx, %ecx
movl %r15d, %r8d
movq %r12, %r9
callq 0x15da2
testq %rax, %rax
je 0x16c79
movb $-0x77, (%rax)
jmp 0x16c7c
xorl %r14d, %r14d
testb %r8b, %r8b
jns 0x16c7c
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x1, %esi
movl $0xe, %edx
jmp 0x16b5c
testb $0x40, %r8b
jne 0x16b74
cmpl $0x3f, %r15d
jg 0x16bc0
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
xorl %ecx, %ecx
callq 0x15da2
testq %rax, %rax
je 0x16c79
movb $-0x75, (%rax)
jmp 0x16c7c
movl 0x70(%rbx), %eax
cmpl $0x3f, %r15d
jg 0x16bf5
testl %eax, %eax
je 0x16c30
movslq %r15d, %rax
leaq 0xc661(%rip), %rcx      # 0x231f0
movb (%rax,%rcx), %al
addb $-0x48, %al
xorl %ecx, %ecx
movl $0x10ef0, %edx          # imm = 0x10EF0
btq %r15, %rdx
movl $0x41, %esi
cmovael %ecx, %esi
movzbl %al, %edx
movq %rbx, %rdi
movq %r9, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x1f57c
movq %rbx, %rdi
movl $0x1, %esi
movl $0xe, %edx
xorl %ecx, %ecx
callq 0x15da2
testq %rax, %rax
je 0x16c79
movb $-0x75, (%rax)
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x1, %esi
movl $0xe, %edx
jmp 0x16b06
testl %eax, %eax
setne %al
movslq %r9d, %rcx
cmpq %r9, %rcx
sete %cl
orb %al, %cl
jne 0x16c51
movq %rbx, %rdi
movl $0xf, %esi
movq %r9, %rdx
callq 0x1683c
testl %eax, %eax
jne 0x16c79
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x1, %esi
movl $0xf, %edx
jmp 0x16b06
movslq %r9d, %rax
cmpq %r9, %rax
je 0x16c51
movq %rbx, %rdi
movl %r15d, %esi
movq %r9, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x1683c
movq %rbx, %rdi
movl $0x1, %esi
movl $0x40, %edx
movq %r9, %rcx
movl %r15d, %r8d
movq %r12, %r9
callq 0x15da2
testq %rax, %rax
je 0x16c79
movb $-0x39, (%rax)
xorl %r14d, %r14d
jmp 0x16c7c
movl (%rbx), %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq