char *FontFamily(unsigned int i) {
  static char *familyname[] = {"nil",    "roman", "swiss", "modern",
                               "script", "decor", "tech"};
  if (i > 0 && i < 7)
    return familyname[i];
  return familyname[0];
}


x86 assembly (clang, -O0):
<FontFamily>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jbe    1134 <FontFamily+0x34>
cmpl   $0x7,-0xc(%rbp)
jae    1134 <FontFamily+0x34>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
lea    0x2f09(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
jmp    113f <FontFamily+0x3f>
mov    0x2ef5(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<FontFamily>:
lea    -0x1(%rdi),%eax
cmp    $0x5,%eax
ja     1119 <FontFamily+0x19>
mov    %edi,%eax
lea    0xeef(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xefc(%rip),%rax
ret

LLVM IR (-O0):
@FontFamily.familyname = internal global [7 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0)]
@.str = [4 x i8] c"nil\00"
@.str.1 = [6 x i8] c"roman\00"
@.str.2 = [6 x i8] c"swiss\00"
@.str.3 = [7 x i8] c"modern\00"
@.str.4 = [7 x i8] c"script\00"
@.str.5 = [6 x i8] c"decor\00"
@.str.6 = [5 x i8] c"tech\00"
define i8* @FontFamily(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp ugt i32 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp ult i32 %7, 7
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load i32, i32* %3
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds [7 x i8*], [7 x i8*]* @FontFamily.familyname, i64 0, i64 %11
%13 = load i8*, i8** %12
store i8* %13, i8** %2
br label %16
14: ; preds = %6, %1
%15 = load i8*, i8** getelementptr inbounds ([7 x i8*], [7 x i8*]* @FontFamily.familyname, i64 0, i64 0)
store i8* %15, i8** %2
br label %16
16: ; preds = %14, %9
%17 = load i8*, i8** %2
ret i8* %17
}

LLVM IR (-O2):
@reltable.FontFamily = internal unnamed_addr constant [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.FontFamily to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.FontFamily to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.FontFamily to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.FontFamily to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.FontFamily to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.FontFamily to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.FontFamily to i64)) to i32)]
@.str = [4 x i8] c"nil\00"
@.str.1 = [6 x i8] c"roman\00"
@.str.2 = [6 x i8] c"swiss\00"
@.str.3 = [7 x i8] c"modern\00"
@.str.4 = [7 x i8] c"script\00"
@.str.5 = [6 x i8] c"decor\00"
@.str.6 = [5 x i8] c"tech\00"
define i8* @FontFamily(i32 %0) {
%2 = add i32 %0, -1
%3 = icmp ult i32 %2, 6
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = zext i32 %0 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.FontFamily to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %9
}