const char *sd_strerror(int err) {
  int i;
  static const struct {
    int err;
    const char *desc;
  } errors[] = {
      {0x00, "Success"},
      {0x01, "Unknown error"},
      {0x02, "No object found"},
      {0x03, "I/O error"},
      {0x04, "VDI exists already"},
      {0x05, "Invalid parameters"},
      {0x06, "System error"},
      {0x07, "VDI is already locked"},
      {0x08, "No VDI found"},
      {0x09, "No base VDI found"},
      {0x0A, "Failed to read from requested VDI"},
      {0x0B, "Failed to write to requested VDI"},
      {0x0C, "Failed to read from base VDI"},
      {0x0D, "Failed to write to base VDI"},
      {0x0E, "Failed to find requested tag"},
      {0x0F, "System is still booting"},
      {0x10, "VDI is not locked"},
      {0x11, "System is shutting down"},
      {0x12, "Out of memory on server"},
      {0x13, "Maximum number of VDIs reached"},
      {0x14, "Protocol version mismatch"},
      {0x15, "Server has no space for new objects"},
      {0x16, "Waiting for cluster to be formatted"},
      {0x17, "Waiting for other nodes to join cluster"},
      {0x18, "Node has failed to join cluster"},
      {0x19, "IO has halted as there are too few living nodes"},
      {0x1A, "Cluster is running/halted and cannot be force recovered"},
      {0x20, "Targeted backend store is not found"},
      {0x21, "Operation is not supported"},
      {0x22, "Targeted node is in recovery"},
      {0x81, "Remote node has an old epoch"},
      {0x82, "Remote node has a new epoch"},
      {0x83, "Cluster has not been formatted"},
      {0x84, "Creation times differ"},
      {0x85, "Invalid epoch"},
  };
  for (i = 0; i < (sizeof(errors) / sizeof((errors)[0])); ++i)
    if (errors[i].err == err)
      return errors[i].desc;
  return "Invalid error code";
}


