#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  char str[300];
  int l, sum;
  printf("\nNote: numbers other than C,L,X,V,I and that are not Roman will be "
         "excluded from the calculations.\n");
  printf("Enter Number:");
  fgets(str, 300, stdin);
  l = strlen(str) - 1;
  sum = 0;
  for (; l >= 0; l--) {
    if (str[l] == 'I' && (str[l + 1] == 'V' || str[l + 1] == 'X' ||
                          str[l + 1] == 'L' || str[l + 1] == 'C'))
      sum--;
    else if (str[l] == 'I')
      sum++;
    else if (str[l] == 'V')
      sum += 5;
    else if (str[l] == 'X')
      sum += 10;
    else if (str[l] == 'L')
      sum += 50;
    else if (str[l] == 'C')
      sum += 100;
  }
  printf("Number in decimal: %d\n\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x130(%rbp),%rdi
mov    0x2e7c(%rip),%rax
mov    (%rax),%edx
mov    $0x12c,%esi
call   1050 <fgets@plt>
lea    -0x130(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x134(%rbp)
movl   $0x0,-0x138(%rbp)
cmpl   $0x0,-0x134(%rbp)
jl     1349 <main+0x219>
movslq -0x134(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x49,%eax
jne    1240 <main+0x110>
mov    -0x134(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x56,%eax
je     122c <main+0xfc>
mov    -0x134(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x58,%eax
je     122c <main+0xfc>
mov    -0x134(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x4c,%eax
je     122c <main+0xfc>
mov    -0x134(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x43,%eax
jne    1240 <main+0x110>
mov    -0x138(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x138(%rbp)
jmp    1330 <main+0x200>
movslq -0x134(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x49,%eax
jne    126c <main+0x13c>
mov    -0x138(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x138(%rbp)
jmp    132b <main+0x1fb>
movslq -0x134(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x56,%eax
jne    1298 <main+0x168>
mov    -0x138(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x138(%rbp)
jmp    1326 <main+0x1f6>
movslq -0x134(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x58,%eax
jne    12c4 <main+0x194>
mov    -0x138(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x138(%rbp)
jmp    1321 <main+0x1f1>
movslq -0x134(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x4c,%eax
jne    12f0 <main+0x1c0>
mov    -0x138(%rbp),%eax
add    $0x32,%eax
mov    %eax,-0x138(%rbp)
jmp    131c <main+0x1ec>
movslq -0x134(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x43,%eax
jne    1317 <main+0x1e7>
mov    -0x138(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x138(%rbp)
jmp    131c <main+0x1ec>
jmp    1321 <main+0x1f1>
jmp    1326 <main+0x1f6>
jmp    132b <main+0x1fb>
jmp    1330 <main+0x200>
jmp    1335 <main+0x205>
mov    -0x134(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x134(%rbp)
jmp    1197 <main+0x67>
mov    -0x138(%rbp),%esi
lea    0xd1c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x138,%rsp
lea    0xf2d(%rip),%rdi
call   1030 <puts@plt>
lea    0xefb(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x12c,%esi
call   1060 <fgets@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1204 <main+0xc4>
mov    %eax,%eax
add    $0x1,%rax
xor    %ebx,%ebx
lea    0xe66(%rip),%rcx
mov    $0x280201,%esi
jmp    11ba <main+0x7a>
add    $0x64,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0xffffffffffffffff,%rax
cmp    $0x1,%rax
jbe    1204 <main+0xc4>
lea    -0x2(%rax),%edx
movzbl (%rsp,%rdx,1),%edx
add    $0xbd,%dl
cmp    $0x15,%dl
ja     11b0 <main+0x70>
movzbl %dl,%edx
movslq (%rcx,%rdx,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
movzbl -0x1(%rsp,%rax,1),%edx
add    $0xbd,%dl
cmp    $0x15,%dl
ja     11ff <main+0xbf>
movzbl %dl,%edx
bt     %rdx,%rsi
jae    11ff <main+0xbf>
add    $0xffffffff,%ebx
jmp    11b0 <main+0x70>
add    $0x32,%ebx
jmp    11b0 <main+0x70>
add    $0x5,%ebx
jmp    11b0 <main+0x70>
add    $0xa,%ebx
jmp    11b0 <main+0x70>
add    $0x1,%ebx
jmp    11b0 <main+0x70>
lea    0xe5b(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x138,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [100 x i8] c"\0ANote: numbers other than C,L,X,V,I and that are not Roman will be excluded from the calculations.\0A\00"
@.str.1 = [14 x i8] c"Enter Number:\00"
@stdin = global i32 0
@.str.2 = [24 x i8] c"Number in decimal: %d\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [300 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 300, i32 %8)
%10 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = sub nsw i32 %11, 1
store i32 %12, i32* %3
store i32 0, i32* %4
br label %13
13: ; preds = %114, %0
%14 = load i32, i32* %3
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %117
16: ; preds = %13
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 73
br i1 %22, label %23, label %58
23: ; preds = %16
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 86
br i1 %30, label %55, label %31
31: ; preds = %23
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 88
br i1 %38, label %55, label %39
39: ; preds = %31
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 76
br i1 %46, label %55, label %47
47: ; preds = %39
%48 = load i32, i32* %3
%49 = add nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 67
br i1 %54, label %55, label %58
55: ; preds = %47, %39, %31, %23
%56 = load i32, i32* %4
%57 = add nsw i32 %56, -1
store i32 %57, i32* %4
br label %113
58: ; preds = %47, %16
%59 = load i32, i32* %3
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 73
br i1 %64, label %65, label %68
65: ; preds = %58
%66 = load i32, i32* %4
%67 = add nsw i32 %66, 1
store i32 %67, i32* %4
br label %112
68: ; preds = %58
%69 = load i32, i32* %3
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 86
br i1 %74, label %75, label %78
75: ; preds = %68
%76 = load i32, i32* %4
%77 = add nsw i32 %76, 5
store i32 %77, i32* %4
br label %111
78: ; preds = %68
%79 = load i32, i32* %3
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 %80
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = icmp eq i32 %83, 88
br i1 %84, label %85, label %88
85: ; preds = %78
%86 = load i32, i32* %4
%87 = add nsw i32 %86, 10
store i32 %87, i32* %4
br label %110
88: ; preds = %78
%89 = load i32, i32* %3
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 %90
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = icmp eq i32 %93, 76
br i1 %94, label %95, label %98
95: ; preds = %88
%96 = load i32, i32* %4
%97 = add nsw i32 %96, 50
store i32 %97, i32* %4
br label %109
98: ; preds = %88
%99 = load i32, i32* %3
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 %100
%102 = load i8, i8* %101
%103 = sext i8 %102 to i32
%104 = icmp eq i32 %103, 67
br i1 %104, label %105, label %108
105: ; preds = %98
%106 = load i32, i32* %4
%107 = add nsw i32 %106, 100
store i32 %107, i32* %4
br label %108
108: ; preds = %105, %98
br label %109
109: ; preds = %108, %95
br label %110
110: ; preds = %109, %85
br label %111
111: ; preds = %110, %75
br label %112
112: ; preds = %111, %65
br label %113
113: ; preds = %112, %55
br label %114
114: ; preds = %113
%115 = load i32, i32* %3
%116 = add nsw i32 %115, -1
store i32 %116, i32* %3
br label %13
117: ; preds = %13
%118 = load i32, i32* %4
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %118)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"Enter Number:\00"
@stdin = global i32 0
@.str.2 = [24 x i8] c"Number in decimal: %d\0A\0A\00"
@str = [99 x i8] c"\0ANote: numbers other than C,L,X,V,I and that are not Roman will be excluded from the calculations.\00"
define i32 @main() {
%1 = alloca [300 x i8]
%2 = getelementptr inbounds [300 x i8], [300 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([99 x i8], [99 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %2, i32 300, i32 %5)
%7 = call i32 @strlen(i8* %2)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %36
9: ; preds = %0
%10 = zext i32 %7 to i64
br label %11
11: ; preds = %9, %33
%12 = phi i64 [ %10, %9 ], [ %14, %33 ]
%13 = phi i32 [ 0, %9 ], [ %34, %33 ]
%14 = add nsw i64 %12, -1
%15 = and i64 %14, 4294967295
%16 = getelementptr inbounds [300 x i8], [300 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
switch i8 %17, label %33 [
i8 73, label %18
i8 67, label %31
i8 86, label %25
i8 88, label %27
i8 76, label %29
]
18: ; preds = %11
%19 = getelementptr inbounds [300 x i8], [300 x i8]* %1, i64 0, i64 %12
%20 = load i8, i8* %19
switch i8 %20, label %23 [
i8 86, label %21
i8 88, label %21
i8 76, label %21
i8 67, label %21
]
21: ; preds = %18, %18, %18, %18
%22 = add nsw i32 %13, -1
br label %33
23: ; preds = %18
%24 = add nsw i32 %13, 1
br label %33
25: ; preds = %11
%26 = add nsw i32 %13, 5
br label %33
27: ; preds = %11
%28 = add nsw i32 %13, 10
br label %33
29: ; preds = %11
%30 = add nsw i32 %13, 50
br label %33
31: ; preds = %11
%32 = add nsw i32 %13, 100
br label %33
33: ; preds = %11, %21, %25, %29, %31, %27, %23
%34 = phi i32 [ %22, %21 ], [ %24, %23 ], [ %26, %25 ], [ %28, %27 ], [ %30, %29 ], [ %32, %31 ], [ %13, %11 ]
%35 = icmp ugt i64 %12, 1
br i1 %35, label %11, label %36
36: ; preds = %33, %0
%37 = phi i32 [ 0, %0 ], [ %34, %33 ]
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %37)
ret i32 0
}