#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*/ addRoman(int, char *, int *, char, char, char);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  int number;
  scanf("%d", &number);
  char chars[50];
  int index_counter = 0;
  int i;
  int div;
  div = number / 100;
  if (div > 0) {
    addRoman(div, chars, &index_counter, 'C', 'D', 'M');
    number = number % 100;
  }
  div = number / 10;
  if (div > 0) {
    addRoman(div, chars, &index_counter, 'X', 'L', 'C');
    number = number % 10;
  }
  if (number > 0) {
    addRoman(number, chars, &index_counter, 'I', 'V', 'X');
  }
  chars[index_counter] = '\0';
  printf("%s\n", chars);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jle    11a4 <main+0x74>
mov    -0x5c(%rbp),%edi
lea    -0x50(%rbp),%rsi
lea    -0x54(%rbp),%rdx
mov    $0x43,%ecx
mov    $0x44,%r8d
mov    $0x4d,%r9d
call   1040 <addRoman@plt>
mov    -0x14(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jle    11eb <main+0xbb>
mov    -0x5c(%rbp),%edi
lea    -0x50(%rbp),%rsi
lea    -0x54(%rbp),%rdx
mov    $0x58,%ecx
mov    $0x4c,%r8d
mov    $0x43,%r9d
call   1040 <addRoman@plt>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1216 <main+0xe6>
mov    -0x14(%rbp),%edi
lea    -0x50(%rbp),%rsi
lea    -0x54(%rbp),%rdx
mov    $0x49,%ecx
mov    $0x56,%r8d
mov    $0x58,%r9d
call   1040 <addRoman@plt>
movslq -0x54(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
lea    -0x50(%rbp),%rsi
lea    0xdd9(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
lea    0xec5(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
movl   $0x0,0xc(%rsp)
mov    0x8(%rsp),%edi
cmp    $0x64,%edi
jge    11a5 <main+0x75>
cmp    $0xa,%edi
jge    11fd <main+0xcd>
test   %edi,%edi
jle    1183 <main+0x53>
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    $0x49,%ecx
mov    $0x56,%r8d
mov    $0x58,%r9d
call   1040 <addRoman@plt>
movslq 0xc(%rsp),%rax
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xe6f(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret
mov    %edi,%eax
imul   $0x51eb851f,%rax,%rdi
shr    $0x25,%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    $0x43,%ecx
mov    $0x44,%r8d
mov    $0x4d,%r9d
call   1040 <addRoman@plt>
movslq 0x8(%rsp),%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
mov    %edi,0x8(%rsp)
cmp    $0xa,%edi
jl     115f <main+0x2f>
movzbl %dil,%eax
imul   $0xcd,%eax,%edi
shr    $0xb,%edi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    $0x58,%ecx
mov    $0x4c,%r8d
mov    $0x43,%r9d
call   1040 <addRoman@plt>
movslq 0x8(%rsp),%rdi
imul   $0x66666667,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
mov    %edi,0x8(%rsp)
test   %edi,%edi
jg     1163 <main+0x33>
jmp    1183 <main+0x53>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [50 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
store i32 0, i32* %8
%12 = load i32, i32* %6
%13 = sdiv i32 %12, 100
store i32 %13, i32* %10
%14 = load i32, i32* %10
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i32, i32* %10
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%19 = call i32 @addRoman(i32 %17, i8* %18, i32* %8, i8 signext 67, i8 signext 68, i8 signext 77)
%20 = load i32, i32* %6
%21 = srem i32 %20, 100
store i32 %21, i32* %6
br label %22
22: ; preds = %16, %2
%23 = load i32, i32* %6
%24 = sdiv i32 %23, 10
store i32 %24, i32* %10
%25 = load i32, i32* %10
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %22
%28 = load i32, i32* %10
%29 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%30 = call i32 @addRoman(i32 %28, i8* %29, i32* %8, i8 signext 88, i8 signext 76, i8 signext 67)
%31 = load i32, i32* %6
%32 = srem i32 %31, 10
store i32 %32, i32* %6
br label %33
33: ; preds = %27, %22
%34 = load i32, i32* %6
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = load i32, i32* %6
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%39 = call i32 @addRoman(i32 %37, i8* %38, i32* %8, i8 signext 73, i8 signext 86, i8 signext 88)
br label %40
40: ; preds = %36, %33
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 %42
store i8 0, i8* %43
%44 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%45 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [50 x i8]
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%9 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 99
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = udiv i32 %10, 100
%14 = call i32 @addRoman(i32 %13, i8* %8, i32* %5, i8 signext 67, i8 signext 68, i8 signext 77)
%15 = load i32, i32* %3
%16 = srem i32 %15, 100
store i32 %16, i32* %3
br label %17
17: ; preds = %12, %2
%18 = phi i32 [ %16, %12 ], [ %10, %2 ]
%19 = icmp sgt i32 %18, 9
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = trunc i32 %18 to i8
%22 = udiv i8 %21, 10
%23 = zext i8 %22 to i32
%24 = call i32 @addRoman(i32 %23, i8* %8, i32* %5, i8 signext 88, i8 signext 76, i8 signext 67)
%25 = load i32, i32* %3
%26 = srem i32 %25, 10
store i32 %26, i32* %3
br label %27
27: ; preds = %17, %20
%28 = phi i32 [ %26, %20 ], [ %18, %17 ]
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @addRoman(i32 %28, i8* %8, i32* %5, i8 signext 73, i8 signext 86, i8 signext 88)
br label %32
32: ; preds = %30, %27
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %34
store i8 0, i8* %35
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
ret i32 0
}