x86 assembly (clang, -O0):
<sd_strerror>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movslq -0x10(%rbp),%rax
cmp    $0x23,%rax
jae    116b <sd_strerror+0x6b>
movslq -0x10(%rbp),%rcx
lea    0x2af9(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%eax
cmp    -0xc(%rbp),%eax
jne    1158 <sd_strerror+0x58>
movslq -0x10(%rbp),%rcx
lea    0x2adc(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    1176 <sd_strerror+0x76>
jmp    115d <sd_strerror+0x5d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    110e <sd_strerror+0xe>
lea    0x1222(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sd_strerror>:
mov    $0x4,%ecx
lea    0x2b54(%rip),%rdx
lea    0x1281(%rip),%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %edi,-0x40(%rdx)
je     1147 <sd_strerror+0x47>
cmp    %edi,-0x30(%rdx)
je     114d <sd_strerror+0x4d>
cmp    %edi,-0x20(%rdx)
je     1153 <sd_strerror+0x53>
cmp    %edi,-0x10(%rdx)
je     1159 <sd_strerror+0x59>
cmp    %edi,(%rdx)
je     115d <sd_strerror+0x5d>
add    $0x5,%rcx
add    $0x50,%rdx
cmp    $0x27,%rcx
jne    1120 <sd_strerror+0x20>
ret
add    $0xfffffffffffffffc,%rcx
jmp    115d <sd_strerror+0x5d>
add    $0xfffffffffffffffd,%rcx
jmp    115d <sd_strerror+0x5d>
add    $0xfffffffffffffffe,%rcx
jmp    115d <sd_strerror+0x5d>
add    $0xffffffffffffffff,%rcx
mov    %ecx,%eax
shl    $0x4,%rax
lea    0x2ab6(%rip),%rcx
mov    0x8(%rax,%rcx,1),%rax
ret

LLVM IR (-O0):
%struct.anon = type { i32, i8* }
@sd_strerror.errors = internal constant [35 x %struct.anon] [%struct.anon { i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0) }, %struct.anon { i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i32 0, i32 0) }, %struct.anon { i32 2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i32 0, i32 0) }, %struct.anon { i32 3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i32 0, i32 0) }, %struct.anon { i32 4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i32 0, i32 0) }, %struct.anon { i32 5, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i32 0, i32 0) }, %struct.anon { i32 6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i32 0, i32 0) }, %struct.anon { i32 7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i32 0, i32 0) }, %struct.anon { i32 8, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i32 0, i32 0) }, %struct.anon { i32 9, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i32 0, i32 0) }, %struct.anon { i32 10, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i32 0, i32 0) }, %struct.anon { i32 11, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i32 0, i32 0) }, %struct.anon { i32 12, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i32 0, i32 0) }, %struct.anon { i32 13, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i32 0, i32 0) }, %struct.anon { i32 14, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.14, i32 0, i32 0) }, %struct.anon { i32 15, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i32 0, i32 0) }, %struct.anon { i32 16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.16, i32 0, i32 0) }, %struct.anon { i32 17, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.17, i32 0, i32 0) }, %struct.anon { i32 18, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i32 0, i32 0) }, %struct.anon { i32 19, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.19, i32 0, i32 0) }, %struct.anon { i32 20, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.20, i32 0, i32 0) }, %struct.anon { i32 21, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.21, i32 0, i32 0) }, %struct.anon { i32 22, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.22, i32 0, i32 0) }, %struct.anon { i32 23, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.23, i32 0, i32 0) }, %struct.anon { i32 24, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.24, i32 0, i32 0) }, %struct.anon { i32 25, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.25, i32 0, i32 0) }, %struct.anon { i32 26, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.26, i32 0, i32 0) }, %struct.anon { i32 32, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.27, i32 0, i32 0) }, %struct.anon { i32 33, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.28, i32 0, i32 0) }, %struct.anon { i32 34, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.29, i32 0, i32 0) }, %struct.anon { i32 129, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.30, i32 0, i32 0) }, %struct.anon { i32 130, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.31, i32 0, i32 0) }, %struct.anon { i32 131, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.32, i32 0, i32 0) }, %struct.anon { i32 132, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.33, i32 0, i32 0) }, %struct.anon { i32 133, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.34, i32 0, i32 0) }]
@.str = [8 x i8] c"Success\00"
@.str.1 = [14 x i8] c"Unknown error\00"
@.str.2 = [16 x i8] c"No object found\00"
@.str.3 = [10 x i8] c"I/O error\00"
@.str.4 = [19 x i8] c"VDI exists already\00"
@.str.5 = [19 x i8] c"Invalid parameters\00"
@.str.6 = [13 x i8] c"System error\00"
@.str.7 = [22 x i8] c"VDI is already locked\00"
@.str.8 = [13 x i8] c"No VDI found\00"
@.str.9 = [18 x i8] c"No base VDI found\00"
@.str.10 = [34 x i8] c"Failed to read from requested VDI\00"
@.str.11 = [33 x i8] c"Failed to write to requested VDI\00"
@.str.12 = [29 x i8] c"Failed to read from base VDI\00"
@.str.13 = [28 x i8] c"Failed to write to base VDI\00"
@.str.14 = [29 x i8] c"Failed to find requested tag\00"
@.str.15 = [24 x i8] c"System is still booting\00"
@.str.16 = [18 x i8] c"VDI is not locked\00"
@.str.17 = [24 x i8] c"System is shutting down\00"
@.str.18 = [24 x i8] c"Out of memory on server\00"
@.str.19 = [31 x i8] c"Maximum number of VDIs reached\00"
@.str.20 = [26 x i8] c"Protocol version mismatch\00"
@.str.21 = [36 x i8] c"Server has no space for new objects\00"
@.str.22 = [36 x i8] c"Waiting for cluster to be formatted\00"
@.str.23 = [40 x i8] c"Waiting for other nodes to join cluster\00"
@.str.24 = [32 x i8] c"Node has failed to join cluster\00"
@.str.25 = [48 x i8] c"IO has halted as there are too few living nodes\00"
@.str.26 = [56 x i8] c"Cluster is running/halted and cannot be force recovered\00"
@.str.27 = [36 x i8] c"Targeted backend store is not found\00"
@.str.28 = [27 x i8] c"Operation is not supported\00"
@.str.29 = [29 x i8] c"Targeted node is in recovery\00"
@.str.30 = [29 x i8] c"Remote node has an old epoch\00"
@.str.31 = [28 x i8] c"Remote node has a new epoch\00"
@.str.32 = [31 x i8] c"Cluster has not been formatted\00"
@.str.33 = [22 x i8] c"Creation times differ\00"
@.str.34 = [14 x i8] c"Invalid epoch\00"
@.str.35 = [19 x i8] c"Invalid error code\00"
define i8* @sd_strerror(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %24, %1
%6 = load i32, i32* %4
%7 = sext i32 %6 to i64
%8 = icmp ult i64 %7, 35
br i1 %8, label %9, label %27
9: ; preds = %5
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [35 x %struct.anon], [35 x %struct.anon]* @sd_strerror.errors, i64 0, i64 %11
%13 = getelementptr inbounds %struct.anon, %struct.anon* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = load i32, i32* %3
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %23
17: ; preds = %9
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [35 x %struct.anon], [35 x %struct.anon]* @sd_strerror.errors, i64 0, i64 %19
%21 = getelementptr inbounds %struct.anon, %struct.anon* %20, i32 0, i32 1
%22 = load i8*, i8** %21
store i8* %22, i8** %2
br label %28
23: ; preds = %9
br label %24
24: ; preds = %23
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %5
27: ; preds = %5
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.35, i64 0, i64 0), i8** %2
br label %28
28: ; preds = %27, %17
%29 = load i8*, i8** %2
ret i8* %29
}

