#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 */
int /*<<< orphan*/ printf(char *, ...);
void toRoman(int num) {
  static char *roman[][10] = {"",     "I",    "II",  "III", "IV",   "V",  "VI",
                              "VII",  "VIII", "IX",  "",    "X",    "XX", "XXX",
                              "XL",   "L",    "LX",  "LXX", "LXXX", "XC", "",
                              "C",    "CC",   "CCC", "CD",  "D",    "DC", "DCC",
                              "DCCC", "CM",   "",    "M",   "MM",   "MMM"};
  int i, j, n;
  printf("%d = ", num);
  for (j = 0, i = 10000; j < 4; ++j, i /= 10) {
    n = (num % i) / (i / 10);
    printf("%s", roman[3 - j][n]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<toRoman>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xf15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x2710,-0x8(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    11af <toRoman+0x9f>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    $0x3,%eax
sub    -0xc(%rbp),%eax
movslq %eax,%rcx
lea    0x2eba(%rip),%rax
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    113a <toRoman+0x2a>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<toRoman>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%ebx
lea    0xf0c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movslq %ebx,%rbx
imul   $0x68db8bad,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
mov    %ebx,%ecx
sub    %eax,%ecx
movswl %cx,%eax
imul   $0xffff8313,%eax,%eax
shr    $0x10,%eax
add    %ecx,%eax
movzwl %ax,%eax
movswl %ax,%ecx
shr    $0xf,%eax
sar    $0x9,%ecx
add    %eax,%ecx
movswq %cx,%rax
lea    0x2b61(%rip),%r15
mov    0xf0(%r15,%rax,8),%rsi
lea    0xeb2(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
imul   $0x10624dd3,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x26,%rax
add    %ecx,%eax
imul   $0x3e8,%eax,%eax
mov    %ebx,%ecx
sub    %eax,%ecx
movswl %cx,%eax
imul   $0x147b,%eax,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x13,%eax
add    %ecx,%eax
cltq
mov    0xa0(%r15,%rax,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
mov    %ebx,%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
mov    0x50(%r15,%rax,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
movslq %ebx,%rax
mov    (%r15,%rax,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@toRoman.roman = internal global [4 x [10 x i8*]] [[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.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), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0)], [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.10, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i32 0, i32 0)], [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.19, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.27, i32 0, i32 0)], [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.28, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.30, i32 0, i32 0), i8* null, i8* null, i8* null, i8* null, i8* null, i8* null]]
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"I\00"
@.str.2 = [3 x i8] c"II\00"
@.str.3 = [4 x i8] c"III\00"
@.str.4 = [3 x i8] c"IV\00"
@.str.5 = [2 x i8] c"V\00"
@.str.6 = [3 x i8] c"VI\00"
@.str.7 = [4 x i8] c"VII\00"
@.str.8 = [5 x i8] c"VIII\00"
@.str.9 = [3 x i8] c"IX\00"
@.str.10 = [2 x i8] c"X\00"
@.str.11 = [3 x i8] c"XX\00"
@.str.12 = [4 x i8] c"XXX\00"
@.str.13 = [3 x i8] c"XL\00"
@.str.14 = [2 x i8] c"L\00"
@.str.15 = [3 x i8] c"LX\00"
@.str.16 = [4 x i8] c"LXX\00"
@.str.17 = [5 x i8] c"LXXX\00"
@.str.18 = [3 x i8] c"XC\00"
@.str.19 = [2 x i8] c"C\00"
@.str.20 = [3 x i8] c"CC\00"
@.str.21 = [4 x i8] c"CCC\00"
@.str.22 = [3 x i8] c"CD\00"
@.str.23 = [2 x i8] c"D\00"
@.str.24 = [3 x i8] c"DC\00"
@.str.25 = [4 x i8] c"DCC\00"
@.str.26 = [5 x i8] c"DCCC\00"
@.str.27 = [3 x i8] c"CM\00"
@.str.28 = [2 x i8] c"M\00"
@.str.29 = [3 x i8] c"MM\00"
@.str.30 = [4 x i8] c"MMM\00"
@.str.31 = [6 x i8] c"%d = \00"
@.str.32 = [3 x i8] c"%s\00"
@.str.33 = [2 x i8] c"\0A\00"
define void @toRoman(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.31, i64 0, i64 0), i32 %6)
store i32 0, i32* %4
store i32 10000, i32* %3
br label %8
8: ; preds = %27, %1
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %32
11: ; preds = %8
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = srem i32 %12, %13
%15 = load i32, i32* %3
%16 = sdiv i32 %15, 10
%17 = sdiv i32 %14, %16
store i32 %17, i32* %5
%18 = load i32, i32* %4
%19 = sub nsw i32 3, %18
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [4 x [10 x i8*]], [4 x [10 x i8*]]* @toRoman.roman, i64 0, i64 %20
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [10 x i8*], [10 x i8*]* %21, i64 0, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.32, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %11
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
%30 = load i32, i32* %3
%31 = sdiv i32 %30, 10
store i32 %31, i32* %3
br label %8
32: ; preds = %8
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.33, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@toRoman.roman = internal unnamed_addr constant [4 x [10 x i8*]] [[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.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), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0)], [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.10, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i32 0, i32 0)], [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.19, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.27, i32 0, i32 0)], [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.28, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.30, i32 0, i32 0), i8* null, i8* null, i8* null, i8* null, i8* null, i8* null]]
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"I\00"
@.str.2 = [3 x i8] c"II\00"
@.str.3 = [4 x i8] c"III\00"
@.str.4 = [3 x i8] c"IV\00"
@.str.5 = [2 x i8] c"V\00"
@.str.6 = [3 x i8] c"VI\00"
@.str.7 = [4 x i8] c"VII\00"
@.str.8 = [5 x i8] c"VIII\00"
@.str.9 = [3 x i8] c"IX\00"
@.str.10 = [2 x i8] c"X\00"
@.str.11 = [3 x i8] c"XX\00"
@.str.12 = [4 x i8] c"XXX\00"
@.str.13 = [3 x i8] c"XL\00"
@.str.14 = [2 x i8] c"L\00"
@.str.15 = [3 x i8] c"LX\00"
@.str.16 = [4 x i8] c"LXX\00"
@.str.17 = [5 x i8] c"LXXX\00"
@.str.18 = [3 x i8] c"XC\00"
@.str.19 = [2 x i8] c"C\00"
@.str.20 = [3 x i8] c"CC\00"
@.str.21 = [4 x i8] c"CCC\00"
@.str.22 = [3 x i8] c"CD\00"
@.str.23 = [2 x i8] c"D\00"
@.str.24 = [3 x i8] c"DC\00"
@.str.25 = [4 x i8] c"DCC\00"
@.str.26 = [5 x i8] c"DCCC\00"
@.str.27 = [3 x i8] c"CM\00"
@.str.28 = [2 x i8] c"M\00"
@.str.29 = [3 x i8] c"MM\00"
@.str.30 = [4 x i8] c"MMM\00"
@.str.31 = [6 x i8] c"%d = \00"
@.str.32 = [3 x i8] c"%s\00"
define void @toRoman(i32 %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.31, i64 0, i64 0), i32 %0)
%3 = srem i32 %0, 10000
%4 = trunc i32 %3 to i16
%5 = sdiv i16 %4, 1000
%6 = sext i16 %5 to i64
%7 = getelementptr inbounds [4 x [10 x i8*]], [4 x [10 x i8*]]* @toRoman.roman, i64 0, i64 3, i64 %6
%8 = load i8*, i8** %7
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.32, i64 0, i64 0), i8* %8)
%10 = srem i32 %0, 1000
%11 = trunc i32 %10 to i16
%12 = sdiv i16 %11, 100
%13 = sext i16 %12 to i64
%14 = getelementptr inbounds [4 x [10 x i8*]], [4 x [10 x i8*]]* @toRoman.roman, i64 0, i64 2, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.32, i64 0, i64 0), i8* %15)
%17 = srem i32 %0, 100
%18 = trunc i32 %17 to i8
%19 = sdiv i8 %18, 10
%20 = sext i8 %19 to i64
%21 = getelementptr inbounds [4 x [10 x i8*]], [4 x [10 x i8*]]* @toRoman.roman, i64 0, i64 1, i64 %20
%22 = load i8*, i8** %21
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.32, i64 0, i64 0), i8* %22)
%24 = srem i32 %0, 10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x [10 x i8*]], [4 x [10 x i8*]]* @toRoman.roman, i64 0, i64 0, i64 %25
%27 = load i8*, i8** %26
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.32, i64 0, i64 0), i8* %27)
%29 = tail call i32 @putchar(i32 10)
ret void
}