#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 arabic) {
  if (arabic / 1000 == 1) {
    printf("m");
  } else if (arabic / 1000 > 1) {
    printf("%dm", arabic / 1000);
  }
  arabic %= 1000;
  if (arabic / 100 == 1) {
    printf("c");
  } else if (arabic / 100 > 1) {
    printf("%dc", arabic / 100);
  }
  arabic %= 100;
  if (arabic / 10 == 1) {
    printf("m");
  } else if (arabic / 10 > 1) {
    printf("%dm", arabic / 10);
  }
  arabic %= 10;
  if (arabic / 1 == 1) {
    printf("m");
  } else if (arabic / 1 > 1) {
    printf("%dm", arabic / 1);
  }
  arabic %= 1;
  printf("\n");
}


x86 assembly (clang, -O0):
<toroman>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x1,%eax
jne    1142 <toroman+0x32>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1176 <toroman+0x66>
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x1,%eax
jle    1171 <toroman+0x61>
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1176 <toroman+0x66>
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x1,%eax
jne    11ab <toroman+0x9b>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11df <toroman+0xcf>
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x1,%eax
jle    11da <toroman+0xca>
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11df <toroman+0xcf>
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x1,%eax
jne    1214 <toroman+0x104>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1248 <toroman+0x138>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x1,%eax
jle    1243 <toroman+0x133>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1248 <toroman+0x138>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x1,%ecx
cltd
idiv   %ecx
cmp    $0x1,%eax
jne    127d <toroman+0x16d>
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b1 <toroman+0x1a1>
mov    -0x4(%rbp),%eax
mov    $0x1,%ecx
cltd
idiv   %ecx
cmp    $0x1,%eax
jle    12ac <toroman+0x19c>
mov    -0x4(%rbp),%eax
mov    $0x1,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xd5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b1 <toroman+0x1a1>
mov    -0x4(%rbp),%eax
mov    $0x1,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<toroman>:
push   %rbp
push   %rbx
push   %rax
movslq %edi,%rax
imul   $0x10624dd3,%rax,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rsi
add    %ecx,%esi
imul   $0x3e8,%esi,%ecx
mov    %eax,%ebx
sub    %ecx,%ebx
add    $0xfffffc18,%eax
cmp    $0x3e7,%eax
ja     115c <toroman+0x3c>
mov    $0x6d,%edi
call   1030 <putchar@plt>
jmp    1172 <toroman+0x52>
cmp    $0x7d0,%edi
jl     1172 <toroman+0x52>
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movswl %bx,%eax
imul   $0x147b,%eax,%esi
mov    %esi,%eax
shr    $0x1f,%eax
sar    $0x13,%esi
add    %eax,%esi
imul   $0x64,%esi,%eax
mov    %ebx,%ebp
sub    %eax,%ebp
lea    -0x64(%rbx),%eax
cmp    $0x63,%eax
ja     11a0 <toroman+0x80>
mov    $0x63,%edi
call   1030 <putchar@plt>
jmp    11b6 <toroman+0x96>
cmp    $0xc8,%ebx
jl     11b6 <toroman+0x96>
lea    0xe55(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl %bpl,%ebx
imul   $0x67,%ebx,%eax
movzwl %ax,%ecx
movswl %cx,%eax
shr    $0xf,%ecx
shr    $0xa,%eax
add    %cl,%al
movzbl %al,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%bl
lea    -0xa(%rbp),%ecx
cmp    $0x9,%cx
ja     11ea <toroman+0xca>
mov    $0x6d,%edi
call   1030 <putchar@plt>
jmp    1201 <toroman+0xe1>
cmp    $0x14,%bp
jl     1201 <toroman+0xe1>
movsbl %al,%esi
lea    0xe06(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%bl
jne    1212 <toroman+0xf2>
mov    $0x6d,%edi
call   1030 <putchar@plt>
jmp    1225 <toroman+0x105>
jle    1225 <toroman+0x105>
movsbl %bl,%esi
lea    0xde2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"m\00"
@.str.1 = [4 x i8] c"%dm\00"
@.str.2 = [2 x i8] c"c\00"
@.str.3 = [4 x i8] c"%dc\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @toroman(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sdiv i32 %3, 1000
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %17
8: ; preds = %1
%9 = load i32, i32* %2
%10 = sdiv i32 %9, 1000
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i32, i32* %2
%14 = sdiv i32 %13, 1000
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %12, %8
br label %17
17: ; preds = %16, %6
%18 = load i32, i32* %2
%19 = srem i32 %18, 1000
store i32 %19, i32* %2
%20 = load i32, i32* %2
%21 = sdiv i32 %20, 100
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %34
25: ; preds = %17
%26 = load i32, i32* %2
%27 = sdiv i32 %26, 100
%28 = icmp sgt i32 %27, 1
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load i32, i32* %2
%31 = sdiv i32 %30, 100
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %29, %25
br label %34
34: ; preds = %33, %23
%35 = load i32, i32* %2
%36 = srem i32 %35, 100
store i32 %36, i32* %2
%37 = load i32, i32* %2
%38 = sdiv i32 %37, 10
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %42
40: ; preds = %34
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %51
42: ; preds = %34
%43 = load i32, i32* %2
%44 = sdiv i32 %43, 10
%45 = icmp sgt i32 %44, 1
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = load i32, i32* %2
%48 = sdiv i32 %47, 10
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %46, %42
br label %51
51: ; preds = %50, %40
%52 = load i32, i32* %2
%53 = srem i32 %52, 10
store i32 %53, i32* %2
%54 = load i32, i32* %2
%55 = sdiv i32 %54, 1
%56 = icmp eq i32 %55, 1
br i1 %56, label %57, label %59
57: ; preds = %51
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %68
59: ; preds = %51
%60 = load i32, i32* %2
%61 = sdiv i32 %60, 1
%62 = icmp sgt i32 %61, 1
br i1 %62, label %63, label %67
63: ; preds = %59
%64 = load i32, i32* %2
%65 = sdiv i32 %64, 1
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %65)
br label %67
67: ; preds = %63, %59
br label %68
68: ; preds = %67, %57
%69 = load i32, i32* %2
%70 = srem i32 %69, 1
store i32 %70, i32* %2
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%dm\00"
@.str.3 = [4 x i8] c"%dc\00"
define void @toroman(i32 %0) {
%2 = sdiv i32 %0, 1000
%3 = srem i32 %0, 1000
%4 = add i32 %0, -1000
%5 = icmp ult i32 %4, 1000
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @putchar(i32 109)
br label %12
8: ; preds = %1
%9 = icmp sgt i32 %0, 1999
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %2)
br label %12
12: ; preds = %8, %10, %6
%13 = trunc i32 %3 to i16
%14 = sdiv i16 %13, 100
%15 = srem i16 %13, 100
%16 = sext i16 %14 to i32
%17 = add nsw i32 %3, -100
%18 = icmp ult i32 %17, 100
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = tail call i32 @putchar(i32 99)
br label %25
21: ; preds = %12
%22 = icmp sgt i32 %3, 199
br i1 %22, label %23, label %25
23: ; preds = %21
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %16)
br label %25
25: ; preds = %21, %23, %19
%26 = trunc i16 %15 to i8
%27 = sdiv i8 %26, 10
%28 = srem i8 %26, 10
%29 = sext i8 %27 to i32
%30 = add nsw i16 %15, -10
%31 = icmp ult i16 %30, 10
br i1 %31, label %32, label %34
32: ; preds = %25
%33 = tail call i32 @putchar(i32 109)
br label %38
34: ; preds = %25
%35 = icmp sgt i16 %15, 19
br i1 %35, label %36, label %38
36: ; preds = %34
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %29)
br label %38
38: ; preds = %34, %36, %32
%39 = sext i8 %28 to i32
%40 = icmp eq i8 %28, 1
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = tail call i32 @putchar(i32 109)
br label %47
43: ; preds = %38
%44 = icmp sgt i8 %28, 1
br i1 %44, label %45, label %47
45: ; preds = %43
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %39)
br label %47
47: ; preds = %43, %45, %41
%48 = tail call i32 @putchar(i32 10)
ret void
}