#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 in_addr {
  int dummy;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  struct in_addr sin_addr;
};
struct addrinfo {
  int ai_family;
  int ai_socktype;
  int ai_flags;
  int ai_protocol;
  char *ai_canonname;
  struct addrinfo *ai_next;
  scalar_t__ ai_addr;
  scalar_t__ ai_addrlen;
};
typedef int /*<<< orphan*/ ipstr;
typedef int /*<<< orphan*/ hints;

/* Variables and functions */
scalar_t__ AF_INET;
scalar_t__ AF_INET6;
int INET_ADDRSTRLEN;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *gai_strerror(int);
int getaddrinfo(char const *, char const *, struct addrinfo *,
                struct addrinfo **);
int htons(int /*<<< orphan*/);
int /*<<< orphan*/ inet_ntop(scalar_t__, struct in_addr *, char *, int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
struct addrinfo *prepare_addrinfo(const char *addr, const char *port,
                                  int _ai_family, int _ai_socktype) {
  struct addrinfo hints, *servinfo;
  int req_status;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = _ai_family;
  hints.ai_socktype = _ai_socktype;
  req_status = getaddrinfo(addr, port, &hints, &servinfo);
  if (req_status != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(req_status));
    return NULL;
  }
  printf("[prepare_addrinfo] Found addresses list...\n\n");
  struct addrinfo *it_servinfo = servinfo;
  while (it_servinfo != NULL) {
    printf("ai_flags: %d\nai_family: %d\nai_socktype: %d\nai_protocol: "
           "%d\nai_addrlen: %d\n",
           it_servinfo->ai_flags, it_servinfo->ai_family,
           it_servinfo->ai_socktype, it_servinfo->ai_protocol,
           (int)it_servinfo->ai_addrlen);
    if (it_servinfo->ai_family == AF_INET) {
      printf("ai_addr: TYPE sockaddr_in\n");
      struct sockaddr_in *addr = (struct sockaddr_in *)it_servinfo->ai_addr;
      struct in_addr *addr_number = &(addr->sin_addr);
      char ipstr[INET_ADDRSTRLEN];
      inet_ntop(servinfo->ai_family, addr_number, ipstr, sizeof(ipstr));
      printf("\tAddress selected: %s\n\tPort selected: %d\n", ipstr,
             htons(addr->sin_port));
    } else if (it_servinfo->ai_family == AF_INET6) {
      printf("ai_addr: TYPE sockaddr_in6\n");
    }
    printf("ai_canonname: %s\n", it_servinfo->ai_canonname);
    if (it_servinfo->ai_next != NULL) {
      printf("ai_next: YES\n");
    } else {
      printf("ai_next: NO\n");
    }
    printf("-------------------\n\n");
    it_servinfo = it_servinfo->ai_next;
  }
  servinfo->ai_next = NULL;
  return servinfo;
}


x86 assembly (clang, -O0):
<prepare_addrinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1070 <memset@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x58(%rbp),%rcx
call   1090 <getaddrinfo@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
je     1200 <prepare_addrinfo+0x90>
mov    0x2e02(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x5c(%rbp),%edi
call   1060 <gai_strerror@plt>
mov    -0x8c(%rbp),%edi
mov    %rax,%rdx
lea    0xe12(%rip),%rsi
call   1080 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    13a8 <prepare_addrinfo+0x238>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x58(%rbp),%rax
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     1394 <prepare_addrinfo+0x224>
mov    -0x68(%rbp),%rax
mov    0x8(%rax),%esi
mov    -0x68(%rbp),%rax
mov    (%rax),%edx
mov    -0x68(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x68(%rbp),%rax
mov    0xc(%rax),%r8d
mov    -0x68(%rbp),%rax
mov    0x28(%rax),%rax
mov    %eax,%r9d
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x68(%rbp),%rax
movslq (%rax),%rax
mov    0x2d84(%rip),%rcx
cmp    (%rcx),%rax
jne    1305 <prepare_addrinfo+0x195>
lea    0xe15(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x68(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x78(%rbp)
mov    0x2d2e(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x98(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x88(%rbp)
mov    -0x58(%rbp),%rcx
movslq (%rcx),%rdi
mov    -0x78(%rbp),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0x70(%rbp),%rax
mov    (%rax),%edi
call   1040 <htons@plt>
mov    -0x98(%rbp),%rsi
mov    %eax,%edx
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x80(%rbp),%rax
mov    %rax,%rsp
jmp    132f <prepare_addrinfo+0x1bf>
mov    -0x68(%rbp),%rax
movslq (%rax),%rax
mov    0x2ccd(%rip),%rcx
cmp    (%rcx),%rax
jne    132a <prepare_addrinfo+0x1ba>
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    132f <prepare_addrinfo+0x1bf>
mov    -0x68(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x68(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     1367 <prepare_addrinfo+0x1f7>
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1375 <prepare_addrinfo+0x205>
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x68(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x68(%rbp)
jmp    1216 <prepare_addrinfo+0xa6>
mov    -0x58(%rbp),%rax
movq   $0x0,0x18(%rax)
mov    -0x58(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prepare_addrinfo>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %ecx,%r14d
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,%r12
lea    -0x68(%rbp),%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1080 <memset@plt>
mov    %ebx,-0x68(%rbp)
mov    %r14d,-0x64(%rbp)
lea    -0x30(%rbp),%rcx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
call   10a0 <getaddrinfo@plt>
test   %eax,%eax
je     11f4 <prepare_addrinfo+0x74>
mov    0x2dfd(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1070 <gai_strerror@plt>
lea    0xe1d(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1090 <fprintf@plt>
xor    %eax,%eax
jmp    1336 <prepare_addrinfo+0x1b6>
lea    0xe9d(%rip),%rdi
call   1040 <puts@plt>
mov    -0x30(%rbp),%r15
lea    0xe06(%rip),%rbx
mov    0x2dd6(%rip),%r14
lea    0xe6d(%rip),%r12
lea    0xea4(%rip),%r13
jmp    12e7 <prepare_addrinfo+0x167>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xed6(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,-0x38(%rbp)
mov    %r13,%rbx
mov    %r12,%r13
mov    0x20(%r15),%r12
lea    0x4(%r12),%rsi
mov    0x2d72(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%r14
mov    %rcx,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    -0x30(%rbp),%rax
movslq (%rax),%rdi
mov    %r14,%rdx
call   1030 <inet_ntop@plt>
mov    (%r12),%edi
mov    %r13,%r12
mov    %rbx,%r13
call   1050 <htons@plt>
lea    0xdcb(%rip),%rdi
mov    %r14,%rsi
mov    0x2d4d(%rip),%r14
lea    0xd6f(%rip),%rbx
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    -0x38(%rbp),%rsp
mov    0x10(%r15),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpq   $0x0,0x18(%r15)
lea    0xe1c(%rip),%rdi
cmove  %r13,%rdi
call   1040 <puts@plt>
lea    0xdf7(%rip),%rdi
call   1040 <puts@plt>
mov    0x18(%r15),%r15
test   %r15,%r15
je     132a <prepare_addrinfo+0x1aa>
mov    0x8(%r15),%esi
mov    (%r15),%edx
mov    0x4(%r15),%ecx
mov    0xc(%r15),%r8d
mov    0x28(%r15),%r9d
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movslq (%r15),%rax
cmp    %rax,(%r14)
je     1230 <prepare_addrinfo+0xb0>
mov    0x2cc9(%rip),%rcx
cmp    %rax,(%rcx)
jne    12af <prepare_addrinfo+0x12f>
lea    0xdcf(%rip),%rdi
call   1040 <puts@plt>
jmp    12af <prepare_addrinfo+0x12f>
mov    -0x30(%rbp),%rax
movq   $0x0,0x18(%rax)
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i32, i8*, %struct.addrinfo*, i64, i64 }
%struct.sockaddr_in = type { i32, %struct.in_addr }
%struct.in_addr = type { i32 }
@stderr = global i32 0
@.str = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.1 = [45 x i8] c"[prepare_addrinfo] Found addresses list...\0A\0A\00"
@.str.2 = [75 x i8] c"ai_flags: %d\0Aai_family: %d\0Aai_socktype: %d\0Aai_protocol: %d\0Aai_addrlen: %d\0A\00"
@AF_INET = global i64 0
@.str.3 = [27 x i8] c"ai_addr: TYPE sockaddr_in\0A\00"
@INET_ADDRSTRLEN = global i32 0
@.str.4 = [42 x i8] c"\09Address selected: %s\0A\09Port selected: %d\0A\00"
@AF_INET6 = global i64 0
@.str.5 = [28 x i8] c"ai_addr: TYPE sockaddr_in6\0A\00"
@.str.6 = [18 x i8] c"ai_canonname: %s\0A\00"
@.str.7 = [14 x i8] c"ai_next: YES\0A\00"
@.str.8 = [13 x i8] c"ai_next: NO\0A\00"
@.str.9 = [22 x i8] c"-------------------\0A\0A\00"
define %struct.addrinfo* @prepare_addrinfo(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca %struct.addrinfo*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.addrinfo
%11 = alloca %struct.addrinfo*
%12 = alloca i32
%13 = alloca %struct.addrinfo*
%14 = alloca %struct.sockaddr_in*
%15 = alloca %struct.in_addr*
%16 = alloca i8*
%17 = alloca i64
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%18 = call i32 @memset(%struct.addrinfo* %10, i32 0, i32 48)
%19 = load i32, i32* %8
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 0
store i32 %19, i32* %20
%21 = load i32, i32* %9
%22 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 1
store i32 %21, i32* %22
%23 = load i8*, i8** %6
%24 = load i8*, i8** %7
%25 = call i32 @getaddrinfo(i8* %23, i8* %24, %struct.addrinfo* %10, %struct.addrinfo** %11)
store i32 %25, i32* %12
%26 = load i32, i32* %12
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %4
%29 = load i32, i32* @stderr
%30 = load i32, i32* %12
%31 = call i8* @gai_strerror(i32 %30)
%32 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %31)
store %struct.addrinfo* null, %struct.addrinfo** %5
br label %120
33: ; preds = %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%35 = load %struct.addrinfo*, %struct.addrinfo** %11
store %struct.addrinfo* %35, %struct.addrinfo** %13
br label %36
36: ; preds = %111, %33
%37 = load %struct.addrinfo*, %struct.addrinfo** %13
%38 = icmp ne %struct.addrinfo* %37, null
br i1 %38, label %39, label %116
39: ; preds = %36
%40 = load %struct.addrinfo*, %struct.addrinfo** %13
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i32 0, i32 2
%42 = load i32, i32* %41
%43 = load %struct.addrinfo*, %struct.addrinfo** %13
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %43, i32 0, i32 0
%45 = load i32, i32* %44
%46 = load %struct.addrinfo*, %struct.addrinfo** %13
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %46, i32 0, i32 1
%48 = load i32, i32* %47
%49 = load %struct.addrinfo*, %struct.addrinfo** %13
%50 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %49, i32 0, i32 3
%51 = load i32, i32* %50
%52 = load %struct.addrinfo*, %struct.addrinfo** %13
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %52, i32 0, i32 7
%54 = load i64, i64* %53
%55 = trunc i64 %54 to i32
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0), i32 %42, i32 %45, i32 %48, i32 %51, i32 %55)
%57 = load %struct.addrinfo*, %struct.addrinfo** %13
%58 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %57, i32 0, i32 0
%59 = load i32, i32* %58
%60 = sext i32 %59 to i64
%61 = load i64, i64* @AF_INET
%62 = icmp eq i64 %60, %61
br i1 %62, label %63, label %88
63: ; preds = %39
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%65 = load %struct.addrinfo*, %struct.addrinfo** %13
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %65, i32 0, i32 6
%67 = load i64, i64* %66
%68 = inttoptr i64 %67 to %struct.sockaddr_in*
store %struct.sockaddr_in* %68, %struct.sockaddr_in** %14
%69 = load %struct.sockaddr_in*, %struct.sockaddr_in** %14
%70 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %69, i32 0, i32 1
store %struct.in_addr* %70, %struct.in_addr** %15
%71 = load i32, i32* @INET_ADDRSTRLEN
%72 = zext i32 %71 to i64
%73 = call i8* @llvm.stacksave()
store i8* %73, i8** %16
%74 = alloca i8, i64 %72
store i64 %72, i64* %17
%75 = load %struct.addrinfo*, %struct.addrinfo** %11
%76 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %75, i32 0, i32 0
%77 = load i32, i32* %76
%78 = sext i32 %77 to i64
%79 = load %struct.in_addr*, %struct.in_addr** %15
%80 = trunc i64 %72 to i32
%81 = call i32 @inet_ntop(i64 %78, %struct.in_addr* %79, i8* %74, i32 %80)
%82 = load %struct.sockaddr_in*, %struct.sockaddr_in** %14
%83 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %82, i32 0, i32 0
%84 = load i32, i32* %83
%85 = call i32 @htons(i32 %84)
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %74, i32 %85)
%87 = load i8*, i8** %16
br label %98
88: ; preds = %39
%89 = load %struct.addrinfo*, %struct.addrinfo** %13
%90 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %89, i32 0, i32 0
%91 = load i32, i32* %90
%92 = sext i32 %91 to i64
%93 = load i64, i64* @AF_INET6
%94 = icmp eq i64 %92, %93
br i1 %94, label %95, label %97
95: ; preds = %88
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %97
97: ; preds = %95, %88
br label %98
98: ; preds = %97, %63
%99 = load %struct.addrinfo*, %struct.addrinfo** %13
%100 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %99, i32 0, i32 4
%101 = load i8*, i8** %100
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %101)
%103 = load %struct.addrinfo*, %struct.addrinfo** %13
%104 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %103, i32 0, i32 5
%105 = load %struct.addrinfo*, %struct.addrinfo** %104
%106 = icmp ne %struct.addrinfo* %105, null
br i1 %106, label %107, label %109
107: ; preds = %98
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
br label %111
109: ; preds = %98
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %111
111: ; preds = %109, %107
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%113 = load %struct.addrinfo*, %struct.addrinfo** %13
%114 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %113, i32 0, i32 5
%115 = load %struct.addrinfo*, %struct.addrinfo** %114
store %struct.addrinfo* %115, %struct.addrinfo** %13
br label %36
116: ; preds = %36
%117 = load %struct.addrinfo*, %struct.addrinfo** %11
%118 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %117, i32 0, i32 5
store %struct.addrinfo* null, %struct.addrinfo** %118
%119 = load %struct.addrinfo*, %struct.addrinfo** %11
store %struct.addrinfo* %119, %struct.addrinfo** %5
br label %120
120: ; preds = %116, %28
%121 = load %struct.addrinfo*, %struct.addrinfo** %5
ret %struct.addrinfo* %121
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i8*, %struct.addrinfo*, i64, i64 }
%struct.sockaddr_in = type { i32, %struct.in_addr }
%struct.in_addr = type { i32 }
@stderr = global i32 0
@.str = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.2 = [75 x i8] c"ai_flags: %d\0Aai_family: %d\0Aai_socktype: %d\0Aai_protocol: %d\0Aai_addrlen: %d\0A\00"
@AF_INET = global i64 0
@INET_ADDRSTRLEN = global i32 0
@.str.4 = [42 x i8] c"\09Address selected: %s\0A\09Port selected: %d\0A\00"
@AF_INET6 = global i64 0
@.str.6 = [18 x i8] c"ai_canonname: %s\0A\00"
@str = [44 x i8] c"[prepare_addrinfo] Found addresses list...\0A\00"
@str.10 = [12 x i8] c"ai_next: NO\00"
@str.11 = [21 x i8] c"-------------------\0A\00"
@str.12 = [13 x i8] c"ai_next: YES\00"
@str.13 = [27 x i8] c"ai_addr: TYPE sockaddr_in6\00"
@str.14 = [26 x i8] c"ai_addr: TYPE sockaddr_in\00"
define %struct.addrinfo* @prepare_addrinfo(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca %struct.addrinfo
%6 = alloca %struct.addrinfo*
%7 = bitcast %struct.addrinfo* %5 to i8*
%8 = bitcast %struct.addrinfo** %6 to i8*
%9 = call i32 @memset(%struct.addrinfo* %5, i32 0, i32 48)
%10 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 0
store i32 %2, i32* %10
%11 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 1
store i32 %3, i32* %11
%12 = call i32 @getaddrinfo(i8* %0, i8* %1, %struct.addrinfo* %5, %struct.addrinfo** %6)
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %4
%15 = load i32, i32* @stderr
%16 = call i8* @gai_strerror(i32 %12)
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %78
18: ; preds = %4
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%20 = load %struct.addrinfo*, %struct.addrinfo** %6
br label %21
21: ; preds = %18, %63
%22 = phi %struct.addrinfo* [ %73, %63 ], [ %20, %18 ]
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %22, i64 0, i32 2
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %22, i64 0, i32 0
%26 = load i32, i32* %25
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %22, i64 0, i32 1
%28 = load i32, i32* %27
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %22, i64 0, i32 3
%30 = load i32, i32* %29
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %22, i64 0, i32 7
%32 = load i64, i64* %31
%33 = trunc i64 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %26, i32 %28, i32 %30, i32 %33)
%35 = load i32, i32* %25
%36 = sext i32 %35 to i64
%37 = load i64, i64* @AF_INET
%38 = icmp eq i64 %37, %36
br i1 %38, label %39, label %58
39: ; preds = %21
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.14, i64 0, i64 0))
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %22, i64 0, i32 6
%42 = load i64, i64* %41
%43 = inttoptr i64 %42 to %struct.sockaddr_in*
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %43, i64 0, i32 1
%45 = load i32, i32* @INET_ADDRSTRLEN
%46 = zext i32 %45 to i64
%47 = call i8* @llvm.stacksave()
%48 = alloca i8, i64 %46
%49 = load %struct.addrinfo*, %struct.addrinfo** %6
%50 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %49, i64 0, i32 0
%51 = load i32, i32* %50
%52 = sext i32 %51 to i64
%53 = call i32 @inet_ntop(i64 %52, %struct.in_addr* %44, i8* %48, i32 %45)
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %43, i64 0, i32 0
%55 = load i32, i32* %54
%56 = call i32 @htons(i32 %55)
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %48, i32 %56)
br label %63
58: ; preds = %21
%59 = load i64, i64* @AF_INET6
%60 = icmp eq i64 %59, %36
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0))
br label %63
63: ; preds = %58, %61, %39
%64 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %22, i64 0, i32 4
%65 = load i8*, i8** %64
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %65)
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %22, i64 0, i32 5
%68 = load %struct.addrinfo*, %struct.addrinfo** %67
%69 = icmp eq %struct.addrinfo* %68, null
%70 = select i1 %69, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str.10, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0)
%71 = call i32 @puts(i8* dereferenceable(1) %70)
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.11, i64 0, i64 0))
%73 = load %struct.addrinfo*, %struct.addrinfo** %67
%74 = icmp eq %struct.addrinfo* %73, null
br i1 %74, label %75, label %21
75: ; preds = %63
%76 = load %struct.addrinfo*, %struct.addrinfo** %6
%77 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %76, i64 0, i32 5
store %struct.addrinfo* null, %struct.addrinfo** %77
br label %78
78: ; preds = %75, %14
%79 = phi %struct.addrinfo* [ null, %14 ], [ %76, %75 ]
ret %struct.addrinfo* %79
}