#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char const *,
                           char const *, char *, char const *, int);
char *get_asm_type(int);
void gen_move(FILE *ftarget, const char *dst, const char *src, int offset,
              int size) {
  const char *instr = size < 4 ? "movsx" : "mov";
  fprintf(ftarget, "  %s %s, %s PTR [%s]%+d\n", instr, dst, get_asm_type(size),
          src, offset);
}


x86 assembly (clang, -O0):
<gen_move>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x20(%rbp),%edx
lea    0xec1(%rip),%rax
lea    0xeb4(%rip),%rcx
cmp    $0x4,%edx
cmovl  %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%edi
call   1040 <get_asm_type@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    %rax,%r8
mov    -0x18(%rbp),%r9
mov    -0x1c(%rbp),%eax
lea    0xe76(%rip),%rsi
mov    %eax,(%rsp)
call   1030 <fprintf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_move>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r12d
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
cmp    $0x4,%r8d
lea    0xebd(%rip),%rax
lea    0xebc(%rip),%rbp
cmovl  %rax,%rbp
mov    %r8d,%edi
call   1040 <get_asm_type@plt>
mov    %r12d,(%rsp)
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %r15,%rcx
mov    %rax,%r8
mov    %r14,%r9
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"movsx\00"
@.str.1 = [4 x i8] c"mov\00"
@.str.2 = [25 x i8] c" %s %s, %s PTR [%s]%+d\0A\00"
define void @gen_move(i32* %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i32* %0, i32** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i32, i32* %10
%13 = icmp slt i32 %12, 4
%14 = zext i1 %13 to i64
%15 = select i1 %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
store i8* %15, i8** %11
%16 = load i32*, i32** %6
%17 = load i8*, i8** %11
%18 = load i8*, i8** %7
%19 = load i32, i32* %10
%20 = call i8* @get_asm_type(i32 %19)
%21 = load i8*, i8** %8
%22 = load i32, i32* %9
%23 = call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %17, i8* %18, i8* %20, i8* %21, i32 %22)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"movsx\00"
@.str.1 = [4 x i8] c"mov\00"
@.str.2 = [25 x i8] c" %s %s, %s PTR [%s]%+d\0A\00"
define void @gen_move(i32* nocapture %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = icmp slt i32 %4, 4
%7 = select i1 %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%8 = tail call i8* @get_asm_type(i32 %4)
%9 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %7, i8* %1, i8* %8, i8* %2, i32 %3)
ret void
}