#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 const EAI_SYSTEM;
int /*<<< orphan*/ err(int const, char *, char const *const);
int /*<<< orphan*/ errx(int const, char *, char const *const,
                        int /*<<< orphan*/);
int /*<<< orphan*/ gai_strerror(int const);
void ai_err(const int errval, const int ecode, const char *const msg) {
  if (errval == EAI_SYSTEM)
    err(ecode, "%s", msg);
  else
    errx(ecode, "%s: %s", msg, gai_strerror(errval));
}


x86 assembly (clang, -O0):
<ai_err>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e9c(%rip),%rcx
cmp    (%rcx),%eax
jne    116c <ai_err+0x3c>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rdx
lea    0xea6(%rip),%rsi
call   1050 <err@plt>
jmp    1197 <ai_err+0x67>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <gai_strerror@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rdx
mov    %eax,%ecx
lea    0xe72(%rip),%rsi
call   1030 <errx@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ai_err>:
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%ebp
test   %edi,%edi
je     115a <ai_err+0x2a>
call   1040 <gai_strerror@plt>
lea    0xebc(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %eax,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <errx@plt>
lea    0xea7(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <err@plt>

LLVM IR (-O0):
@EAI_SYSTEM = constant i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [7 x i8] c"%s: %s\00"
define void @ai_err(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%7 = load i32, i32* %4
%8 = load i32, i32* @EAI_SYSTEM
%9 = icmp eq i32 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i32, i32* %5
%12 = load i8*, i8** %6
%13 = call i32 @err(i32 %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %20
14: ; preds = %3
%15 = load i32, i32* %5
%16 = load i8*, i8** %6
%17 = load i32, i32* %4
%18 = call i32 @gai_strerror(i32 %17)
%19 = call i32 @errx(i32 %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32 %18)
br label %20
20: ; preds = %14, %10
ret void
}

LLVM IR (-O2):
@EAI_SYSTEM = constant i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [7 x i8] c"%s: %s\00"
define void @ai_err(i32 %0, i32 %1, i8* %2) {
%4 = icmp eq i32 %0, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @err(i32 %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %10
7: ; preds = %3
%8 = tail call i32 @gai_strerror(i32 %0)
%9 = tail call i32 @errx(i32 %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %2, i32 %8)
br label %10
10: ; preds = %7, %5
ret void
}