#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 /*<<< orphan*/ ai_canonname;
};
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
scalar_t__ addrinfo_addr_port(struct addrinfo *, char *, int, int *);
int /*<<< orphan*/ dump(char *, char *, ...);
void dump_addrinfo(struct addrinfo *ai) {
  char addr[128];
  int port;
  dump("%s", ai->ai_canonname);
  if (addrinfo_addr_port(ai, addr, sizeof(addr), &port))
    dump(" (%s) port %d", addr, port);
}


x86 assembly (clang, -O0):
<dump_addrinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movslq (%rax),%rsi
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <dump@plt>
mov    -0x8(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    $0x80,%edx
lea    -0x94(%rbp),%rcx
call   1040 <addrinfo_addr_port@plt>
cmp    $0x0,%rax
je     1185 <dump_addrinfo+0x65>
lea    -0x90(%rbp),%rsi
mov    -0x94(%rbp),%edx
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <dump@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_addrinfo>:
push   %rbx
sub    $0x90,%rsp
mov    %rdi,%rbx
movslq (%rdi),%rsi
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1030 <dump@plt>
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
mov    $0x80,%edx
call   1040 <addrinfo_addr_port@plt>
test   %rax,%rax
je     116f <dump_addrinfo+0x4f>
mov    0xc(%rsp),%edx
lea    0xea0(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1030 <dump@plt>
add    $0x90,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.addrinfo = type { i32 }
@.str = [3 x i8] c"%s\00"
@.str.1 = [14 x i8] c" (%s) port %d\00"
define void @dump_addrinfo(%struct.addrinfo* %0) {
%2 = alloca %struct.addrinfo*
%3 = alloca [128 x i8]
%4 = alloca i32
store %struct.addrinfo* %0, %struct.addrinfo** %2
%5 = load %struct.addrinfo*, %struct.addrinfo** %2
%6 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i32 0, i32 0
%7 = load i32, i32* %6
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i8*
%10 = call i32 (i8*, i8*, ...) @dump(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load %struct.addrinfo*, %struct.addrinfo** %2
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%13 = call i64 @addrinfo_addr_port(%struct.addrinfo* %11, i8* %12, i32 128, i32* %4)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %1
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%17 = load i32, i32* %4
%18 = call i32 (i8*, i8*, ...) @dump(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32 %17)
br label %19
19: ; preds = %15, %1
ret void
}

LLVM IR (-O2):
%struct.addrinfo = type { i32 }
@.str = [3 x i8] c"%s\00"
@.str.1 = [14 x i8] c" (%s) port %d\00"
define void @dump_addrinfo(%struct.addrinfo* %0) {
%2 = alloca [128 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %0, i64 0, i32 0
%7 = load i32, i32* %6
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i8*
%10 = tail call i32 (i8*, i8*, ...) @dump(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = call i64 @addrinfo_addr_port(%struct.addrinfo* %0, i8* %4, i32 128, i32* %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %1
%14 = load i32, i32* %3
%15 = call i32 (i8*, i8*, ...) @dump(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %4, i32 %14)
br label %16
16: ; preds = %13, %1
ret void
}