LLVM IR (-O2):
%struct.anon = type { i32, i8* }
@sd_strerror.errors = internal unnamed_addr constant [35 x %struct.anon] [%struct.anon { i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0) }, %struct.anon { i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i32 0, i32 0) }, %struct.anon { i32 2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i32 0, i32 0) }, %struct.anon { i32 3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i32 0, i32 0) }, %struct.anon { i32 4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i32 0, i32 0) }, %struct.anon { i32 5, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i32 0, i32 0) }, %struct.anon { i32 6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i32 0, i32 0) }, %struct.anon { i32 7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i32 0, i32 0) }, %struct.anon { i32 8, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i32 0, i32 0) }, %struct.anon { i32 9, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i32 0, i32 0) }, %struct.anon { i32 10, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i32 0, i32 0) }, %struct.anon { i32 11, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i32 0, i32 0) }, %struct.anon { i32 12, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i32 0, i32 0) }, %struct.anon { i32 13, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i32 0, i32 0) }, %struct.anon { i32 14, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.14, i32 0, i32 0) }, %struct.anon { i32 15, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i32 0, i32 0) }, %struct.anon { i32 16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.16, i32 0, i32 0) }, %struct.anon { i32 17, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.17, i32 0, i32 0) }, %struct.anon { i32 18, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i32 0, i32 0) }, %struct.anon { i32 19, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.19, i32 0, i32 0) }, %struct.anon { i32 20, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.20, i32 0, i32 0) }, %struct.anon { i32 21, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.21, i32 0, i32 0) }, %struct.anon { i32 22, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.22, i32 0, i32 0) }, %struct.anon { i32 23, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.23, i32 0, i32 0) }, %struct.anon { i32 24, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.24, i32 0, i32 0) }, %struct.anon { i32 25, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.25, i32 0, i32 0) }, %struct.anon { i32 26, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.26, i32 0, i32 0) }, %struct.anon { i32 32, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.27, i32 0, i32 0) }, %struct.anon { i32 33, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.28, i32 0, i32 0) }, %struct.anon { i32 34, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.29, i32 0, i32 0) }, %struct.anon { i32 129, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.30, i32 0, i32 0) }, %struct.anon { i32 130, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.31, i32 0, i32 0) }, %struct.anon { i32 131, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.32, i32 0, i32 0) }, %struct.anon { i32 132, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.33, i32 0, i32 0) }, %struct.anon { i32 133, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.34, i32 0, i32 0) }]
@.str = [8 x i8] c"Success\00"
@.str.1 = [14 x i8] c"Unknown error\00"
@.str.2 = [16 x i8] c"No object found\00"
@.str.3 = [10 x i8] c"I/O error\00"
@.str.4 = [19 x i8] c"VDI exists already\00"
@.str.5 = [19 x i8] c"Invalid parameters\00"
@.str.6 = [13 x i8] c"System error\00"
@.str.7 = [22 x i8] c"VDI is already locked\00"
@.str.8 = [13 x i8] c"No VDI found\00"
@.str.9 = [18 x i8] c"No base VDI found\00"
@.str.10 = [34 x i8] c"Failed to read from requested VDI\00"
@.str.11 = [33 x i8] c"Failed to write to requested VDI\00"
@.str.12 = [29 x i8] c"Failed to read from base VDI\00"
@.str.13 = [28 x i8] c"Failed to write to base VDI\00"
@.str.14 = [29 x i8] c"Failed to find requested tag\00"
@.str.15 = [24 x i8] c"System is still booting\00"
@.str.16 = [18 x i8] c"VDI is not locked\00"
@.str.17 = [24 x i8] c"System is shutting down\00"
@.str.18 = [24 x i8] c"Out of memory on server\00"
@.str.19 = [31 x i8] c"Maximum number of VDIs reached\00"
@.str.20 = [26 x i8] c"Protocol version mismatch\00"
@.str.21 = [36 x i8] c"Server has no space for new objects\00"
@.str.22 = [36 x i8] c"Waiting for cluster to be formatted\00"
@.str.23 = [40 x i8] c"Waiting for other nodes to join cluster\00"
@.str.24 = [32 x i8] c"Node has failed to join cluster\00"
@.str.25 = [48 x i8] c"IO has halted as there are too few living nodes\00"
@.str.26 = [56 x i8] c"Cluster is running/halted and cannot be force recovered\00"
@.str.27 = [36 x i8] c"Targeted backend store is not found\00"
@.str.28 = [27 x i8] c"Operation is not supported\00"
@.str.29 = [29 x i8] c"Targeted node is in recovery\00"
@.str.30 = [29 x i8] c"Remote node has an old epoch\00"
@.str.31 = [28 x i8] c"Remote node has a new epoch\00"
@.str.32 = [31 x i8] c"Cluster has not been formatted\00"
@.str.33 = [22 x i8] c"Creation times differ\00"
@.str.34 = [14 x i8] c"Invalid epoch\00"
@.str.35 = [19 x i8] c"Invalid error code\00"
define i8* @sd_strerror(i32 %0) {
br label %2
2: ; preds = %32, %1
%3 = phi i64 [ 0, %1 ], [ %33, %32 ]
%4 = getelementptr inbounds [35 x %struct.anon], [35 x %struct.anon]* @sd_strerror.errors, i64 0, i64 %3, i32 0
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, %0
br i1 %6, label %7, label %12
7: ; preds = %27, %22, %17, %12, %2
%8 = phi i64 [ %3, %2 ], [ %13, %12 ], [ %18, %17 ], [ %23, %22 ], [ %28, %27 ]
%9 = and i64 %8, 4294967295
%10 = getelementptr inbounds [35 x %struct.anon], [35 x %struct.anon]* @sd_strerror.errors, i64 0, i64 %9, i32 1
%11 = load i8*, i8** %10
br label %35
12: ; preds = %2
%13 = add nuw nsw i64 %3, 1
%14 = getelementptr inbounds [35 x %struct.anon], [35 x %struct.anon]* @sd_strerror.errors, i64 0, i64 %13, i32 0
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, %0
br i1 %16, label %7, label %17
17: ; preds = %12
%18 = add nuw nsw i64 %3, 2
%19 = getelementptr inbounds [35 x %struct.anon], [35 x %struct.anon]* @sd_strerror.errors, i64 0, i64 %18, i32 0
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, %0
br i1 %21, label %7, label %22
22: ; preds = %17
%23 = add nuw nsw i64 %3, 3
%24 = getelementptr inbounds [35 x %struct.anon], [35 x %struct.anon]* @sd_strerror.errors, i64 0, i64 %23, i32 0
%25 = load i32, i32* %24
%26 = icmp eq i32 %25, %0
br i1 %26, label %7, label %27
27: ; preds = %22
%28 = add nuw nsw i64 %3, 4
%29 = getelementptr inbounds [35 x %struct.anon], [35 x %struct.anon]* @sd_strerror.errors, i64 0, i64 %28, i32 0
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, %0
br i1 %31, label %7, label %32
32: ; preds = %27
%33 = add nuw nsw i64 %3, 5
%34 = icmp eq i64 %33, 35
br i1 %34, label %35, label %2
35: ; preds = %32, %7
%36 = phi i8* [ %11, %7 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.35, i64 0, i64 0), %32 ]
ret i8* %36
}