#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ errtext;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
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",
                           "Destructing"};
  assert(code >= 0 && code < (sizeof(errtext) / sizeof(*errtext)));
  return errtext[code];
}


x86 assembly (clang, -O0):
<ares_strerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
lea    0x2c54(%rip),%rsi
mov    $0x88,%edx
call   1040 <memcpy@plt>
xor    %eax,%eax
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x91(%rbp)
jl     1169 <ares_strerror+0x49>
movslq -0x4(%rbp),%rax
cmp    $0x11,%rax
setb   %al
mov    %al,-0x91(%rbp)
mov    -0x91(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movslq -0x4(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rax
ff
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ares_strerror>:
push   %rbx
movslq %edi,%rbx
xor    %edi,%edi
cmp    $0x11,%ebx
setb   %dil
call   1030 <assert@plt>
lea    0x10a3(%rip),%rcx
movslq (%rcx,%rbx,4),%rax
add    %rcx,%rax
pop    %rbx
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 = [12 x i8] c"Destructing\00"
@__const.ares_strerror.errtext = [17 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 ([12 x i8], [12 x i8]* @.str.16, i32 0, i32 0)]
define i8* @ares_strerror(i32 %0) {
%2 = alloca i32
%3 = alloca [17 x i8*]
store i32 %0, i32* %2
%4 = bitcast [17 x i8*]* %3 to i8*
%5 = load i32, i32* %2
%6 = icmp sge i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* %2
%9 = sext i32 %8 to i64
%10 = icmp ult i64 %9, 17
br label %11
11: ; preds = %7, %1
%12 = phi i1 [ false, %1 ], [ %10, %7 ]
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [17 x i8*], [17 x i8*]* %3, i64 0, i64 %16
%18 = load i8*, i8** %17
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 = [12 x i8] c"Destructing\00"
@reltable.ares_strerror = [17 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([40 x i8]* @.str.1 to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([41 x i8]* @.str.2 to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([36 x i8]* @.str.3 to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.4 to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([50 x i8]* @.str.5 to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.6 to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.7 to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.8 to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.9 to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.10 to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([30 x i8]* @.str.11 to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([37 x i8]* @.str.12 to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.13 to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.14 to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.15 to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.16 to i64), i64 ptrtoint ([17 x i32]* @reltable.ares_strerror to i64)) to i32)]
define i8* @ares_strerror(i32 %0) {
%2 = sext i32 %0 to i64
%3 = icmp ult i32 %0, 17
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = shl i64 %2, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([17 x i32]* @reltable.ares_strerror to i8*), i64 %6)
ret i8* %7
}