char numToChar(int step) {
  switch (step) {
  case 1000:
    return 'M';
  case 500:
    return 'D';
  case 100:
    return 'C';
  case 50:
    return 'L';
  case 10:
    return 'X';
  case 5:
    return 'V';
  case 1:
    return 'I';
  default:
    return 'I';
  }
}


x86 assembly (clang, -O0):
<numToChar>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     11bb <numToChar+0xbb>
jmp    111b <numToChar+0x1b>
mov    -0xc(%rbp),%eax
sub    $0x5,%eax
je     11b2 <numToChar+0xb2>
jmp    112c <numToChar+0x2c>
mov    -0xc(%rbp),%eax
sub    $0xa,%eax
je     11a9 <numToChar+0xa9>
jmp    113d <numToChar+0x3d>
mov    -0xc(%rbp),%eax
sub    $0x32,%eax
je     11a0 <numToChar+0xa0>
jmp    114e <numToChar+0x4e>
mov    -0xc(%rbp),%eax
sub    $0x64,%eax
je     1197 <numToChar+0x97>
jmp    115f <numToChar+0x5f>
mov    -0xc(%rbp),%eax
sub    $0x1f4,%eax
je     118e <numToChar+0x8e>
jmp    1172 <numToChar+0x72>
mov    -0xc(%rbp),%eax
sub    $0x3e8,%eax
jne    11c4 <numToChar+0xc4>
jmp    1185 <numToChar+0x85>
movb   $0x4d,-0x1(%rbp)
jmp    11c8 <numToChar+0xc8>
movb   $0x44,-0x1(%rbp)
jmp    11c8 <numToChar+0xc8>
movb   $0x43,-0x1(%rbp)
jmp    11c8 <numToChar+0xc8>
movb   $0x4c,-0x1(%rbp)
jmp    11c8 <numToChar+0xc8>
movb   $0x58,-0x1(%rbp)
jmp    11c8 <numToChar+0xc8>
movb   $0x56,-0x1(%rbp)
jmp    11c8 <numToChar+0xc8>
movb   $0x49,-0x1(%rbp)
jmp    11c8 <numToChar+0xc8>
movb   $0x49,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<numToChar>:
cmp    $0x31,%edi
jle    111a <numToChar+0x1a>
cmp    $0x1f3,%edi
jg     112c <numToChar+0x2c>
cmp    $0x32,%edi
je     1144 <numToChar+0x44>
cmp    $0x64,%edi
jne    1141 <numToChar+0x41>
mov    $0x43,%al
ret
cmp    $0x1,%edi
je     1141 <numToChar+0x41>
cmp    $0x5,%edi
je     1147 <numToChar+0x47>
cmp    $0xa,%edi
jne    1141 <numToChar+0x41>
mov    $0x58,%al
ret
mov    $0x4d,%al
cmp    $0x3e8,%edi
je     1143 <numToChar+0x43>
cmp    $0x1f4,%edi
jne    1141 <numToChar+0x41>
mov    $0x44,%al
ret
mov    $0x49,%al
ret
mov    $0x4c,%al
ret
mov    $0x56,%al
ret

LLVM IR (-O0):
define signext i8 @numToChar(i32 %0) {
%2 = alloca i8
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %12 [
i32 1000, label %5
i32 500, label %6
i32 100, label %7
i32 50, label %8
i32 10, label %9
i32 5, label %10
i32 1, label %11
]
5: ; preds = %1
store i8 77, i8* %2
br label %13
6: ; preds = %1
store i8 68, i8* %2
br label %13
7: ; preds = %1
store i8 67, i8* %2
br label %13
8: ; preds = %1
store i8 76, i8* %2
br label %13
9: ; preds = %1
store i8 88, i8* %2
br label %13
10: ; preds = %1
store i8 86, i8* %2
br label %13
11: ; preds = %1
store i8 73, i8* %2
br label %13
12: ; preds = %1
store i8 73, i8* %2
br label %13
13: ; preds = %12, %11, %10, %9, %8, %7, %6, %5
%14 = load i8, i8* %2
ret i8 %14
}

LLVM IR (-O2):
define signext i8 @numToChar(i32 %0) {
switch i32 %0, label %8 [
i32 1000, label %9
i32 500, label %2
i32 100, label %3
i32 50, label %4
i32 10, label %5
i32 5, label %6
i32 1, label %7
]
2: ; preds = %1
br label %9
3: ; preds = %1
br label %9
4: ; preds = %1
br label %9
5: ; preds = %1
br label %9
6: ; preds = %1
br label %9
7: ; preds = %1
br label %9
8: ; preds = %1
br label %9
9: ; preds = %1, %8, %7, %6, %5, %4, %3, %2
%10 = phi i8 [ 73, %8 ], [ 73, %7 ], [ 86, %6 ], [ 88, %5 ], [ 76, %4 ], [ 67, %3 ], [ 68, %2 ], [ 77, %1 ]
ret i8 %10
}