#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 number(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  int i, n = 0;
  char s[5];
  scanf("%s", s);
  for (i = 0; i < strlen(s); i++) {
    if (s[i] == 'I' && (s[i + 1] == 'V' || s[i + 1] == 'X')) {
      n = n + number(s[i + 1]) - 1;
      i++;
      continue;
    }
    n = n + number(s[i]);
  }
  if (n <= 256) {
    printf("\n Number = %d", n);
    printf("\n");
  } else {
    printf("\n Enter a smaller number ");
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x11(%rbp),%rsi
lea    0xe9f(%rip),%rdi
call   1060 <scanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x11(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    1226 <main+0xe6>
movslq -0x8(%rbp),%rax
movsbl -0x11(%rbp,%rax,1),%eax
cmp    $0x49,%eax
jne    11fa <main+0xba>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x11(%rbp,%rax,1),%eax
cmp    $0x56,%eax
je     11c7 <main+0x87>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x11(%rbp,%rax,1),%eax
cmp    $0x58,%eax
jne    11fa <main+0xba>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x11(%rbp,%rax,1),%edi
call   1050 <number@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1218 <main+0xd8>
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x11(%rbp,%rax,1),%edi
call   1050 <number@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116d <main+0x2d>
cmpl   $0x100,-0xc(%rbp)
jg     1257 <main+0x117>
mov    -0xc(%rbp),%esi
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1273 <main+0x133>
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xea2(%rip),%rdi
lea    0x3(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
xor    %r15d,%r15d
test   %eax,%eax
jle    11e8 <main+0x98>
lea    0x3(%rsp),%r14
xor    %ebp,%ebp
jmp    11ad <main+0x5d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %al,%edi
call   1060 <number@plt>
add    %r15d,%eax
mov    %eax,%r15d
add    $0x1,%ebp
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    %eax,%ebp
jge    11df <main+0x8f>
movslq %ebp,%rbx
movzbl 0x3(%rsp,%rbx,1),%eax
cmp    $0x49,%al
jne    1190 <main+0x40>
movzbl 0x4(%rsp,%rbx,1),%ecx
cmp    $0x58,%cl
je     11c8 <main+0x78>
cmp    $0x56,%cl
jne    1190 <main+0x40>
add    $0x1,%rbx
movsbl %cl,%edi
call   1060 <number@plt>
add    %eax,%r15d
add    $0xffffffff,%r15d
mov    %ebx,%ebp
jmp    119e <main+0x4e>
cmp    $0x100,%r15d
jg     11fb <main+0xab>
lea    0xe14(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1209 <main+0xb9>
lea    0xe0f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [14 x i8] c"\0A Number = %d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [26 x i8] c"\0A Enter a smaller number \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [5 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
store i32 0, i32* %2
br label %7
7: ; preds = %55, %0
%8 = load i32, i32* %2
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %58
12: ; preds = %7
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 73
br i1 %18, label %19, label %47
19: ; preds = %12
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 86
br i1 %26, label %35, label %27
27: ; preds = %19
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 88
br i1 %34, label %35, label %47
35: ; preds = %27, %19
%36 = load i32, i32* %3
%37 = load i32, i32* %2
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = call i32 @number(i8 signext %41)
%43 = add nsw i32 %36, %42
%44 = sub nsw i32 %43, 1
store i32 %44, i32* %3
%45 = load i32, i32* %2
%46 = add nsw i32 %45, 1
store i32 %46, i32* %2
br label %55
47: ; preds = %27, %12
%48 = load i32, i32* %3
%49 = load i32, i32* %2
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = call i32 @number(i8 signext %52)
%54 = add nsw i32 %48, %53
store i32 %54, i32* %3
br label %55
55: ; preds = %47, %35
%56 = load i32, i32* %2
%57 = add nsw i32 %56, 1
store i32 %57, i32* %2
br label %7
58: ; preds = %7
%59 = load i32, i32* %3
%60 = icmp sle i32 %59, 256
br i1 %60, label %61, label %65
61: ; preds = %58
%62 = load i32, i32* %3
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %62)
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %68
65: ; preds = %58
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %68
68: ; preds = %65, %61
ret i32 0
}

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