void convert(temp) {
  switch (temp) {
  case 'I':
    printf("1");
    break;
  case 'V':
    printf("5");
    break;
  case 'X':
    printf("10");
    break;
  case 'L':
    printf("50");
    break;
  case 'C':
    printf("100");
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffbd,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x15,%eax
ja     11a3 <convert+0x93>
mov    -0x10(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a8 <convert+0x98>
lea    0xefc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a8 <convert+0x98>
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a8 <convert+0x98>
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a8 <convert+0x98>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a8 <convert+0x98>
jmp    11a8 <convert+0x98>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert>:
add    $0xffffffbd,%edi
cmp    $0x15,%edi
ja     1146 <convert+0x26>
lea    0xed1(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xf1f(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
ret
mov    $0x31,%edi
jmp    1030 <putchar@plt>
lea    0xf03(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
mov    $0x35,%edi
jmp    1030 <putchar@plt>
lea    0xee8(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"5\00"
@.str.2 = [3 x i8] c"10\00"
@.str.3 = [3 x i8] c"50\00"
@.str.4 = [4 x i8] c"100\00"
define void @convert(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %14 [
i32 73, label %4
i32 86, label %6
i32 88, label %8
i32 76, label %10
i32 67, label %12
]
4: ; preds = %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %15
6: ; preds = %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %15
8: ; preds = %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %15
10: ; preds = %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %15
12: ; preds = %1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %15
14: ; preds = %1
br label %15
15: ; preds = %14, %12, %10, %8, %6, %4
ret void
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"10\00"
@.str.3 = [3 x i8] c"50\00"
@.str.4 = [4 x i8] c"100\00"
define void @convert(i32 %0) {
switch i32 %0, label %12 [
i32 73, label %2
i32 86, label %4
i32 88, label %6
i32 76, label %8
i32 67, label %10
]
2: ; preds = %1
%3 = tail call i32 @putchar(i32 49)
br label %12
4: ; preds = %1
%5 = tail call i32 @putchar(i32 53)
br label %12
6: ; preds = %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %12
8: ; preds = %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %12
10: ; preds = %1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %12
12: ; preds = %1, %10, %8, %6, %4, %2
ret void
}