#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 addrinfo {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *, char const *);
int getaddrinfo(char const *, char const *, struct addrinfo const *,
                struct addrinfo **);
char *getxinfo_strerr(int);
int /*<<< orphan*/ stderr;
void xgetaddrinfo(const char *node, const char *service,
                  const struct addrinfo *hints, struct addrinfo **res) {
  int err = getaddrinfo(node, service, hints, res);
  if (err) {
    const char *errstr = getxinfo_strerr(err);
    fprintf(stderr, "Fatal: getaddrinfo(%s:%s): %s\n", node ? node : "",
            service ? service : "", errstr);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<xgetaddrinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1060 <getaddrinfo@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     120f <xgetaddrinfo+0xcf>
mov    -0x24(%rbp),%edi
call   1030 <getxinfo_strerr@plt>
mov    %rax,-0x30(%rbp)
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11aa <xgetaddrinfo+0x6a>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    11ba <xgetaddrinfo+0x7a>
lea    0xe6d(%rip),%rax
mov    %rax,-0x40(%rbp)
jmp    11ba <xgetaddrinfo+0x7a>
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11da <xgetaddrinfo+0x9a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    11ea <xgetaddrinfo+0xaa>
lea    0xe3d(%rip),%rax
mov    %rax,-0x50(%rbp)
jmp    11ea <xgetaddrinfo+0xaa>
mov    -0x48(%rbp),%rdx
mov    -0x34(%rbp),%edi
mov    -0x50(%rbp),%rcx
mov    -0x30(%rbp),%r8
lea    0xe00(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xgetaddrinfo>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1060 <getaddrinfo@plt>
test   %eax,%eax
jne    115b <xgetaddrinfo+0x1b>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %eax,%edi
call   1030 <getxinfo_strerr@plt>
mov    0x2e77(%rip),%rcx
test   %rbx,%rbx
lea    0xeab(%rip),%rdx
cmove  %rdx,%rbx
mov    (%rcx),%edi
test   %r14,%r14
cmove  %rdx,%r14
lea    0xe79(%rip),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    %rax,%r8
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

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

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