const char *ares_strerror(int code) {
  const char *errtext[] = {"Successful completion",
                           "DNS server returned answer with no data",
                           "DNS server claims query was misformatted",
                           "DNS server returned general failure",
                           "Domain name not found",
                           "DNS server does not implement requested operation",
                           "DNS server refused query",
                           "Misformatted DNS query",
                           "Misformatted domain name",
                           "Unsupported address family",
                           "Misformatted DNS reply",
                           "Could not contact DNS servers",
                           "Timeout while contacting DNS servers",
                           "End of file",
                           "Error reading file",
                           "Out of memory",
                           "Channel is being destroyed",
                           "Misformatted string",
                           "Illegal flags specified",
                           "Given hostname is not numeric",
                           "Illegal hints flags specified",
                           "c-ares library initialization not yet performed",
                           "Error loading iphlpapi.dll",
                           "Could not find GetNetworkParams function",
                           "DNS query cancelled"};
  if (code >= 0 && code < (int)(sizeof(errtext) / sizeof(*errtext)))
    return errtext[code];
  else
    return "unknown";
}


x86 assembly (clang, -O0):
<ares_strerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %edi,-0xc(%rbp)
lea    -0xe0(%rbp),%rdi
lea    0x2c24(%rip),%rsi
mov    $0xc8,%edx
call   1030 <memcpy@plt>
cmpl   $0x0,-0xc(%rbp)
jl     115f <ares_strerror+0x4f>
cmpl   $0x19,-0xc(%rbp)
jge    115f <ares_strerror+0x4f>
movslq -0xc(%rbp),%rax
mov    -0xe0(%rbp,%rax,8),%rax
ff
mov    %rax,-0x8(%rbp)
jmp    116a <ares_strerror+0x5a>
lea    0x1163(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ares_strerror>:
cmp    $0x18,%edi
ja     1116 <ares_strerror+0x16>
mov    %edi,%eax
lea    0x11c6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0x11ac(%rip),%rax
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Successful completion\00"
@.str.1 = [40 x i8] c"DNS server returned answer with no data\00"
@.str.2 = [41 x i8] c"DNS server claims query was misformatted\00"
@.str.3 = [36 x i8] c"DNS server returned general failure\00"
@.str.4 = [22 x i8] c"Domain name not found\00"
@.str.5 = [50 x i8] c"DNS server does not implement requested operation\00"
@.str.6 = [25 x i8] c"DNS server refused query\00"
@.str.7 = [23 x i8] c"Misformatted DNS query\00"
@.str.8 = [25 x i8] c"Misformatted domain name\00"
@.str.9 = [27 x i8] c"Unsupported address family\00"
@.str.10 = [23 x i8] c"Misformatted DNS reply\00"
@.str.11 = [30 x i8] c"Could not contact DNS servers\00"
@.str.12 = [37 x i8] c"Timeout while contacting DNS servers\00"
@.str.13 = [12 x i8] c"End of file\00"
@.str.14 = [19 x i8] c"Error reading file\00"
@.str.15 = [14 x i8] c"Out of memory\00"
@.str.16 = [27 x i8] c"Channel is being destroyed\00"
@.str.17 = [20 x i8] c"Misformatted string\00"
@.str.18 = [24 x i8] c"Illegal flags specified\00"
@.str.19 = [30 x i8] c"Given hostname is not numeric\00"
@.str.20 = [30 x i8] c"Illegal hints flags specified\00"
@.str.21 = [48 x i8] c"c-ares library initialization not yet performed\00"
@.str.22 = [27 x i8] c"Error loading iphlpapi.dll\00"
@.str.23 = [41 x i8] c"Could not find GetNetworkParams function\00"
@.str.24 = [20 x i8] c"DNS query cancelled\00"
@__const.ares_strerror.errtext = [25 x i8*] [i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.24, i32 0, i32 0)]
@.str.25 = [8 x i8] c"unknown\00"
define i8* @ares_strerror(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [25 x i8*]
store i32 %0, i32* %3
%5 = bitcast [25 x i8*]* %4 to i8*
%6 = load i32, i32* %3
%7 = icmp sge i32 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %1
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 25
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [25 x i8*], [25 x i8*]* %4, i64 0, i64 %13
%15 = load i8*, i8** %14
store i8* %15, i8** %2
br label %17
16: ; preds = %8, %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.25, i64 0, i64 0), i8** %2
br label %17
17: ; preds = %16, %11
%18 = load i8*, i8** %2
ret i8* %18
}

LLVM IR (-O2):
@.str = [22 x i8] c"Successful completion\00"
@.str.1 = [40 x i8] c"DNS server returned answer with no data\00"
@.str.2 = [41 x i8] c"DNS server claims query was misformatted\00"
@.str.3 = [36 x i8] c"DNS server returned general failure\00"
@.str.4 = [22 x i8] c"Domain name not found\00"
@.str.5 = [50 x i8] c"DNS server does not implement requested operation\00"
@.str.6 = [25 x i8] c"DNS server refused query\00"
@.str.7 = [23 x i8] c"Misformatted DNS query\00"
@.str.8 = [25 x i8] c"Misformatted domain name\00"
@.str.9 = [27 x i8] c"Unsupported address family\00"
@.str.10 = [23 x i8] c"Misformatted DNS reply\00"
@.str.11 = [30 x i8] c"Could not contact DNS servers\00"
@.str.12 = [37 x i8] c"Timeout while contacting DNS servers\00"
@.str.13 = [12 x i8] c"End of file\00"
@.str.14 = [19 x i8] c"Error reading file\00"
@.str.15 = [14 x i8] c"Out of memory\00"
@.str.16 = [27 x i8] c"Channel is being destroyed\00"
@.str.17 = [20 x i8] c"Misformatted string\00"
@.str.18 = [24 x i8] c"Illegal flags specified\00"
@.str.19 = [30 x i8] c"Given hostname is not numeric\00"
@.str.20 = [30 x i8] c"Illegal hints flags specified\00"
@.str.21 = [48 x i8] c"c-ares library initialization not yet performed\00"
@.str.22 = [27 x i8] c"Error loading iphlpapi.dll\00"
@.str.23 = [41 x i8] c"Could not find GetNetworkParams function\00"
@.str.24 = [20 x i8] c"DNS query cancelled\00"
@reltable.ares_strerror = [25 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([40 x i8]* @.str.1 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([41 x i8]* @.str.2 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([36 x i8]* @.str.3 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.4 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([50 x i8]* @.str.5 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.6 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.7 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.8 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.9 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.10 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([30 x i8]* @.str.11 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([37 x i8]* @.str.12 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.13 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.14 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.15 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.16 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.17 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.18 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([30 x i8]* @.str.19 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([30 x i8]* @.str.20 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([48 x i8]* @.str.21 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.22 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([41 x i8]* @.str.23 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.24 to i64), i64 ptrtoint ([25 x i32]* @reltable.ares_strerror to i64)) to i32)]
@.str.25 = [8 x i8] c"unknown\00"
define i8* @ares_strerror(i32 %0) {
%2 = icmp ult i32 %0, 25
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = zext i32 %0 to i64
%5 = shl i64 %4, 2
%6 = call i8* @llvm.load.relative.i64(i8* bitcast ([25 x i32]* @reltable.ares_strerror to i8*), i64 %5)
br label %7
7: ; preds = %1, %3
%8 = phi i8* [ %6, %3 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.25, i64 0, i64 0), %1 ]
ret i8* %8
}