#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_FAILURE;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *gai_strerror(int);
int getaddrinfo(char const *, char const *, struct addrinfo *,
                struct addrinfo **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
void get_addrinfo_list(const char *hostname, const char *port_number,
                       struct addrinfo *hints, struct addrinfo **res) {
  assert(hostname != "");
  printf("preparing addrinfo struct...\n");
  int status = getaddrinfo(hostname, port_number, hints, res);
  if (status != 0) {
    fprintf(stderr, "get_addrinfo_list: %s\n", gai_strerror(status));
    exit(EXIT_FAILURE);
  }
  assert(status == 0);
}


x86 assembly (clang, -O0):
<get_addrinfo_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    0xe9e(%rip),%rax
cmp    %rax,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1080 <getaddrinfo@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11f2 <get_addrinfo_list+0x92>
mov    0x2e1b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <gai_strerror@plt>
mov    -0x28(%rbp),%edi
mov    %rax,%rdx
lea    0xe3f(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
cmpl   $0x0,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_addrinfo_list>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0xe9b(%rip),%rax
xor    %edi,%edi
cmp    %rax,%rbx
setne  %dil
call   1050 <assert@plt>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1080 <getaddrinfo@plt>
test   %eax,%eax
jne    11bf <get_addrinfo_list+0x5f>
mov    $0x1,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <assert@plt>
mov    0x2e1a(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1040 <gai_strerror@plt>
lea    0xe2a(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1060 <fprintf@plt>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [30 x i8] c"preparing addrinfo struct...\0A\00"
@stderr = global i32 0
@.str.2 = [23 x i8] c"get_addrinfo_list: %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @get_addrinfo_list(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
store i8* %0, i8** %5
store i8* %1, i8** %6
store %struct.addrinfo* %2, %struct.addrinfo** %7
store %struct.addrinfo** %3, %struct.addrinfo*** %8
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%15 = load i8*, i8** %5
%16 = load i8*, i8** %6
%17 = load %struct.addrinfo*, %struct.addrinfo** %7
%18 = load %struct.addrinfo**, %struct.addrinfo*** %8
%19 = call i32 @getaddrinfo(i8* %15, i8* %16, %struct.addrinfo* %17, %struct.addrinfo** %18)
store i32 %19, i32* %9
%20 = load i32, i32* %9
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %4
%23 = load i32, i32* @stderr
%24 = load i32, i32* %9
%25 = call i8* @gai_strerror(i32 %24)
%26 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %4
%30 = load i32, i32* %9
%31 = icmp eq i32 %30, 0
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
ret void
}

LLVM IR (-O2):
%struct.addrinfo = type { i32 }
@.str = [1 x i8] zeroinitializer
@stderr = global i32 0
@.str.2 = [23 x i8] c"get_addrinfo_list: %s\0A\00"
@EXIT_FAILURE = global i32 0
@str = [29 x i8] c"preparing addrinfo struct...\00"
define void @get_addrinfo_list(i8* %0, i8* %1, %struct.addrinfo* %2, %struct.addrinfo** %3) {
%5 = icmp ne i8* %0, getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @getaddrinfo(i8* %0, i8* %1, %struct.addrinfo* %2, %struct.addrinfo** %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %4
%12 = load i32, i32* @stderr
%13 = tail call i8* @gai_strerror(i32 %9)
%14 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %4
%18 = tail call i32 @assert(i32 1)
ret void
}