#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 toupper(char);
int getValue(char roman) {
  int r = 0;
  switch (toupper(roman)) {
  case 'I':
    r = 1;
    break;
  case 'V':
    r = 5;
    break;
  case 'X':
    r = 10;
    break;
  case 'L':
    r = 50;
    break;
  case 'C':
    r = 100;
    break;
  case 'D':
    r = 500;
    break;
  case 'M':
    r = 1000;
    break;
  default:
    r = 0;
    break;
  }
  return r;
}


x86 assembly (clang, -O0):
<getValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
movsbl -0x1(%rbp),%edi
call   1030 <toupper@plt>
add    $0xffffffbd,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x15,%eax
ja     11a8 <getValue+0x98>
mov    -0x10(%rbp),%rax
lea    0xeb5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x8(%rbp)
jmp    11af <getValue+0x9f>
movl   $0x5,-0x8(%rbp)
jmp    11af <getValue+0x9f>
movl   $0xa,-0x8(%rbp)
jmp    11af <getValue+0x9f>
movl   $0x32,-0x8(%rbp)
jmp    11af <getValue+0x9f>
movl   $0x64,-0x8(%rbp)
jmp    11af <getValue+0x9f>
movl   $0x1f4,-0x8(%rbp)
jmp    11af <getValue+0x9f>
movl   $0x3e8,-0x8(%rbp)
jmp    11af <getValue+0x9f>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getValue>:
push   %rax
call   1030 <toupper@plt>
mov    %eax,%ecx
add    $0xffffffbd,%ecx
cmp    $0x15,%ecx
ja     1143 <getValue+0x33>
mov    $0x1,%eax
lea    0xed4(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x64,%eax
pop    %rcx
ret
mov    $0x1f4,%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret
mov    $0x32,%eax
pop    %rcx
ret
mov    $0x5,%eax
pop    %rcx
ret
mov    $0xa,%eax
pop    %rcx
ret
mov    $0x3e8,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @getValue(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
store i8 %0, i8* %2
store i32 0, i32* %3
%4 = load i8, i8* %2
%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* %3
br label %14
7: ; preds = %1
store i32 5, i32* %3
br label %14
8: ; preds = %1
store i32 10, i32* %3
br label %14
9: ; preds = %1
store i32 50, i32* %3
br label %14
10: ; preds = %1
store i32 100, i32* %3
br label %14
11: ; preds = %1
store i32 500, i32* %3
br label %14
12: ; preds = %1
store i32 1000, i32* %3
br label %14
13: ; preds = %1
store i32 0, i32* %3
br label %14
14: ; preds = %13, %12, %11, %10, %9, %8, %7, %6
%15 = load i32, i32* %3
ret i32 %15
}

LLVM IR (-O2):
define i32 @getValue(i8 signext %0) {
%2 = tail call i32 @toupper(i8 signext %0)
switch i32 %2, label %9 [
i32 73, label %10
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 %10
4: ; preds = %1
br label %10
5: ; preds = %1
br label %10
6: ; preds = %1
br label %10
7: ; preds = %1
br label %10
8: ; preds = %1
br label %10
9: ; preds = %1
br label %10
10: ; preds = %1, %9, %8, %7, %6, %5, %4, %3
%11 = phi i32 [ 0, %9 ], [ 1000, %8 ], [ 500, %7 ], [ 100, %6 ], [ 50, %5 ], [ 10, %4 ], [ 5, %3 ], [ 1, %1 ]
ret i32 %11
}