#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 */
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;

/* Variables and functions */
int NI_NUMERICHOST;
int NI_NUMERICSERV;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int getnameinfo(struct sockaddr const *, int /*<<< orphan*/, char *,
                int /*<<< orphan*/, char *, int /*<<< orphan*/, int);
char *getxinfo_strerr(int);
int /*<<< orphan*/ stderr;
void xgetnameinfo(const struct sockaddr *addr, socklen_t addrlen, char *host,
                  socklen_t hostlen, char *serv, socklen_t servlen) {
  int flags = NI_NUMERICHOST | NI_NUMERICSERV;
  int err = getnameinfo(addr, addrlen, host, hostlen, serv, servlen, flags);
  if (err) {
    const char *errstr = getxinfo_strerr(err);
    fprintf(stderr, "Fatal: getnameinfo: %s\n", errstr);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<xgetnameinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    0x2e6b(%rip),%rax
mov    (%rax),%eax
mov    0x2e7a(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%r8
mov    -0x2c(%rbp),%r9d
mov    -0x30(%rbp),%eax
mov    %eax,(%rsp)
call   1030 <getnameinfo@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     11d0 <xgetnameinfo+0x90>
mov    -0x34(%rbp),%edi
call   1040 <getxinfo_strerr@plt>
mov    %rax,-0x40(%rbp)
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rdx
lea    0xe3f(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xgetnameinfo>:
push   %rax
mov    0x2e88(%rip),%r10
mov    0x2e99(%rip),%rax
mov    (%rax),%eax
or     (%r10),%eax
mov    %eax,(%rsp)
call   1030 <getnameinfo@plt>
test   %eax,%eax
jne    1162 <xgetnameinfo+0x22>
pop    %rax
ret
mov    %eax,%edi
call   1040 <getxinfo_strerr@plt>
mov    0x2e68(%rip),%rcx
mov    (%rcx),%edi
lea    0xe87(%rip),%rsi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
@NI_NUMERICHOST = global i32 0
@NI_NUMERICSERV = global i32 0
@stderr = global i32 0
@.str = [24 x i8] c"Fatal: getnameinfo: %s\0A\00"
define void @xgetnameinfo(%struct.sockaddr* %0, i32 %1, i8* %2, i32 %3, i8* %4, i32 %5) {
%7 = alloca %struct.sockaddr*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
store %struct.sockaddr* %0, %struct.sockaddr** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i32 %5, i32* %12
%16 = load i32, i32* @NI_NUMERICHOST
%17 = load i32, i32* @NI_NUMERICSERV
%18 = or i32 %16, %17
store i32 %18, i32* %13
%19 = load %struct.sockaddr*, %struct.sockaddr** %7
%20 = load i32, i32* %8
%21 = load i8*, i8** %9
%22 = load i32, i32* %10
%23 = load i8*, i8** %11
%24 = load i32, i32* %12
%25 = load i32, i32* %13
%26 = call i32 @getnameinfo(%struct.sockaddr* %19, i32 %20, i8* %21, i32 %22, i8* %23, i32 %24, i32 %25)
store i32 %26, i32* %14
%27 = load i32, i32* %14
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %6
%30 = load i32, i32* %14
%31 = call i8* @getxinfo_strerr(i32 %30)
store i8* %31, i8** %15
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %15
%34 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %33)
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %6
ret void
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
@NI_NUMERICHOST = global i32 0
@NI_NUMERICSERV = global i32 0
@stderr = global i32 0
@.str = [24 x i8] c"Fatal: getnameinfo: %s\0A\00"
define void @xgetnameinfo(%struct.sockaddr* %0, i32 %1, i8* %2, i32 %3, i8* %4, i32 %5) {
%7 = load i32, i32* @NI_NUMERICHOST
%8 = load i32, i32* @NI_NUMERICSERV
%9 = or i32 %8, %7
%10 = tail call i32 @getnameinfo(%struct.sockaddr* %0, i32 %1, i8* %2, i32 %3, i8* %4, i32 %5, i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %6
%13 = tail call i8* @getxinfo_strerr(i32 %10)
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %13)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %6
ret void
}