#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*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char);
int /*<<< orphan*/ stderr;
int toupper(char);
unsigned read_rome_char(char c) {
  switch (toupper(c)) {
  case 'I':
    return 1;
  case 'V':
    return 5;
  case 'X':
    return 10;
  case 'L':
    return 50;
  case 'C':
    return 100;
  case 'D':
    return 500;
  case 'M':
    return 1000;
  default:
    fprintf(stderr, "offending character: '%c'\n", c);
    abort();
  }
}


x86 assembly (clang, -O0):
<read_rome_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1040 <toupper@plt>
add    $0xffffffbd,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x15,%eax
ja     11c1 <read_rome_char+0x91>
mov    -0x10(%rbp),%rax
lea    0xe9c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x4(%rbp)
jmp    11e1 <read_rome_char+0xb1>
movl   $0x5,-0x4(%rbp)
jmp    11e1 <read_rome_char+0xb1>
movl   $0xa,-0x4(%rbp)
jmp    11e1 <read_rome_char+0xb1>
movl   $0x32,-0x4(%rbp)
jmp    11e1 <read_rome_char+0xb1>
movl   $0x64,-0x4(%rbp)
jmp    11e1 <read_rome_char+0xb1>
movl   $0x1f4,-0x4(%rbp)
jmp    11e1 <read_rome_char+0xb1>
movl   $0x3e8,-0x4(%rbp)
jmp    11e1 <read_rome_char+0xb1>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
movsbl -0x5(%rbp),%edx
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_rome_char>:
push   %rbx
mov    %edi,%ebx
call   1040 <toupper@plt>
mov    %eax,%ecx
add    $0xffffffbd,%ecx
cmp    $0x15,%ecx
ja     1181 <read_rome_char+0x51>
mov    $0x1,%eax
lea    0xeb2(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x64,%eax
pop    %rbx
ret
mov    $0x1f4,%eax
pop    %rbx
ret
mov    $0x32,%eax
pop    %rbx
ret
mov    $0x3e8,%eax
pop    %rbx
ret
mov    $0x5,%eax
pop    %rbx
ret
mov    $0xa,%eax
pop    %rbx
ret
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
movsbl %bl,%edx
lea    0xec4(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"offending character: '%c'\0A\00"
define i32 @read_rome_char(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = call i32 @toupper(i8 signext %4)
switch i32 %5, label %13 [
i32 73, label %6
i32 86, label %7
i32 88, label %8
i32 76, label %9
i32 67, label %10
i32 68, label %11
i32 77, label %12
]
6: ; preds = %1
store i32 1, i32* %2
br label %18
7: ; preds = %1
store i32 5, i32* %2
br label %18
8: ; preds = %1
store i32 10, i32* %2
br label %18
9: ; preds = %1
store i32 50, i32* %2
br label %18
10: ; preds = %1
store i32 100, i32* %2
br label %18
11: ; preds = %1
store i32 500, i32* %2
br label %18
12: ; preds = %1
store i32 1000, i32* %2
br label %18
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = load i8, i8* %3
%16 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8 signext %15)
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %12, %11, %10, %9, %8, %7, %6
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"offending character: '%c'\0A\00"
define i32 @read_rome_char(i8 signext %0) {
%2 = tail call i32 @toupper(i8 signext %0)
switch i32 %2, label %9 [
i32 73, label %13
i32 86, label %3
i32 88, label %4
i32 76, label %5
i32 67, label %6
i32 68, label %7
i32 77, label %8
]
3: ; preds = %1
br label %13
4: ; preds = %1
br label %13
5: ; preds = %1
br label %13
6: ; preds = %1
br label %13
7: ; preds = %1
br label %13
8: ; preds = %1
br label %13
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8 signext %0)
%12 = tail call i32 (...) @abort()
unreachable
13: ; preds = %1, %8, %7, %6, %5, %4, %3
%14 = phi i32 [ 1000, %8 ], [ 500, %7 ], [ 100, %6 ], [ 50, %5 ], [ 10, %4 ], [ 5, %3 ], [ 1, %1 ]
ret i32 %14
}