char *get_numeral(int val) {
  int a = 13;
  char *return_val = "";
  static int decimals[] = {1,  4,   5,   9,   10,  40,  50,
                           90, 100, 400, 500, 900, 1000};
  static char *roman[] = {"I",  "IV", "V",  "IX", "X",  "XL", "L",
                          "XC", "C",  "CD", "D",  "CM", "M"};
  for (int i = a; --i >= 0;) {
    if (val > decimals[a]) {
      return_val = roman[i];
      break;
    }
  }
  return return_val;
}


x86 assembly (clang, -O0):
<get_numeral>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0xd,-0x8(%rbp)
lea    0xef8(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jl     1165 <get_numeral+0x65>
mov    -0x4(%rbp),%eax
movslq -0x8(%rbp),%rdx
lea    0x2ef1(%rip),%rcx
cmp    (%rcx,%rdx,4),%eax
jle    1160 <get_numeral+0x60>
movslq -0x14(%rbp),%rcx
lea    0x2f1d(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x10(%rbp)
jmp    1165 <get_numeral+0x65>
jmp    111f <get_numeral+0x1f>
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_numeral>:
lea    0xef9(%rip),%rax
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@get_numeral.decimals = internal global [13 x i32] [i32 1, i32 4, i32 5, i32 9, i32 10, i32 40, i32 50, i32 90, i32 100, i32 400, i32 500, i32 900, i32 1000]
@get_numeral.roman = internal global [13 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i32 0, i32 0)]
@.str.1 = [2 x i8] c"I\00"
@.str.2 = [3 x i8] c"IV\00"
@.str.3 = [2 x i8] c"V\00"
@.str.4 = [3 x i8] c"IX\00"
@.str.5 = [2 x i8] c"X\00"
@.str.6 = [3 x i8] c"XL\00"
@.str.7 = [2 x i8] c"L\00"
@.str.8 = [3 x i8] c"XC\00"
@.str.9 = [2 x i8] c"C\00"
@.str.10 = [3 x i8] c"CD\00"
@.str.11 = [2 x i8] c"D\00"
@.str.12 = [3 x i8] c"CM\00"
@.str.13 = [2 x i8] c"M\00"
define i8* @get_numeral(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %2
store i32 13, i32* %3
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %4
%6 = load i32, i32* %3
store i32 %6, i32* %5
br label %7
7: ; preds = %23, %1
%8 = load i32, i32* %5
%9 = add nsw i32 %8, -1
store i32 %9, i32* %5
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [13 x i32], [13 x i32]* @get_numeral.decimals, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = icmp sgt i32 %12, %16
br i1 %17, label %18, label %23
18: ; preds = %11
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [13 x i8*], [13 x i8*]* @get_numeral.roman, i64 0, i64 %20
%22 = load i8*, i8** %21
store i8* %22, i8** %4
br label %24
23: ; preds = %11
br label %7
24: ; preds = %18, %7
%25 = load i8*, i8** %4
ret i8* %25
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @get_numeral(i32 %0) {
ret i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
}