const char *strerr(int error_code) {
  switch (error_code) {
  case 20:
    return "Out of memory";
  case 30:
    return "No such file/directory";
  case 31:
    return "Permission denied";
  case 32:
    return "File exists";
  case 33:
    return "Not a directory";
  case 34:
    return "Is a directory";
  case 35:
    return "File name too long";
  case 36:
    return "Invalid path/device name";
  case 40:
    return "No such device";
  case 41:
    return "Device already registered";
  case 42:
    return "I/O error";
  case 43:
    return "Not a block device";
  case 44:
    return "Device busy";
  default:
    return "Unknown error";
  }
}


x86 assembly (clang, -O0):
<strerr>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffec,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x18,%eax
ja     1200 <strerr+0x100>
mov    -0x18(%rbp),%rax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf2d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <strerr+0x10b>
lea    0xf2b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <strerr+0x10b>
lea    0xf32(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <strerr+0x10b>
lea    0xf34(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <strerr+0x10b>
lea    0xf30(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <strerr+0x10b>
lea    0xf30(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <strerr+0x10b>
lea    0xf2f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <strerr+0x10b>
lea    0xf32(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <strerr+0x10b>
lea    0xf3b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <strerr+0x10b>
lea    0xf3a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <strerr+0x10b>
lea    0xf44(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <strerr+0x10b>
lea    0xf3e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <strerr+0x10b>
lea    0xf41(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <strerr+0x10b>
lea    0xf3d(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strerr>:
add    $0xffffffec,%edi
cmp    $0x18,%edi
ja     111a <strerr+0x1a>
movslq %edi,%rax
lea    0xfde(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xfbf(%rip),%rax
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Out of memory\00"
@.str.1 = [23 x i8] c"No such file/directory\00"
@.str.2 = [18 x i8] c"Permission denied\00"
@.str.3 = [12 x i8] c"File exists\00"
@.str.4 = [16 x i8] c"Not a directory\00"
@.str.5 = [15 x i8] c"Is a directory\00"
@.str.6 = [19 x i8] c"File name too long\00"
@.str.7 = [25 x i8] c"Invalid path/device name\00"
@.str.8 = [15 x i8] c"No such device\00"
@.str.9 = [26 x i8] c"Device already registered\00"
@.str.10 = [10 x i8] c"I/O error\00"
@.str.11 = [19 x i8] c"Not a block device\00"
@.str.12 = [12 x i8] c"Device busy\00"
@.str.13 = [14 x i8] c"Unknown error\00"
define i8* @strerr(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %18 [
i32 20, label %5
i32 30, label %6
i32 31, label %7
i32 32, label %8
i32 33, label %9
i32 34, label %10
i32 35, label %11
i32 36, label %12
i32 40, label %13
i32 41, label %14
i32 42, label %15
i32 43, label %16
i32 44, label %17
]
5: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %2
br label %19
6: ; preds = %1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %19
7: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %19
8: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %19
9: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %19
10: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %19
11: ; preds = %1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %19
12: ; preds = %1
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %19
13: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %19
14: ; preds = %1
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %19
15: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %19
16: ; preds = %1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %19
17: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %19
18: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %19
19: ; preds = %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%20 = load i8*, i8** %2
ret i8* %20
}

LLVM IR (-O2):
@.str = [14 x i8] c"Out of memory\00"
@.str.1 = [23 x i8] c"No such file/directory\00"
@.str.2 = [18 x i8] c"Permission denied\00"
@.str.3 = [12 x i8] c"File exists\00"
@.str.4 = [16 x i8] c"Not a directory\00"
@.str.5 = [15 x i8] c"Is a directory\00"
@.str.6 = [19 x i8] c"File name too long\00"
@.str.7 = [25 x i8] c"Invalid path/device name\00"
@.str.8 = [15 x i8] c"No such device\00"
@.str.9 = [26 x i8] c"Device already registered\00"
@.str.10 = [10 x i8] c"I/O error\00"
@.str.11 = [19 x i8] c"Not a block device\00"
@.str.12 = [12 x i8] c"Device busy\00"
@.str.13 = [14 x i8] c"Unknown error\00"
@reltable.strerr = [25 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.13 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.13 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.13 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.13 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.13 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.13 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.13 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.13 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.13 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.1 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.2 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.3 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.4 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.5 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.6 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.7 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.13 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.13 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.13 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.8 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.9 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.10 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.11 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.12 to i64), i64 ptrtoint ([25 x i32]* @reltable.strerr to i64)) to i32)]
define i8* @strerr(i32 %0) {
%2 = add i32 %0, -20
%3 = icmp ult i32 %2, 25
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([25 x i32]* @reltable.strerr to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), %1 ]
ret i8* %9
}