#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 atoi(char *);
int /*<<< orphan*/ printf(char *, char *, int, int);
int romanToInt(char *);
int main(int argc, char **argv) {
  int n;
  if (romanToInt("MMMCCCXXXIII") != 3333)
    printf("FAILED %s, result: %d, should be: %d\n", "MMMCCCXXXIII",
           romanToInt("MMMCCCXXXIII"), 3333);
  if (romanToInt("MCDXXXVII") != 1437)
    printf("FAILED %s, result: %d, should be: %d\n", "MCDXXXVII",
           romanToInt("MCDXXXVII"), 1437);
  if (romanToInt("MDCCCLXXX") != 1880)
    printf("FAILED %s, result: %d, should be: %d\n", "MDCCCLXXX",
           romanToInt("MDCCCLXXX"), 1880);
  if (romanToInt("XC") != 90)
    printf("FAILED %s, result: %d, should be: %d\n", "XC", romanToInt("XC"),
           90);
  if (argc > 1) {
    for (n = 0; n < argc; n += 2) {
      if (romanToInt(argv[n]) != atoi(argv[n + 1]))
        printf("FAILED %s, result: %d, should be: %d\n", argv[n],
               romanToInt(argv[n]), atoi(argv[n + 1]));
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
call   1050 <romanToInt@plt>
cmp    $0xd05,%eax
je     1183 <main+0x53>
lea    0xe9c(%rip),%rdi
call   1050 <romanToInt@plt>
mov    %eax,%edx
lea    0xe9b(%rip),%rdi
lea    0xe87(%rip),%rsi
mov    $0xd05,%ecx
call   1030 <printf@plt>
lea    0xea9(%rip),%rdi
call   1050 <romanToInt@plt>
cmp    $0x59d,%eax
je     11c0 <main+0x90>
lea    0xe92(%rip),%rdi
call   1050 <romanToInt@plt>
mov    %eax,%edx
lea    0xe5e(%rip),%rdi
lea    0xe7d(%rip),%rsi
mov    $0x59d,%ecx
call   1030 <printf@plt>
lea    0xe76(%rip),%rdi
call   1050 <romanToInt@plt>
cmp    $0x758,%eax
je     11fd <main+0xcd>
lea    0xe5f(%rip),%rdi
call   1050 <romanToInt@plt>
mov    %eax,%edx
lea    0xe21(%rip),%rdi
lea    0xe4a(%rip),%rsi
mov    $0x758,%ecx
call   1030 <printf@plt>
lea    0xe43(%rip),%rdi
call   1050 <romanToInt@plt>
cmp    $0x5a,%eax
je     1238 <main+0x108>
lea    0xe2e(%rip),%rdi
call   1050 <romanToInt@plt>
mov    %eax,%edx
lea    0xde6(%rip),%rdi
lea    0xe19(%rip),%rsi
mov    $0x5a,%ecx
call   1030 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jle    12f3 <main+0x1c3>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12ee <main+0x1be>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <romanToInt@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
je     12db <main+0x1ab>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <romanToInt@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <atoi@plt>
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    %eax,%ecx
lea    0xd37(%rip),%rdi
call   1030 <printf@plt>
jmp    12e0 <main+0x1b0>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1249 <main+0x119>
jmp    12f3 <main+0x1c3>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%r15d
lea    0xeb8(%rip),%rdi
call   1050 <romanToInt@plt>
cmp    $0xd05,%eax
je     1179 <main+0x49>
lea    0xea5(%rip),%r14
mov    %r14,%rdi
call   1050 <romanToInt@plt>
lea    0xea3(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
mov    $0xd05,%ecx
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
call   1050 <romanToInt@plt>
cmp    $0x59d,%eax
je     11b1 <main+0x81>
lea    0xea0(%rip),%r14
mov    %r14,%rdi
call   1050 <romanToInt@plt>
lea    0xe6b(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
mov    $0x59d,%ecx
call   1030 <printf@plt>
lea    0xe85(%rip),%rdi
call   1050 <romanToInt@plt>
cmp    $0x758,%eax
je     11e9 <main+0xb9>
lea    0xe72(%rip),%r14
mov    %r14,%rdi
call   1050 <romanToInt@plt>
lea    0xe33(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
mov    $0x758,%ecx
call   1030 <printf@plt>
lea    0xe57(%rip),%rdi
call   1050 <romanToInt@plt>
cmp    $0x5a,%eax
je     121f <main+0xef>
lea    0xe46(%rip),%r14
mov    %r14,%rdi
call   1050 <romanToInt@plt>
lea    0xdfd(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
mov    $0x5a,%ecx
call   1030 <printf@plt>
cmp    $0x2,%r15d
jl     127d <main+0x14d>
xor    %ebx,%ebx
lea    0xddf(%rip),%r14
jmp    1239 <main+0x109>
add    $0x2,%rbx
cmp    %r15d,%ebx
jge    127d <main+0x14d>
mov    (%r12,%rbx,8),%rdi
call   1050 <romanToInt@plt>
mov    %eax,%ebp
mov    0x8(%r12,%rbx,8),%rdi
call   1040 <atoi@plt>
cmp    %eax,%ebp
je     1230 <main+0x100>
mov    (%r12,%rbx,8),%rbp
mov    %rbp,%rdi
call   1050 <romanToInt@plt>
mov    %eax,%r13d
mov    0x8(%r12,%rbx,8),%rdi
call   1040 <atoi@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r13d,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
jmp    1230 <main+0x100>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"MMMCCCXXXIII\00"
@.str.1 = [38 x i8] c"FAILED %s, result: %d, should be: %d\0A\00"
@.str.2 = [10 x i8] c"MCDXXXVII\00"
@.str.3 = [10 x i8] c"MDCCCLXXX\00"
@.str.4 = [3 x i8] c"XC\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @romanToInt(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 3333
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 @romanToInt(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %10, i32 3333)
br label %12
12: ; preds = %9, %2
%13 = call i32 @romanToInt(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp ne i32 %13, 1437
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = call i32 @romanToInt(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 1437)
br label %18
18: ; preds = %15, %12
%19 = call i32 @romanToInt(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp ne i32 %19, 1880
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = call i32 @romanToInt(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 1880)
br label %24
24: ; preds = %21, %18
%25 = call i32 @romanToInt(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp ne i32 %25, 90
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = call i32 @romanToInt(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %28, i32 90)
br label %30
30: ; preds = %27, %24
%31 = load i32, i32* %4
%32 = icmp sgt i32 %31, 1
br i1 %32, label %33, label %78
33: ; preds = %30
store i32 0, i32* %6
br label %34
34: ; preds = %74, %33
%35 = load i32, i32* %6
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %77
38: ; preds = %34
%39 = load i8**, i8*** %5
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = call i32 @romanToInt(i8* %43)
%45 = load i8**, i8*** %5
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %45, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 @atoi(i8* %50)
%52 = icmp ne i32 %44, %51
br i1 %52, label %53, label %73
53: ; preds = %38
%54 = load i8**, i8*** %5
%55 = load i32, i32* %6
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
%58 = load i8*, i8** %57
%59 = load i8**, i8*** %5
%60 = load i32, i32* %6
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %59, i64 %61
%63 = load i8*, i8** %62
%64 = call i32 @romanToInt(i8* %63)
%65 = load i8**, i8*** %5
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %65, i64 %68
%70 = load i8*, i8** %69
%71 = call i32 @atoi(i8* %70)
%72 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %58, i32 %64, i32 %71)
br label %73
73: ; preds = %53, %38
br label %74
74: ; preds = %73
%75 = load i32, i32* %6
%76 = add nsw i32 %75, 2
store i32 %76, i32* %6
br label %34
77: ; preds = %34
br label %78
78: ; preds = %77, %30
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"MMMCCCXXXIII\00"
@.str.1 = [38 x i8] c"FAILED %s, result: %d, should be: %d\0A\00"
@.str.2 = [10 x i8] c"MCDXXXVII\00"
@.str.3 = [10 x i8] c"MDCCCLXXX\00"
@.str.4 = [3 x i8] c"XC\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @romanToInt(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 3333
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @romanToInt(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %6, i32 3333)
br label %8
8: ; preds = %5, %2
%9 = tail call i32 @romanToInt(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32 %9, 1437
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i32 @romanToInt(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 1437)
br label %14
14: ; preds = %11, %8
%15 = tail call i32 @romanToInt(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i32 %15, 1880
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = tail call i32 @romanToInt(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%19 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %18, i32 1880)
br label %20
20: ; preds = %17, %14
%21 = tail call i32 @romanToInt(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i32 %21, 90
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = tail call i32 @romanToInt(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%25 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %24, i32 90)
br label %26
26: ; preds = %23, %20
%27 = icmp sgt i32 %0, 1
br i1 %27, label %28, label %48
28: ; preds = %26, %44
%29 = phi i64 [ %45, %44 ], [ 0, %26 ]
%30 = getelementptr inbounds i8*, i8** %1, i64 %29
%31 = load i8*, i8** %30
%32 = tail call i32 @romanToInt(i8* %31)
%33 = or i64 %29, 1
%34 = getelementptr inbounds i8*, i8** %1, i64 %33
%35 = load i8*, i8** %34
%36 = tail call i32 @atoi(i8* %35)
%37 = icmp eq i32 %32, %36
br i1 %37, label %44, label %38
38: ; preds = %28
%39 = load i8*, i8** %30
%40 = tail call i32 @romanToInt(i8* %39)
%41 = load i8*, i8** %34
%42 = tail call i32 @atoi(i8* %41)
%43 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %39, i32 %40, i32 %42)
br label %44
44: ; preds = %28, %38
%45 = add nuw i64 %29, 2
%46 = trunc i64 %45 to i32
%47 = icmp slt i32 %46, %0
br i1 %47, label %28, label %48
48: ; preds = %44, %26
ret i32 0
}