#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 /*<<< orphan*/ fatal(char *, int /*<<< orphan*/);
int /*<<< orphan*/ gai_strerror(int);
int getnameinfo_ex(struct sockaddr const *, int /*<<< orphan*/, char *, size_t,
                   _Bool);
void xgetnameinfo_ex(const struct sockaddr *sa, socklen_t len, char *str,
                     size_t size, _Bool numeric_mode) {
  int err = getnameinfo_ex(sa, len, str, size, numeric_mode);
  if (err != 0) {
    fatal(("getnameinfo failed: %s"), gai_strerror(err));
  }
}


x86 assembly (clang, -O0):
<xgetnameinfo_ex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r8b,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
and    $0x1,%al
mov    %al,-0x21(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%r8d
call   1030 <getnameinfo_ex@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     118f <xgetnameinfo_ex+0x5f>
mov    -0x28(%rbp),%edi
call   1040 <gai_strerror@plt>
mov    %eax,%esi
lea    0xe76(%rip),%rdi
call   1050 <fatal@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xgetnameinfo_ex>:
push   %rax
call   1030 <getnameinfo_ex@plt>
test   %eax,%eax
je     1150 <xgetnameinfo_ex+0x20>
mov    %eax,%edi
call   1040 <gai_strerror@plt>
lea    0xeb8(%rip),%rdi
mov    %eax,%esi
pop    %rax
jmp    1050 <fatal@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
@.str = [23 x i8] c"getnameinfo failed: %s\00"
define void @xgetnameinfo_ex(%struct.sockaddr* %0, i32 %1, i8* %2, i64 %3, i1 zeroext %4) {
%6 = alloca %struct.sockaddr*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8
%11 = alloca i32
store %struct.sockaddr* %0, %struct.sockaddr** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i64 %3, i64* %9
%12 = zext i1 %4 to i8
store i8 %12, i8* %10
%13 = load %struct.sockaddr*, %struct.sockaddr** %6
%14 = load i32, i32* %7
%15 = load i8*, i8** %8
%16 = load i64, i64* %9
%17 = load i8, i8* %10
%18 = trunc i8 %17 to i1
%19 = call i32 @getnameinfo_ex(%struct.sockaddr* %13, i32 %14, i8* %15, i64 %16, i1 zeroext %18)
store i32 %19, i32* %11
%20 = load i32, i32* %11
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %5
%23 = load i32, i32* %11
%24 = call i32 @gai_strerror(i32 %23)
%25 = call i32 @fatal(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %22, %5
ret void
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
@.str = [23 x i8] c"getnameinfo failed: %s\00"
define void @xgetnameinfo_ex(%struct.sockaddr* %0, i32 %1, i8* %2, i64 %3, i1 zeroext %4) {
%6 = tail call i32 @getnameinfo_ex(%struct.sockaddr* %0, i32 %1, i8* %2, i64 %3, i1 zeroext %4)
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = tail call i32 @gai_strerror(i32 %6)
%10 = tail call i32 @fatal(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %8, %5
ret void
}