#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 decimal(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  int i, result = 0;
  char roman[5];
  scanf("%s", roman);
  for (i = 0; i < strlen(roman); i++) {
    if (roman[i] == 'I' && (roman[i + 1] == 'X' || roman[i + 1] == 'V')) {
      result += decimal(roman[i + 1]) - 1;
      i++;
      continue;
    }
    result += decimal(roman[i]);
  }
  if (result > 256)
    printf("The number should be between 1 and 256.");
  else
    printf("With decimal numerals: %d\n", result);
  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    1212 <main+0xd2>
movslq -0x8(%rbp),%rax
movsbl -0x11(%rbp,%rax,1),%eax
cmp    $0x49,%eax
jne    11f0 <main+0xb0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x11(%rbp,%rax,1),%eax
cmp    $0x58,%eax
je     11c7 <main+0x87>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x11(%rbp,%rax,1),%eax
cmp    $0x56,%eax
jne    11f0 <main+0xb0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x11(%rbp,%rax,1),%edi
call   1050 <decimal@plt>
sub    $0x1,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1204 <main+0xc4>
movslq -0x8(%rbp),%rax
movsbl -0x11(%rbp,%rax,1),%edi
call   1050 <decimal@plt>
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116d <main+0x2d>
cmpl   $0x100,-0xc(%rbp)
jle    1232 <main+0xf2>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1243 <main+0x103>
mov    -0xc(%rbp),%esi
lea    0xdef(%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    0xeb2(%rip),%rdi
lea    0x3(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
xor    %r15d,%r15d
test   %eax,%eax
jle    11e1 <main+0xa1>
lea    0x3(%rsp),%r14
xor    %ebp,%ebp
jmp    119a <main+0x5a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %al,%edi
call   1050 <decimal@plt>
add    %eax,%r15d
add    $0x1,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jge    11c8 <main+0x88>
movslq %ebp,%rbx
movzbl 0x3(%rsp,%rbx,1),%eax
cmp    $0x49,%al
jne    1180 <main+0x40>
movzbl 0x4(%rsp,%rbx,1),%ecx
cmp    $0x58,%cl
je     11b5 <main+0x75>
cmp    $0x56,%cl
jne    1180 <main+0x40>
add    $0x1,%rbx
movsbl %cl,%edi
call   1050 <decimal@plt>
add    $0xffffffff,%eax
mov    %ebx,%ebp
jmp    1188 <main+0x48>
cmp    $0x101,%r15d
jl     11e1 <main+0xa1>
lea    0xe2b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11f2 <main+0xb2>
lea    0xe43(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@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 = [40 x i8] c"The number should be between 1 and 256.\00"
@.str.2 = [27 x i8] c"With decimal numerals: %d\0A\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, 88
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, 86
br i1 %34, label %35, label %47
35: ; preds = %27, %19
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = call i32 @decimal(i8 signext %40)
%42 = sub nsw i32 %41, 1
%43 = load i32, i32* %3
%44 = add nsw i32 %43, %42
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* %2
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = call i32 @decimal(i8 signext %51)
%53 = load i32, i32* %3
%54 = add nsw i32 %53, %52
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 sgt i32 %59, 256
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %66
63: ; preds = %58
%64 = load i32, i32* %3
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %64)
br label %66
66: ; preds = %63, %61
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [40 x i8] c"The number should be between 1 and 256.\00"
@.str.2 = [27 x i8] c"With decimal numerals: %d\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 = 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 %34
6: ; preds = %0, %23
%7 = phi i32 [ %26, %23 ], [ 0, %0 ]
%8 = phi i32 [ %27, %23 ], [ 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 %21
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 %21 [
i8 88, label %18
i8 86, label %18
]
18: ; preds = %13, %13
%19 = call i32 @decimal(i8 signext %17)
%20 = add nsw i32 %19, -1
br label %23
21: ; preds = %13, %6
%22 = call i32 @decimal(i8 signext %11)
br label %23
23: ; preds = %21, %18
%24 = phi i32 [ %14, %18 ], [ %8, %21 ]
%25 = phi i32 [ %20, %18 ], [ %22, %21 ]
%26 = add nsw i32 %25, %7
%27 = add nsw i32 %24, 1
%28 = call i32 @strlen(i8* %2)
%29 = icmp slt i32 %27, %28
br i1 %29, label %6, label %30
30: ; preds = %23
%31 = icmp sgt i32 %26, 256
br i1 %31, label %32, label %34
32: ; preds = %30
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %37
34: ; preds = %0, %30
%35 = phi i32 [ %26, %30 ], [ 0, %0 ]
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %34, %32
ret i32 0
}