#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 */

/* Variables and functions */
scalar_t__ malloc(int);
int /*<<< orphan*/ strcat(char *, char *);
char *intToRoman(int num) {
  char *M[] = {"", "M", "MM", "MMM"};
  char *C[] = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
  char *X[] = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
  char *I[] = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
  char *s = (char *)malloc(sizeof(char) * 20);
  *s = '\0';
  strcat(s, M[num / 1000]);
  strcat(s, C[(num % 1000) / 100]);
  strcat(s, X[(num % 100) / 10]);
  strcat(s, I[(num % 10)]);
  return s;
}


x86 assembly (clang, -O0):
<intToRoman>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2bcb(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2bc8(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2bc5(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2bc2(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x80(%rbp),%rdi
lea    0x2bbb(%rip),%rsi
mov    $0x50,%edx
call   1030 <memcpy@plt>
lea    -0xd0(%rbp),%rdi
lea    0x2bf3(%rip),%rsi
mov    $0x50,%edx
call   1030 <memcpy@plt>
lea    -0x120(%rbp),%rdi
lea    0x2c2b(%rip),%rsi
mov    $0x50,%edx
call   1030 <memcpy@plt>
mov    $0x14,%edi
call   1040 <malloc@plt>
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x128(%rbp),%rdi
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cltq
mov    -0x30(%rbp,%rax,8),%rsi
call   1050 <strcat@plt>
mov    -0x128(%rbp),%rdi
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cltq
mov    -0x80(%rbp,%rax,8),%rsi
call   1050 <strcat@plt>
mov    -0x128(%rbp),%rdi
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cltq
mov    -0xd0(%rbp,%rax,8),%rsi
ff
call   1050 <strcat@plt>
mov    -0x128(%rbp),%rdi
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x120(%rbp,%rax,8),%rsi
ff
call   1050 <strcat@plt>
mov    -0x128(%rbp),%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intToRoman>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
mov    $0x14,%edi
call   1030 <malloc@plt>
mov    %rax,%r14
movb   $0x0,(%rax)
movslq %ebp,%rbp
imul   $0x10624dd3,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
movslq %eax,%rbx
lea    0xee5(%rip),%rax
movslq (%rax,%rbx,4),%rsi
add    %rax,%rsi
mov    %r14,%rdi
call   1040 <strcat@plt>
imul   $0x3e8,%ebx,%eax
mov    %ebp,%ecx
sub    %eax,%ecx
movswl %cx,%eax
imul   $0x147b,%eax,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x13,%eax
add    %ecx,%eax
cltq
lea    0xec0(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    %r14,%rdi
call   1040 <strcat@plt>
imul   $0x51eb851f,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
mov    %ebp,%ecx
sub    %eax,%ecx
movsbl %cl,%eax
imul   $0x67,%eax,%eax
movzwl %ax,%eax
movswl %ax,%ecx
shr    $0xf,%eax
shr    $0xa,%ecx
add    %al,%cl
movsbq %cl,%rax
lea    0xe9f(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    %r14,%rdi
call   1040 <strcat@plt>
imul   $0x66666667,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebp
movslq %ebp,%rax
lea    0xe93(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    %r14,%rdi
call   1040 <strcat@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"M\00"
@.str.2 = [3 x i8] c"MM\00"
@.str.3 = [4 x i8] c"MMM\00"
@__const.intToRoman.M = [4 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [2 x i8] c"C\00"
@.str.5 = [3 x i8] c"CC\00"
@.str.6 = [4 x i8] c"CCC\00"
@.str.7 = [3 x i8] c"CD\00"
@.str.8 = [2 x i8] c"D\00"
@.str.9 = [3 x i8] c"DC\00"
@.str.10 = [4 x i8] c"DCC\00"
@.str.11 = [5 x i8] c"DCCC\00"
@.str.12 = [3 x i8] c"CM\00"
@__const.intToRoman.C = [10 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i32 0, i32 0)]
@.str.13 = [2 x i8] c"X\00"
@.str.14 = [3 x i8] c"XX\00"
@.str.15 = [4 x i8] c"XXX\00"
@.str.16 = [3 x i8] c"XL\00"
@.str.17 = [2 x i8] c"L\00"
@.str.18 = [3 x i8] c"LX\00"
@.str.19 = [4 x i8] c"LXX\00"
@.str.20 = [5 x i8] c"LXXX\00"
@.str.21 = [3 x i8] c"XC\00"
@__const.intToRoman.X = [10 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i32 0, i32 0)]
@.str.22 = [2 x i8] c"I\00"
@.str.23 = [3 x i8] c"II\00"
@.str.24 = [4 x i8] c"III\00"
@.str.25 = [3 x i8] c"IV\00"
@.str.26 = [2 x i8] c"V\00"
@.str.27 = [3 x i8] c"VI\00"
@.str.28 = [4 x i8] c"VII\00"
@.str.29 = [5 x i8] c"VIII\00"
@.str.30 = [3 x i8] c"IX\00"
@__const.intToRoman.I = [10 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.30, i32 0, i32 0)]
define i8* @intToRoman(i32 %0) {
%2 = alloca i32
%3 = alloca [4 x i8*]
%4 = alloca [10 x i8*]
%5 = alloca [10 x i8*]
%6 = alloca [10 x i8*]
%7 = alloca i8*
store i32 %0, i32* %2
%8 = bitcast [4 x i8*]* %3 to i8*
%9 = bitcast [10 x i8*]* %4 to i8*
%10 = bitcast [10 x i8*]* %5 to i8*
%11 = bitcast [10 x i8*]* %6 to i8*
%12 = call i64 @malloc(i32 20)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %7
%14 = load i8*, i8** %7
store i8 0, i8* %14
%15 = load i8*, i8** %7
%16 = load i32, i32* %2
%17 = sdiv i32 %16, 1000
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 @strcat(i8* %15, i8* %20)
%22 = load i8*, i8** %7
%23 = load i32, i32* %2
%24 = srem i32 %23, 1000
%25 = sdiv i32 %24, 100
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 @strcat(i8* %22, i8* %28)
%30 = load i8*, i8** %7
%31 = load i32, i32* %2
%32 = srem i32 %31, 100
%33 = sdiv i32 %32, 10
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [10 x i8*], [10 x i8*]* %5, i64 0, i64 %34
%36 = load i8*, i8** %35
%37 = call i32 @strcat(i8* %30, i8* %36)
%38 = load i8*, i8** %7
%39 = load i32, i32* %2
%40 = srem i32 %39, 10
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [10 x i8*], [10 x i8*]* %6, i64 0, i64 %41
%43 = load i8*, i8** %42
%44 = call i32 @strcat(i8* %38, i8* %43)
%45 = load i8*, i8** %7
ret i8* %45
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"M\00"
@.str.2 = [3 x i8] c"MM\00"
@.str.3 = [4 x i8] c"MMM\00"
@reltable.intToRoman = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([1 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.intToRoman to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.intToRoman to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.intToRoman to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.intToRoman to i64)) to i32)]
@.str.4 = [2 x i8] c"C\00"
@.str.5 = [3 x i8] c"CC\00"
@.str.6 = [4 x i8] c"CCC\00"
@.str.7 = [3 x i8] c"CD\00"
@.str.8 = [2 x i8] c"D\00"
@.str.9 = [3 x i8] c"DC\00"
@.str.10 = [4 x i8] c"DCC\00"
@.str.11 = [5 x i8] c"DCCC\00"
@.str.12 = [3 x i8] c"CM\00"
@reltable.intToRoman.31 = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([1 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.31 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.4 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.31 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.31 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.6 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.31 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.7 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.31 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.8 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.31 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.9 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.31 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.10 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.31 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.11 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.31 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.12 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.31 to i64)) to i32)]
@.str.13 = [2 x i8] c"X\00"
@.str.14 = [3 x i8] c"XX\00"
@.str.15 = [4 x i8] c"XXX\00"
@.str.16 = [3 x i8] c"XL\00"
@.str.17 = [2 x i8] c"L\00"
@.str.18 = [3 x i8] c"LX\00"
@.str.19 = [4 x i8] c"LXX\00"
@.str.20 = [5 x i8] c"LXXX\00"
@.str.21 = [3 x i8] c"XC\00"
@reltable.intToRoman.32 = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([1 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.32 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.13 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.32 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.14 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.32 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.15 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.32 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.16 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.32 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.17 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.32 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.18 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.32 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.19 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.32 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.20 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.32 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.21 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.32 to i64)) to i32)]
@.str.22 = [2 x i8] c"I\00"
@.str.23 = [3 x i8] c"II\00"
@.str.24 = [4 x i8] c"III\00"
@.str.25 = [3 x i8] c"IV\00"
@.str.26 = [2 x i8] c"V\00"
@.str.27 = [3 x i8] c"VI\00"
@.str.28 = [4 x i8] c"VII\00"
@.str.29 = [5 x i8] c"VIII\00"
@.str.30 = [3 x i8] c"IX\00"
@reltable.intToRoman.33 = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([1 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.33 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.22 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.33 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.23 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.33 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.24 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.33 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.25 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.33 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.26 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.33 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.27 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.33 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.28 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.33 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.29 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.33 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.30 to i64), i64 ptrtoint ([10 x i32]* @reltable.intToRoman.33 to i64)) to i32)]
define i8* @intToRoman(i32 %0) {
%2 = tail call i64 @malloc(i32 20)
%3 = inttoptr i64 %2 to i8*
store i8 0, i8* %3
%4 = sdiv i32 %0, 1000
%5 = sext i32 %4 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.intToRoman to i8*), i64 %6)
%8 = tail call i32 @strcat(i8* %3, i8* %7)
%9 = srem i32 %0, 1000
%10 = trunc i32 %9 to i16
%11 = sdiv i16 %10, 100
%12 = sext i16 %11 to i64
%13 = shl i64 %12, 2
%14 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.intToRoman.31 to i8*), i64 %13)
%15 = tail call i32 @strcat(i8* %3, i8* %14)
%16 = srem i32 %0, 100
%17 = trunc i32 %16 to i8
%18 = sdiv i8 %17, 10
%19 = sext i8 %18 to i64
%20 = shl i64 %19, 2
%21 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.intToRoman.32 to i8*), i64 %20)
%22 = tail call i32 @strcat(i8* %3, i8* %21)
%23 = srem i32 %0, 10
%24 = sext i32 %23 to i64
%25 = shl i64 %24, 2
%26 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.intToRoman.33 to i8*), i64 %25)
%27 = tail call i32 @strcat(i8* %3, i8* %26)
ret i8* %3
}