const char *elf_abi(unsigned char code) {
  if (code == 0)
    return "UNIX - System V";
  else if (code == 1)
    return "HP-UX operating system";
  else if (code == 255)
    return "Standalone (embedded) application";
  else
    return "Unkown";
}


x86 assembly (clang, -O0):
<elf_abi>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
cmp    $0x0,%eax
jne    1127 <elf_abi+0x27>
lea    0xee2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    116e <elf_abi+0x6e>
movzbl -0x9(%rbp),%eax
cmp    $0x1,%eax
jne    1144 <elf_abi+0x44>
lea    0xed5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    116e <elf_abi+0x6e>
movzbl -0x9(%rbp),%eax
cmp    $0xff,%eax
jne    1163 <elf_abi+0x63>
lea    0xecd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    116e <elf_abi+0x6e>
lea    0xedf(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<elf_abi>:
add    $0x1,%dil
cmp    $0x2,%dil
ja     111d <elf_abi+0x1d>
movsbq %dil,%rax
lea    0xf3b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xf25(%rip),%rax
ret

LLVM IR (-O0):
@.str = [16 x i8] c"UNIX - System V\00"
@.str.1 = [23 x i8] c"HP-UX operating system\00"
@.str.2 = [34 x i8] c"Standalone (embedded) application\00"
@.str.3 = [7 x i8] c"Unkown\00"
define i8* @elf_abi(i8 zeroext %0) {
%2 = alloca i8*
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = zext i8 %4 to i32
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %2
br label %19
8: ; preds = %1
%9 = load i8, i8* %3
%10 = zext i8 %9 to i32
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %8
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %19
13: ; preds = %8
%14 = load i8, i8* %3
%15 = zext i8 %14 to i32
%16 = icmp eq i32 %15, 255
br i1 %16, label %17, label %18
17: ; preds = %13
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %19
18: ; preds = %13
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %19
19: ; preds = %18, %17, %12, %7
%20 = load i8*, i8** %2
ret i8* %20
}

LLVM IR (-O2):
@.str = [16 x i8] c"UNIX - System V\00"
@.str.1 = [23 x i8] c"HP-UX operating system\00"
@.str.2 = [34 x i8] c"Standalone (embedded) application\00"
@.str.3 = [7 x i8] c"Unkown\00"
@reltable.elf_abi = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([34 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.elf_abi to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.elf_abi to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.elf_abi to i64)) to i32)]
define i8* @elf_abi(i8 zeroext %0) {
%2 = add i8 %0, 1
%3 = icmp ult i8 %2, 3
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i8 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.elf_abi to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), %1 ]
ret i8* %9
}