// File: /workspace/github_c_makefile_star2_O2/lucvoo[P]sparse-dev/compile-i386.c
// Function: emit_move
static void emit_move(struct storage *src, struct storage *dest,
		      struct symbol *ctype, const char *comment)
{
	unsigned int bits;
	unsigned int is_signed;
	unsigned int is_dest = (src->type == STOR_REG);
	const char *opname;

	if (ctype) {
		bits = ctype->bit_size;
		is_signed = is_signed_type(ctype);
	} else {
		bits = 32;
		is_signed = 0;
	}

	/*
	 * Are we moving from a register to a register?
	 * Make the new reg to be the "cache".
	 */
	if ((dest->type == STOR_REG) && (src->type == STOR_REG)) {
		struct storage *backing;

reg_reg_move:
		if (dest == src)
			return;

		backing = src->reg->contains;
		if (backing) {
			/* Is it still valid? */
			if (backing->reg != src->reg)
				backing = NULL;
			else
				backing->reg = dest->reg;
		}
		dest->reg->contains = backing;
		insn("mov", src, dest, NULL);
		return;
	}

	/*
	 * Are we moving to a register from a non-reg?
	 *
	 * See if we have the non-reg source already cached
	 * in a register..
	 */
	if (dest->type == STOR_REG) {
		if (src->reg) {
			struct reg_info *info = src->reg;
			if (info->contains == src) {
				src = reginfo_reg(info);
				goto reg_reg_move;
			}
		}
		dest->reg->contains = src;
		src->reg = dest->reg;
	}

	if (src->type == STOR_REG) {
		/* We could just mark the register dirty here and do lazy store.. */
		src->reg->contains = dest;
		dest->reg = src->reg;
	}

	if ((bits == 8) || (bits == 16)) {
		if (is_dest)
			opname = "mov";
		else
			opname = is_signed ? "movsx" : "movzx";
	} else
		opname = "mov";

	insn(opbits(opname, bits), src, dest, comment);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rcx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movl (%rdi), %r12d
testq %rdx, %rdx
je 0x3aa40
movl 0x50(%rdx), %ebp
movq %rdx, %rdi
callq 0x3ab3d
testl %eax, %eax
leaq 0xd414(%rip), %rax      # 0x47e47
leaq 0xd407(%rip), %rdi      # 0x47e41
cmoveq %rax, %rdi
jmp 0x3aa4a
pushq $0x20
popq %rbp
leaq 0xd3fd(%rip), %rdi      # 0x47e47
cmpl $0x3, (%rbx)
movl %r12d, %eax
jne 0x3aaa1
cmpl $0x3, %r12d
jne 0x3aa7f
cmpq %rbx, %r14
je 0x3aaf1
movq 0x10(%r14), %rcx
movq 0x8(%rcx), %rax
testq %rax, %rax
je 0x3aa78
cmpq %rcx, 0x10(%rax)
je 0x3ab11
xorl %eax, %eax
jmp 0x3ab19
movq 0x10(%r14), %rax
testq %rax, %rax
je 0x3aa8e
cmpq %r14, 0x8(%rax)
je 0x3aafa
movq 0x10(%rbx), %rax
movq %r14, 0x8(%rax)
movq 0x10(%rbx), %rax
movq %rax, 0x10(%r14)
movl (%r14), %eax
cmpl $0x3, %eax
jne 0x3aab6
movq 0x10(%r14), %rax
movq %rbx, 0x8(%rax)
movq 0x10(%r14), %rax
movq %rax, 0x10(%rbx)
cmpl $0x10, %ebp
je 0x3aac0
cmpl $0x8, %ebp
jne 0x3aad1
cmpl $0x3, %r12d
leaq 0xd372(%rip), %rax      # 0x47e3d
cmoveq %rax, %rdi
jmp 0x3aad8
leaq 0xd365(%rip), %rdi      # 0x47e3d
movl %ebp, %esi
callq 0x3ab5d
leaq 0x55f0a(%rip), %rdi     # 0x909f0
movq %r14, %rsi
movq %rbx, %rdx
movq %r15, %rcx
jmp 0x3ab30
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movzbl 0x10(%rax), %eax
imulq $0x30, %rax, %rax
leaq 0x28997(%rip), %r14     # 0x634a0
addq %rax, %r14
jmp 0x3aa58
movq 0x10(%rbx), %rcx
movq %rcx, 0x10(%rax)
movq 0x10(%rbx), %rcx
movq %rax, 0x8(%rcx)
leaq 0xd315(%rip), %rdi      # 0x47e3d
movq %r14, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x3a954