const char *bladerf_strerror(int error) {
  switch (error) {
  case (-1):
    return "An unexpected error occurred";
  case (-2):
    return "Provided parameter was out of the allowable range";
  case (-3):
    return "Invalid operation or parameter";
  case (-4):
    return "A memory allocation error occurred";
  case (-5):
    return "File or device I/O failure";
  case (-6):
    return "Operation timed out";
  case (-7):
    return "No devices available";
  case (-8):
    return "Operation not supported";
  case (-9):
    return "Misaligned flash access";
  case (-10):
    return "Invalid checksum";
  case (-11):
    return "File not found";
  case (-12):
    return "An FPGA update is required";
  case (-13):
    return "A firmware update is required";
  case (-14):
    return "Requested timestamp is in the past";
  case (-15):
    return "Could not enqueue data into full queue";
  case (-16):
    return "An FPGA operation reported a failure";
  case (-17):
    return "Insufficient permissions for the requested operation";
  case (-18):
    return "The operation would block, but has been requested to be "
           "non-blocking";
  case 0:
    return "Success";
  default:
    return "Unknown error code";
  }
}


x86 assembly (clang, -O0):
<bladerf_strerror>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x12,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x12,%eax
ja     1260 <bladerf_strerror+0x160>
mov    -0x18(%rbp),%rax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf15(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0xf22(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0xf44(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0xf53(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0xf66(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0xf71(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0xf75(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0xf7a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0xf82(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0xf8a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0xf8b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0xf8a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0xf95(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0xfa3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0xfb6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0xfcd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0xfe2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0x1007(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0x103c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <bladerf_strerror+0x16b>
lea    0x1034(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bladerf_strerror>:
add    $0x12,%edi
cmp    $0x12,%edi
ja     111a <bladerf_strerror+0x1a>
movslq %edi,%rax
lea    0x1152(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0x112e(%rip),%rax
ret

LLVM IR (-O0):
@.str = [29 x i8] c"An unexpected error occurred\00"
@.str.1 = [50 x i8] c"Provided parameter was out of the allowable range\00"
@.str.2 = [31 x i8] c"Invalid operation or parameter\00"
@.str.3 = [35 x i8] c"A memory allocation error occurred\00"
@.str.4 = [27 x i8] c"File or device I/O failure\00"
@.str.5 = [20 x i8] c"Operation timed out\00"
@.str.6 = [21 x i8] c"No devices available\00"
@.str.7 = [24 x i8] c"Operation not supported\00"
@.str.8 = [24 x i8] c"Misaligned flash access\00"
@.str.9 = [17 x i8] c"Invalid checksum\00"
@.str.10 = [15 x i8] c"File not found\00"
@.str.11 = [27 x i8] c"An FPGA update is required\00"
@.str.12 = [30 x i8] c"A firmware update is required\00"
@.str.13 = [35 x i8] c"Requested timestamp is in the past\00"
@.str.14 = [39 x i8] c"Could not enqueue data into full queue\00"
@.str.15 = [37 x i8] c"An FPGA operation reported a failure\00"
@.str.16 = [53 x i8] c"Insufficient permissions for the requested operation\00"
@.str.17 = [69 x i8] c"The operation would block, but has been requested to be non-blocking\00"
@.str.18 = [8 x i8] c"Success\00"
@.str.19 = [19 x i8] c"Unknown error code\00"
define i8* @bladerf_strerror(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %24 [
i32 -1, label %5
i32 -2, label %6
i32 -3, label %7
i32 -4, label %8
i32 -5, label %9
i32 -6, label %10
i32 -7, label %11
i32 -8, label %12
i32 -9, label %13
i32 -10, label %14
i32 -11, label %15
i32 -12, label %16
i32 -13, label %17
i32 -14, label %18
i32 -15, label %19
i32 -16, label %20
i32 -17, label %21
i32 -18, label %22
i32 0, label %23
]
5: ; preds = %1
store i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8** %2
br label %25
6: ; preds = %1
store i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %25
7: ; preds = %1
store i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %25
8: ; preds = %1
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %25
9: ; preds = %1
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %25
10: ; preds = %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %25
11: ; preds = %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %25
12: ; preds = %1
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %25
13: ; preds = %1
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %25
14: ; preds = %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %25
15: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %25
16: ; preds = %1
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %25
17: ; preds = %1
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %25
18: ; preds = %1
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %25
19: ; preds = %1
store i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.14, i64 0, i64 0), i8** %2
br label %25
20: ; preds = %1
store i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.15, i64 0, i64 0), i8** %2
br label %25
21: ; preds = %1
store i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.16, i64 0, i64 0), i8** %2
br label %25
22: ; preds = %1
store i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.17, i64 0, i64 0), i8** %2
br label %25
23: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i64 0, i64 0), i8** %2
br label %25
24: ; preds = %1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.19, i64 0, i64 0), i8** %2
br label %25
25: ; preds = %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%26 = load i8*, i8** %2
ret i8* %26
}

LLVM IR (-O2):
@.str = [29 x i8] c"An unexpected error occurred\00"
@.str.1 = [50 x i8] c"Provided parameter was out of the allowable range\00"
@.str.2 = [31 x i8] c"Invalid operation or parameter\00"
@.str.3 = [35 x i8] c"A memory allocation error occurred\00"
@.str.4 = [27 x i8] c"File or device I/O failure\00"
@.str.5 = [20 x i8] c"Operation timed out\00"
@.str.6 = [21 x i8] c"No devices available\00"
@.str.7 = [24 x i8] c"Operation not supported\00"
@.str.8 = [24 x i8] c"Misaligned flash access\00"
@.str.9 = [17 x i8] c"Invalid checksum\00"
@.str.10 = [15 x i8] c"File not found\00"
@.str.11 = [27 x i8] c"An FPGA update is required\00"
@.str.12 = [30 x i8] c"A firmware update is required\00"
@.str.13 = [35 x i8] c"Requested timestamp is in the past\00"
@.str.14 = [39 x i8] c"Could not enqueue data into full queue\00"
@.str.15 = [37 x i8] c"An FPGA operation reported a failure\00"
@.str.16 = [53 x i8] c"Insufficient permissions for the requested operation\00"
@.str.17 = [69 x i8] c"The operation would block, but has been requested to be non-blocking\00"
@.str.18 = [8 x i8] c"Success\00"
@.str.19 = [19 x i8] c"Unknown error code\00"
@reltable.bladerf_strerror = [19 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([69 x i8]* @.str.17 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([53 x i8]* @.str.16 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([37 x i8]* @.str.15 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([39 x i8]* @.str.14 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([35 x i8]* @.str.13 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([30 x i8]* @.str.12 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.11 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.10 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.9 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.8 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.7 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.6 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.5 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.4 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([35 x i8]* @.str.3 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @.str.2 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([50 x i8]* @.str.1 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([29 x i8]* @.str to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.18 to i64), i64 ptrtoint ([19 x i32]* @reltable.bladerf_strerror to i64)) to i32)]
define i8* @bladerf_strerror(i32 %0) {
%2 = add i32 %0, 18
%3 = icmp ult i32 %2, 19
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 ([19 x i32]* @reltable.bladerf_strerror to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.19, i64 0, i64 0), %1 ]
ret i8* %9
}