#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, char **memptr) {
  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"};
  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)
mov    %rsi,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
lea    0x2c60(%rip),%rsi
mov    $0x80,%edx
call   1040 <memcpy@plt>
xor    %eax,%eax
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x91(%rbp)
jl     116d <ares_strerror+0x4d>
movslq -0x4(%rbp),%rax
cmp    $0x10,%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    $0x10,%ebx
setb   %dil
call   1030 <assert@plt>
lea    0x1097(%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"
@__const.ares_strerror.errtext = [16 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)]
define i8* @ares_strerror(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [16 x i8*]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = bitcast [16 x i8*]* %5 to i8*
%7 = load i32, i32* %3
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = icmp ult i64 %11, 16
br label %13
13: ; preds = %9, %2
%14 = phi i1 [ false, %2 ], [ %12, %9 ]
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [16 x i8*], [16 x i8*]* %5, i64 0, i64 %18
%20 = load i8*, i8** %19
ret i8* %20
}

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"
@reltable.ares_strerror = [16 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([40 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([41 x i8]* @.str.2 to i64), i64 ptrtoint ([16 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([36 x i8]* @.str.3 to i64), i64 ptrtoint ([16 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.4 to i64), i64 ptrtoint ([16 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([50 x i8]* @.str.5 to i64), i64 ptrtoint ([16 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.6 to i64), i64 ptrtoint ([16 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.7 to i64), i64 ptrtoint ([16 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.8 to i64), i64 ptrtoint ([16 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.9 to i64), i64 ptrtoint ([16 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.10 to i64), i64 ptrtoint ([16 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([30 x i8]* @.str.11 to i64), i64 ptrtoint ([16 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([37 x i8]* @.str.12 to i64), i64 ptrtoint ([16 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.13 to i64), i64 ptrtoint ([16 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.14 to i64), i64 ptrtoint ([16 x i32]* @reltable.ares_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.15 to i64), i64 ptrtoint ([16 x i32]* @reltable.ares_strerror to i64)) to i32)]
define i8* @ares_strerror(i32 %0, i8** nocapture readnone %1) {
%3 = sext i32 %0 to i64
%4 = icmp ult i32 %0, 16
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = shl i64 %3, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([16 x i32]* @reltable.ares_strerror to i8*), i64 %7)
ret i8* %8
}