#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 */
int /*<<< orphan*/ pcap_snprintf(char *, int, char *, int);
const char *pcap_strerror(int errnum) {
  extern int sys_nerr;
  extern const char *const sys_errlist[];
  static char ebuf[20];
  if ((unsigned int)errnum < sys_nerr)
    return ((char *)sys_errlist[errnum]);
  (void)pcap_snprintf(ebuf, sizeof ebuf, "Unknown error: %d", errnum);
  return (ebuf);
}


x86 assembly (clang, -O0):
<pcap_strerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2ec3(%rip),%rcx
cmp    (%rcx),%eax
jae    1145 <pcap_strerror+0x35>
movslq -0xc(%rbp),%rcx
mov    0x2ec0(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
jmp    116b <pcap_strerror+0x5b>
mov    -0xc(%rbp),%ecx
lea    0x2ef1(%rip),%rdi
mov    $0x14,%esi
lea    0xea5(%rip),%rdx
call   1030 <pcap_snprintf@plt>
lea    0x2ed9(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pcap_strerror>:
push   %rbx
mov    %edi,%ecx
mov    0x2ece(%rip),%rax
cmp    %edi,(%rax)
jbe    112e <pcap_strerror+0x1e>
movslq %ecx,%rax
mov    0x2ed0(%rip),%rcx
mov    (%rcx,%rax,8),%rbx
jmp    1149 <pcap_strerror+0x39>
lea    0x2f0b(%rip),%rbx
lea    0xec4(%rip),%rdx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1030 <pcap_snprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@pcap_strerror.ebuf = internal global [20 x i8] zeroinitializer
@sys_nerr = external global i32
@sys_errlist = external constant [0 x i8*]
@.str = [18 x i8] c"Unknown error: %d\00"
define i8* @pcap_strerror(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = load i32, i32* @sys_nerr
%6 = icmp ult i32 %4, %5
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [0 x i8*], [0 x i8*]* @sys_errlist, i64 0, i64 %9
%11 = load i8*, i8** %10
store i8* %11, i8** %2
br label %15
12: ; preds = %1
%13 = load i32, i32* %3
%14 = call i32 @pcap_snprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @pcap_strerror.ebuf, i64 0, i64 0), i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %13)
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @pcap_strerror.ebuf, i64 0, i64 0), i8** %2
br label %15
15: ; preds = %12, %7
%16 = load i8*, i8** %2
ret i8* %16
}

LLVM IR (-O2):
@pcap_strerror.ebuf = internal global [20 x i8] zeroinitializer
@sys_nerr = external global i32
@sys_errlist = external constant [0 x i8*]
@.str = [18 x i8] c"Unknown error: %d\00"
define i8* @pcap_strerror(i32 %0) {
%2 = load i32, i32* @sys_nerr
%3 = icmp ugt i32 %2, %0
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %0 to i64
%6 = getelementptr inbounds [0 x i8*], [0 x i8*]* @sys_errlist, i64 0, i64 %5
%7 = load i8*, i8** %6
br label %10
8: ; preds = %1
%9 = tail call i32 @pcap_snprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @pcap_strerror.ebuf, i64 0, i64 0), i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %10
10: ; preds = %8, %4
%11 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @pcap_strerror.ebuf, i64 0, i64 0), %8 ]
ret i8* %11
}