#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 *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char str[5];
  int l, n = 0;
  printf("Enter Number: ");
  scanf("%s", str);
  for (l = strlen(str) - 1; l >= 0; l--) {
    if (str[l] == 'I' && (str[l + 1] == 'V' || str[l + 1] == 'X' ||
                          str[l + 1] == 'L' || str[l + 1] == 'C'))
      n--;
    else if (str[l] == 'I')
      n++;
    else if (str[l] == 'V')
      n += 5;
    else if (str[l] == 'X')
      n += 10;
    else if (str[l] == 'L')
      n += 50;
    else if (str[l] == 'C')
      n += 100;
  }
  if (n > 256)
    printf("Maximum number is 256.");
  else
    printf("Number: %d\n\n", n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x9(%rbp),%rsi
lea    0xeb0(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x9(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     12bc <main+0x18c>
movslq -0x10(%rbp),%rax
movsbl -0x9(%rbp,%rax,1),%eax
cmp    $0x49,%eax
jne    11f5 <main+0xc5>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x9(%rbp,%rax,1),%eax
cmp    $0x56,%eax
je     11e7 <main+0xb7>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x9(%rbp,%rax,1),%eax
cmp    $0x58,%eax
je     11e7 <main+0xb7>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x9(%rbp,%rax,1),%eax
cmp    $0x4c,%eax
je     11e7 <main+0xb7>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x9(%rbp,%rax,1),%eax
cmp    $0x43,%eax
jne    11f5 <main+0xc5>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    12a9 <main+0x179>
movslq -0x10(%rbp),%rax
movsbl -0x9(%rbp,%rax,1),%eax
cmp    $0x49,%eax
jne    1215 <main+0xe5>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12a4 <main+0x174>
movslq -0x10(%rbp),%rax
movsbl -0x9(%rbp,%rax,1),%eax
cmp    $0x56,%eax
jne    1235 <main+0x105>
mov    -0x14(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x14(%rbp)
jmp    129f <main+0x16f>
movslq -0x10(%rbp),%rax
movsbl -0x9(%rbp,%rax,1),%eax
cmp    $0x58,%eax
jne    1255 <main+0x125>
mov    -0x14(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x14(%rbp)
jmp    129a <main+0x16a>
movslq -0x10(%rbp),%rax
movsbl -0x9(%rbp,%rax,1),%eax
cmp    $0x4c,%eax
jne    1275 <main+0x145>
mov    -0x14(%rbp),%eax
add    $0x32,%eax
mov    %eax,-0x14(%rbp)
jmp    1295 <main+0x165>
movslq -0x10(%rbp),%rax
movsbl -0x9(%rbp,%rax,1),%eax
cmp    $0x43,%eax
jne    1290 <main+0x160>
mov    -0x14(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x14(%rbp)
jmp    1295 <main+0x165>
jmp    129a <main+0x16a>
jmp    129f <main+0x16f>
jmp    12a4 <main+0x174>
jmp    12a9 <main+0x179>
jmp    12ae <main+0x17e>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1173 <main+0x43>
cmpl   $0x100,-0x14(%rbp)
jle    12dc <main+0x1ac>
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12ed <main+0x1bd>
mov    -0x14(%rbp),%esi
lea    0xd43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xf1d(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf1c(%rip),%rdi
lea    0x3(%rsp),%r14
mov    %r14,%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11fd <main+0xcd>
mov    %eax,%eax
add    $0x1,%rax
xor    %ebx,%ebx
lea    0xe89(%rip),%rcx
mov    $0x280201,%esi
jmp    119a <main+0x6a>
add    $0x64,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rax
cmp    $0x1,%rax
jbe    11e5 <main+0xb5>
lea    -0x2(%rax),%edx
movzbl 0x3(%rsp,%rdx,1),%edx
add    $0xbd,%dl
cmp    $0x15,%dl
ja     1190 <main+0x60>
movzbl %dl,%edx
movslq (%rcx,%rdx,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
movzbl 0x2(%rsp,%rax,1),%edx
add    $0xbd,%dl
cmp    $0x15,%dl
ja     11e0 <main+0xb0>
movzbl %dl,%edx
bt     %rdx,%rsi
jae    11e0 <main+0xb0>
add    $0xffffffff,%ebx
jmp    1190 <main+0x60>
add    $0x32,%ebx
jmp    1190 <main+0x60>
add    $0x5,%ebx
jmp    1190 <main+0x60>
add    $0xa,%ebx
jmp    1190 <main+0x60>
add    $0x1,%ebx
jmp    1190 <main+0x60>
cmp    $0x101,%ebx
jl     11fd <main+0xcd>
lea    0xe76(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    120d <main+0xdd>
lea    0xe7d(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [15 x i8] c"Enter Number: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [23 x i8] c"Maximum number is 256.\00"
@.str.3 = [13 x i8] c"Number: %d\0A\0A\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 @strlen(i8* %2)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %38
7: ; preds = %0
%8 = zext i32 %5 to i64
br label %9
9: ; preds = %7, %31
%10 = phi i64 [ %8, %7 ], [ %12, %31 ]
%11 = phi i32 [ 0, %7 ], [ %32, %31 ]
%12 = add nsw i64 %10, -1
%13 = and i64 %12, 4294967295
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %14
switch i8 %15, label %31 [
i8 73, label %16
i8 67, label %29
i8 86, label %23
i8 88, label %25
i8 76, label %27
]
16: ; preds = %9
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %10
%18 = load i8, i8* %17
switch i8 %18, label %21 [
i8 86, label %19
i8 88, label %19
i8 76, label %19
i8 67, label %19
]
19: ; preds = %16, %16, %16, %16
%20 = add nsw i32 %11, -1
br label %31
21: ; preds = %16
%22 = add nsw i32 %11, 1
br label %31
23: ; preds = %9
%24 = add nsw i32 %11, 5
br label %31
25: ; preds = %9
%26 = add nsw i32 %11, 10
br label %31
27: ; preds = %9
%28 = add nsw i32 %11, 50
br label %31
29: ; preds = %9
%30 = add nsw i32 %11, 100
br label %31
31: ; preds = %9, %19, %23, %27, %29, %25, %21
%32 = phi i32 [ %20, %19 ], [ %22, %21 ], [ %24, %23 ], [ %26, %25 ], [ %28, %27 ], [ %30, %29 ], [ %11, %9 ]
%33 = icmp ugt i64 %10, 1
br i1 %33, label %9, label %34
34: ; preds = %31
%35 = icmp sgt i32 %32, 256
br i1 %35, label %36, label %38
36: ; preds = %34
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %41
38: ; preds = %0, %34
%39 = phi i32 [ %32, %34 ], [ 0, %0 ]
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %38, %36
ret i32 0
}