// File: /workspace/github_c_makefile_star2_O1/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 0x16b49
movq %rdx, %r12
movl %esi, %r15d
cmpl $0x3f, %r8d
jg 0x16b67
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x1, %esi
movl %r8d, %edx
xorl %ecx, %ecx
movl %r15d, %r8d
movq %r12, %r9
callq 0x15e07
testq %rax, %rax
je 0x16c99
movb $-0x77, (%rax)
jmp 0x16c9c
xorl %r14d, %r14d
testb %r8b, %r8b
jns 0x16c9c
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x1, %esi
movl $0xe, %edx
jmp 0x16b81
testb $0x40, %r8b
jne 0x16b99
cmpl $0x3f, %r15d
jg 0x16be4
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
xorl %ecx, %ecx
callq 0x15e07
testq %rax, %rax
je 0x16c99
movb $-0x75, (%rax)
jmp 0x16c9c
cmpl $0x3f, %r15d
jg 0x16c3a
cmpl $0x0, 0x70(%rbx)
je 0x16c19
movslq %r15d, %rax
leaq 0xc56d(%rip), %rcx      # 0x23120
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 0x1ef79
movq %rbx, %rdi
movl $0x1, %esi
movl $0xe, %edx
xorl %ecx, %ecx
callq 0x15e07
testq %rax, %rax
je 0x16c99
movb $-0x75, (%rax)
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x1, %esi
movl $0xe, %edx
jmp 0x16b2b
movslq %r9d, %rax
cmpq %r9, %rax
je 0x16c3a
movq %rbx, %rdi
movl %r15d, %esi
movq %r9, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x16832
movslq %r9d, %rax
cmpq %r9, %rax
je 0x16c71
cmpl $0x0, 0x70(%rbx)
jne 0x16c71
movq %rbx, %rdi
movl $0xf, %esi
movq %r9, %rdx
callq 0x16832
testl %eax, %eax
jne 0x16c99
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x1, %esi
movl $0xf, %edx
jmp 0x16b2b
movq %rbx, %rdi
movl $0x1, %esi
movl $0x40, %edx
movq %r9, %rcx
movl %r15d, %r8d
movq %r12, %r9
callq 0x15e07
testq %rax, %rax
je 0x16c99
movb $-0x39, (%rax)
xorl %r14d, %r14d
jmp 0x16c9c
movl (%rbx), %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq