#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_in6 {
  int /*<<< orphan*/ sin6_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
};
struct addrinfo {
  scalar_t__ ai_family;
  scalar_t__ ai_addr;
};
typedef int /*<<< orphan*/ addr_str;

/* Variables and functions */
scalar_t__ AF_INET;
scalar_t__ AF_INET6;
int INET6_ADDRSTRLEN;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ inet_ntop(scalar_t__, int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ stderr;
void print_info(struct addrinfo *curr) {
  char addr_str[INET6_ADDRSTRLEN];
  if (curr->ai_family == AF_INET6) {
    inet_ntop(AF_INET6, &((struct sockaddr_in6 *)curr->ai_addr)->sin6_addr,
              addr_str, sizeof(addr_str));
  } else {
    inet_ntop(AF_INET, &((struct sockaddr_in *)curr->ai_addr)->sin_addr,
              addr_str, sizeof(addr_str));
  }
  fprintf(stderr, "Trying to connect to %s\n", addr_str);
}


x86 assembly (clang, -O0):
<print_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2eb5(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x28(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x2e6e(%rip),%rcx
cmp    (%rcx),%rax
jne    1199 <print_info+0x79>
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rax
mov    0x2e56(%rip),%rcx
mov    (%rcx),%rdi
mov    -0x8(%rbp),%rcx
mov    0x8(%rcx),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
jmp    11ba <print_info+0x9a>
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rax
mov    0x2e38(%rip),%rcx
mov    (%rcx),%rdi
mov    -0x8(%rbp),%rcx
mov    0x8(%rcx),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0x20(%rbp),%rdx
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
lea    0xe32(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_info>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    0x2ebb(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rbx
mov    %rcx,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    (%rdi),%rax
mov    0x2e8b(%rip),%rdx
cmp    (%rdx),%rax
je     115c <print_info+0x3c>
mov    0x2e87(%rip),%rax
mov    (%rax),%rax
mov    0x8(%rdi),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
call   1030 <inet_ntop@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.addrinfo = type { i64, i64 }
%struct.sockaddr_in6 = type { i32 }
%struct.sockaddr_in = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@AF_INET6 = global i64 0
@AF_INET = global i64 0
@stderr = global i32 0
@.str = [25 x i8] c"Trying to connect to %s\0A\00"
define void @print_info(%struct.addrinfo* %0) {
%2 = alloca %struct.addrinfo*
%3 = alloca i8*
%4 = alloca i64
store %struct.addrinfo* %0, %struct.addrinfo** %2
%5 = load i32, i32* @INET6_ADDRSTRLEN
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
store i8* %7, i8** %3
%8 = alloca i8, i64 %6
store i64 %6, i64* %4
%9 = load %struct.addrinfo*, %struct.addrinfo** %2
%10 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i32 0, i32 0
%11 = load i64, i64* %10
%12 = load i64, i64* @AF_INET6
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %23
14: ; preds = %1
%15 = load i64, i64* @AF_INET6
%16 = load %struct.addrinfo*, %struct.addrinfo** %2
%17 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %16, i32 0, i32 1
%18 = load i64, i64* %17
%19 = inttoptr i64 %18 to %struct.sockaddr_in6*
%20 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %19, i32 0, i32 0
%21 = trunc i64 %6 to i32
%22 = call i32 @inet_ntop(i64 %15, i32* %20, i8* %8, i32 %21)
br label %32
23: ; preds = %1
%24 = load i64, i64* @AF_INET
%25 = load %struct.addrinfo*, %struct.addrinfo** %2
%26 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %25, i32 0, i32 1
%27 = load i64, i64* %26
%28 = inttoptr i64 %27 to %struct.sockaddr_in*
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %28, i32 0, i32 0
%30 = trunc i64 %6 to i32
%31 = call i32 @inet_ntop(i64 %24, i32* %29, i8* %8, i32 %30)
br label %32
32: ; preds = %23, %14
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %8)
%35 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
%struct.addrinfo = type { i64, i64 }
%struct.sockaddr_in6 = type { i32 }
%struct.sockaddr_in = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@AF_INET6 = global i64 0
@AF_INET = global i64 0
@stderr = global i32 0
@.str = [25 x i8] c"Trying to connect to %s\0A\00"
define void @print_info(%struct.addrinfo* nocapture %0) {
%2 = load i32, i32* @INET6_ADDRSTRLEN
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %0, i64 0, i32 0
%6 = load i64, i64* %5
%7 = load i64, i64* @AF_INET6
%8 = icmp eq i64 %6, %7
br i1 %8, label %9, label %15
9: ; preds = %1
%10 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %0, i64 0, i32 1
%11 = load i64, i64* %10
%12 = inttoptr i64 %11 to %struct.sockaddr_in6*
%13 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %12, i64 0, i32 0
%14 = call i32 @inet_ntop(i64 %6, i32* %13, i8* %4, i32 %2)
br label %22
15: ; preds = %1
%16 = load i64, i64* @AF_INET
%17 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %0, i64 0, i32 1
%18 = load i64, i64* %17
%19 = inttoptr i64 %18 to %struct.sockaddr_in*
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %19, i64 0, i32 0
%21 = call i32 @inet_ntop(i64 %16, i32* %20, i8* %4, i32 %2)
br label %22
22: ; preds = %15, %9
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %4)
ret void
}