#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 */

/* Variables and functions */
#define HOST_NOT_FOUND 131
#define NO_DATA 130
#define NO_RECOVERY 129
#define TRY_AGAIN 128
int /*<<< orphan*/ sprintf(char *, char *, int);
const char *githstrerror(int err) {
  static char buffer[48];
  switch (err) {
  case HOST_NOT_FOUND:
    return "Authoritative answer: host not found";
  case NO_DATA:
    return "Valid name, no data record of requested type";
  case NO_RECOVERY:
    return "Non recoverable errors, FORMERR, REFUSED, NOTIMP";
  case TRY_AGAIN:
    return "Non-authoritative \"host not found\", or SERVERFAIL";
  }
  sprintf(buffer, "Name resolution error %d", err);
  return buffer;
}


x86 assembly (clang, -O0):
<githstrerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     1184 <githstrerror+0x74>
mov    -0x18(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xec5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a5 <githstrerror+0x95>
lea    0xeda(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a5 <githstrerror+0x95>
lea    0xef7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a5 <githstrerror+0x95>
lea    0xf18(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a5 <githstrerror+0x95>
mov    -0xc(%rbp),%edx
lea    0x2eb2(%rip),%rdi
lea    0xf30(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2e9f(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<githstrerror>:
push   %rbx
mov    %edi,%edx
lea    -0x80(%rdx),%eax
cmp    $0x4,%eax
jae    112d <githstrerror+0x1d>
cltq
lea    0xfac(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    1143 <githstrerror+0x33>
lea    0x2f0c(%rip),%rbx
lea    0xf7a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@githstrerror.buffer = internal global [48 x i8] zeroinitializer
@.str = [37 x i8] c"Authoritative answer: host not found\00"
@.str.1 = [45 x i8] c"Valid name, no data record of requested type\00"
@.str.2 = [49 x i8] c"Non recoverable errors, FORMERR, REFUSED, NOTIMP\00"
@.str.3 = [50 x i8] c"Non-authoritative \22host not found\22, or SERVERFAIL\00"
@.str.4 = [25 x i8] c"Name resolution error %d\00"
define i8* @githstrerror(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %9 [
i32 131, label %5
i32 130, label %6
i32 129, label %7
i32 128, label %8
]
5: ; preds = %1
store i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8** %2
br label %12
6: ; preds = %1
store i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %12
7: ; preds = %1
store i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %12
8: ; preds = %1
store i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %12
9: ; preds = %1
%10 = load i32, i32* %3
%11 = call i32 @sprintf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @githstrerror.buffer, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %10)
store i8* getelementptr inbounds ([48 x i8], [48 x i8]* @githstrerror.buffer, i64 0, i64 0), i8** %2
br label %12
12: ; preds = %9, %8, %7, %6, %5
%13 = load i8*, i8** %2
ret i8* %13
}

LLVM IR (-O2):
@githstrerror.buffer = internal global [48 x i8] zeroinitializer
@.str = [37 x i8] c"Authoritative answer: host not found\00"
@.str.1 = [45 x i8] c"Valid name, no data record of requested type\00"
@.str.2 = [49 x i8] c"Non recoverable errors, FORMERR, REFUSED, NOTIMP\00"
@.str.3 = [50 x i8] c"Non-authoritative \22host not found\22, or SERVERFAIL\00"
@.str.4 = [25 x i8] c"Name resolution error %d\00"
@reltable.githstrerror = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([50 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.githstrerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([49 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.githstrerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([45 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.githstrerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([37 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.githstrerror to i64)) to i32)]
define i8* @githstrerror(i32 %0) {
%2 = add i32 %0, -128
%3 = icmp ult i32 %2, 4
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @githstrerror.buffer, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %0)
br label %10
6: ; preds = %1
%7 = sext i32 %2 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.githstrerror to i8*), i64 %8)
br label %10
10: ; preds = %6, %4
%11 = phi i8* [ getelementptr inbounds ([48 x i8], [48 x i8]* @githstrerror.buffer, i64 0, i64 0), %4 ], [ %9, %6 ]
ret i8* %11
}