#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct sockaddr_in6 {
  int /*<<< orphan*/ sin6_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
};
struct addrinfo {
  TYPE_1__ *ai_addr;
  int /*<<< orphan*/ ai_addrlen;
  struct addrinfo *ai_next;
};
struct TYPE_2__ {
  int sa_family;
};

/* Variables and functions */
#define AF_INET 129
#define AF_INET6 128
int EAI_SYSTEM;
int /*<<< orphan*/ EXIT_FAILURE;
int INET6_ADDRSTRLEN;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int getaddrinfo(char *, char *, int /*<<< orphan*/ *, struct addrinfo **);
int getnameinfo(TYPE_1__ *, int /*<<< orphan*/, char *, int, char *, int,
                int /*<<< orphan*/);
int /*<<< orphan*/ inet_ntop(int const, int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 3) {
    fprintf(stderr, "Usage: getaddrinfo domain port\n");
    return 1;
  }
  struct addrinfo *result;
  struct addrinfo *res;
  int error;
  error = getaddrinfo(argv[1], argv[2], NULL, &result);
  if (error != 0) {
    if (error == EAI_SYSTEM) {
      perror("getaddrinfo");
    } else {
      fprintf(stderr, "error in getaddrinfo: %s\n", gai_strerror(error));
    }
    exit(EXIT_FAILURE);
  }
  for (res = result; res != NULL; res = res->ai_next) {
    char hostname[1025];
    char servicename[1025];
    char ipaddress[INET6_ADDRSTRLEN];
    error = getnameinfo(res->ai_addr, res->ai_addrlen, hostname, 1025,
                        servicename, 1025, 0);
    if (error != 0) {
      fprintf(stderr, "error in getnameinfo: %s\n", gai_strerror(error));
      continue;
    }
    switch (res->ai_addr->sa_family) {
    case AF_INET: {
      struct sockaddr_in *addr_in = (struct sockaddr_in *)res->ai_addr;
      inet_ntop(AF_INET, &(addr_in->sin_addr), ipaddress, INET6_ADDRSTRLEN);
      break;
    }
    case AF_INET6: {
      struct sockaddr_in6 *addr_in = (struct sockaddr_in6 *)res->ai_addr;
      inet_ntop(AF_INET6, &(addr_in->sin6_addr), ipaddress, INET6_ADDRSTRLEN);
      break;
    }
    default:
      break;
    }
    if (*hostname != '\0')
      printf("hostname: %s, servicename: %s, ip: %s\n", hostname, servicename,
             ipaddress);
  }
  freeaddrinfo(result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x880,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11d6 <main+0x46>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0xe3d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1451 <main+0x2c1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x18(%rbp),%rcx
call   10a0 <getaddrinfo@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     125f <main+0xcf>
mov    -0x24(%rbp),%eax
mov    0x2dd6(%rip),%rcx
cmp    (%rcx),%eax
jne    1223 <main+0x93>
lea    0xe07(%rip),%rdi
call   1080 <perror@plt>
jmp    1251 <main+0xc1>
mov    0x2da6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x86c(%rbp)
mov    -0x24(%rbp),%edi
call   1050 <gai_strerror@plt>
mov    -0x86c(%rbp),%edi
mov    %rax,%rdx
lea    0xde2(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1441 <main+0x2b1>
mov    0x2d6f(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x848(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x878(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x850(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%esi
lea    -0x430(%rbp),%rdx
lea    -0x840(%rbp),%r8
mov    $0x401,%r9d
xor    %eax,%eax
sub    $0x10,%rsp
mov    %r9d,%ecx
movl   $0x0,(%rsp)
call   1060 <getnameinfo@plt>
add    $0x10,%rsp
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     132c <main+0x19c>
mov    0x2cda(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x87c(%rbp)
mov    -0x24(%rbp),%edi
call   1050 <gai_strerror@plt>
mov    -0x87c(%rbp),%edi
mov    %rax,%rdx
lea    0xd30(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x4,-0x854(%rbp)
jmp    1409 <main+0x279>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x880(%rbp)
sub    $0x80,%eax
je     1395 <main+0x205>
jmp    134b <main+0x1bb>
mov    -0x880(%rbp),%eax
sub    $0x81,%eax
jne    13c9 <main+0x239>
jmp    1361 <main+0x1d1>
mov    -0x878(%rbp),%rdx
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x860(%rbp)
mov    -0x860(%rbp),%rsi
mov    0x2c64(%rip),%rax
mov    (%rax),%ecx
mov    $0x81,%edi
call   1030 <inet_ntop@plt>
jmp    13ce <main+0x23e>
mov    -0x878(%rbp),%rdx
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x868(%rbp)
mov    -0x868(%rbp),%rsi
mov    0x2c30(%rip),%rax
mov    (%rax),%ecx
mov    $0x80,%edi
call   1030 <inet_ntop@plt>
jmp    13ce <main+0x23e>
jmp    13ce <main+0x23e>
movsbl -0x430(%rbp),%eax
cmp    $0x0,%eax
je     13ff <main+0x26f>
mov    -0x878(%rbp),%rcx
lea    -0x430(%rbp),%rsi
lea    -0x840(%rbp),%rdx
lea    0xc66(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x854(%rbp)
mov    -0x848(%rbp),%rax
mov    %rax,%rsp
mov    -0x854(%rbp),%eax
test   %eax,%eax
je     142b <main+0x29b>
jmp    1426 <main+0x296>
jmp    1430 <main+0x2a0>
jmp    1430 <main+0x2a0>
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1267 <main+0xd7>
mov    -0x18(%rbp),%rdi
call   10b0 <freeaddrinfo@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x828,%rsp
cmp    $0x3,%edi
jne    12bf <main+0x12f>
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rsi
lea    -0x30(%rbp),%rcx
xor    %edx,%edx
call   10a0 <getaddrinfo@plt>
test   %eax,%eax
jne    12fd <main+0x16d>
mov    -0x30(%rbp),%r13
xor    %ebx,%ebx
test   %r13,%r13
je     12e5 <main+0x155>
mov    0x2e0a(%rip),%rbx
lea    -0x850(%rbp),%r14
jmp    1229 <main+0x99>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%r12
mov    0x2dd6(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1050 <gai_strerror@plt>
mov    %ebx,%edi
mov    %r12,%rbx
lea    0xe37(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r15,%rsp
mov    0x10(%r13),%r13
test   %r13,%r13
je     12dd <main+0x14d>
mov    %rsp,%r15
mov    (%rbx),%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    0x0(%r13),%rdi
mov    0x8(%r13),%esi
sub    $0x8,%rsp
lea    -0x440(%rbp),%rdx
mov    $0x401,%ecx
mov    %r14,%r8
mov    $0x401,%r9d
push   $0x0
call   1060 <getnameinfo@plt>
add    $0x10,%rsp
test   %eax,%eax
jne    11f0 <main+0x60>
mov    0x0(%r13),%rsi
mov    (%rsi),%edi
cmp    $0x81,%edi
je     128a <main+0xfa>
cmp    $0x80,%edi
jne    1294 <main+0x104>
mov    $0x80,%edi
mov    (%rbx),%ecx
mov    %r12,%rdx
call   1030 <inet_ntop@plt>
cmpb   $0x0,-0x440(%rbp)
je     1219 <main+0x89>
lea    0xdb8(%rip),%rdi
lea    -0x440(%rbp),%rsi
mov    %r14,%rdx
mov    %r12,%rcx
call   1040 <printf@plt>
jmp    1219 <main+0x89>
mov    0x2d0a(%rip),%rax
mov    (%rax),%edi
lea    0xd31(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%ebx
jmp    12ec <main+0x15c>
mov    -0x30(%rbp),%rdi
xor    %ebx,%ebx
jmp    12e7 <main+0x157>
xor    %edi,%edi
call   10b0 <freeaddrinfo@plt>
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cdc(%rip),%rcx
cmp    (%rcx),%eax
jne    1322 <main+0x192>
lea    0xd11(%rip),%rdi
call   1080 <perror@plt>
mov    0x2cad(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x2ca7(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1050 <gai_strerror@plt>
lea    0xcf3(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1314 <main+0x184>

LLVM IR (-O0):
%struct.addrinfo = type { %struct.TYPE_2__*, i32, %struct.addrinfo* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr_in6 = type { i32 }
@stderr = global i32 0
@.str = [32 x i8] c"Usage: getaddrinfo domain port\0A\00"
@EAI_SYSTEM = global i32 0
@.str.1 = [12 x i8] c"getaddrinfo\00"
@.str.2 = [26 x i8] c"error in getaddrinfo: %s\0A\00"
@EXIT_FAILURE = global i32 0
@INET6_ADDRSTRLEN = global i32 0
@.str.3 = [26 x i8] c"error in getnameinfo: %s\0A\00"
@.str.4 = [39 x i8] c"hostname: %s, servicename: %s, ip: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.addrinfo*
%7 = alloca %struct.addrinfo*
%8 = alloca i32
%9 = alloca [1025 x i8]
%10 = alloca [1025 x i8]
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32
%14 = alloca %struct.sockaddr_in*
%15 = alloca %struct.sockaddr_in6*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 3
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %117
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @getaddrinfo(i8* %24, i8* %27, i32* null, %struct.addrinfo** %6)
store i32 %28, i32* %8
%29 = load i32, i32* %8
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %45
31: ; preds = %21
%32 = load i32, i32* %8
%33 = load i32, i32* @EAI_SYSTEM
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %42
37: ; preds = %31
%38 = load i32, i32* @stderr
%39 = load i32, i32* %8
%40 = call i8* @gai_strerror(i32 %39)
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %40)
br label %42
42: ; preds = %37, %35
%43 = load i32, i32* @EXIT_FAILURE
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %21
%46 = load %struct.addrinfo*, %struct.addrinfo** %6
store %struct.addrinfo* %46, %struct.addrinfo** %7
br label %47
47: ; preds = %110, %45
%48 = load %struct.addrinfo*, %struct.addrinfo** %7
%49 = icmp ne %struct.addrinfo* %48, null
br i1 %49, label %50, label %114
50: ; preds = %47
%51 = load i32, i32* @INET6_ADDRSTRLEN
%52 = zext i32 %51 to i64
%53 = call i8* @llvm.stacksave()
store i8* %53, i8** %11
%54 = alloca i8, i64 %52
store i64 %52, i64* %12
%55 = load %struct.addrinfo*, %struct.addrinfo** %7
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %55, i32 0, i32 0
%57 = load %struct.TYPE_2__*, %struct.TYPE_2__** %56
%58 = load %struct.addrinfo*, %struct.addrinfo** %7
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %58, i32 0, i32 1
%60 = load i32, i32* %59
%61 = getelementptr inbounds [1025 x i8], [1025 x i8]* %9, i64 0, i64 0
%62 = getelementptr inbounds [1025 x i8], [1025 x i8]* %10, i64 0, i64 0
%63 = call i32 @getnameinfo(%struct.TYPE_2__* %57, i32 %60, i8* %61, i32 1025, i8* %62, i32 1025, i32 0)
store i32 %63, i32* %8
%64 = load i32, i32* %8
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %71
66: ; preds = %50
%67 = load i32, i32* @stderr
%68 = load i32, i32* %8
%69 = call i8* @gai_strerror(i32 %68)
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %69)
store i32 4, i32* %13
br label %106
71: ; preds = %50
%72 = load %struct.addrinfo*, %struct.addrinfo** %7
%73 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %72, i32 0, i32 0
%74 = load %struct.TYPE_2__*, %struct.TYPE_2__** %73
%75 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %74, i32 0, i32 0
%76 = load i32, i32* %75
switch i32 %76, label %95 [
i32 129, label %77
i32 128, label %86
]
77: ; preds = %71
%78 = load %struct.addrinfo*, %struct.addrinfo** %7
%79 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %78, i32 0, i32 0
%80 = load %struct.TYPE_2__*, %struct.TYPE_2__** %79
%81 = bitcast %struct.TYPE_2__* %80 to %struct.sockaddr_in*
store %struct.sockaddr_in* %81, %struct.sockaddr_in** %14
%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* @INET6_ADDRSTRLEN
%85 = call i32 @inet_ntop(i32 129, i32* %83, i8* %54, i32 %84)
br label %96
86: ; preds = %71
%87 = load %struct.addrinfo*, %struct.addrinfo** %7
%88 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %87, i32 0, i32 0
%89 = load %struct.TYPE_2__*, %struct.TYPE_2__** %88
%90 = bitcast %struct.TYPE_2__* %89 to %struct.sockaddr_in6*
store %struct.sockaddr_in6* %90, %struct.sockaddr_in6** %15
%91 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %15
%92 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %91, i32 0, i32 0
%93 = load i32, i32* @INET6_ADDRSTRLEN
%94 = call i32 @inet_ntop(i32 128, i32* %92, i8* %54, i32 %93)
br label %96
95: ; preds = %71
br label %96
96: ; preds = %95, %86, %77
%97 = getelementptr inbounds [1025 x i8], [1025 x i8]* %9, i64 0, i64 0
%98 = load i8, i8* %97
%99 = sext i8 %98 to i32
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %105
101: ; preds = %96
%102 = getelementptr inbounds [1025 x i8], [1025 x i8]* %9, i64 0, i64 0
%103 = getelementptr inbounds [1025 x i8], [1025 x i8]* %10, i64 0, i64 0
%104 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %102, i8* %103, i8* %54)
br label %105
105: ; preds = %101, %96
store i32 0, i32* %13
br label %106
106: ; preds = %105, %66
%107 = load i8*, i8** %11
%108 = load i32, i32* %13
switch i32 %108, label %119 [
i32 0, label %109
i32 4, label %110
]
109: ; preds = %106
br label %110
110: ; preds = %109, %106
%111 = load %struct.addrinfo*, %struct.addrinfo** %7
%112 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %111, i32 0, i32 2
%113 = load %struct.addrinfo*, %struct.addrinfo** %112
store %struct.addrinfo* %113, %struct.addrinfo** %7
br label %47
114: ; preds = %47
%115 = load %struct.addrinfo*, %struct.addrinfo** %6
%116 = call i32 @freeaddrinfo(%struct.addrinfo* %115)
store i32 0, i32* %3
br label %117
117: ; preds = %114, %18
%118 = load i32, i32* %3
ret i32 %118
119: ; preds = %106
unreachable
}

LLVM IR (-O2):
%struct.addrinfo = type { %struct.TYPE_2__*, i32, %struct.addrinfo* }
%struct.TYPE_2__ = type { i32 }
@stderr = global i32 0
@.str = [32 x i8] c"Usage: getaddrinfo domain port\0A\00"
@EAI_SYSTEM = global i32 0
@.str.1 = [12 x i8] c"getaddrinfo\00"
@.str.2 = [26 x i8] c"error in getaddrinfo: %s\0A\00"
@EXIT_FAILURE = global i32 0
@INET6_ADDRSTRLEN = global i32 0
@.str.3 = [26 x i8] c"error in getnameinfo: %s\0A\00"
@.str.4 = [39 x i8] c"hostname: %s, servicename: %s, ip: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo*
%4 = alloca [1025 x i8]
%5 = alloca [1025 x i8]
%6 = icmp eq i32 %0, 3
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %75
10: ; preds = %2
%11 = bitcast %struct.addrinfo** %3 to i8*
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = call i32 @getaddrinfo(i8* %13, i8* %15, i32* null, %struct.addrinfo** %3)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %10
%19 = load %struct.addrinfo*, %struct.addrinfo** %3
%20 = icmp eq %struct.addrinfo* %19, null
br i1 %20, label %72, label %21
21: ; preds = %18
%22 = getelementptr inbounds [1025 x i8], [1025 x i8]* %4, i64 0, i64 0
%23 = getelementptr inbounds [1025 x i8], [1025 x i8]* %5, i64 0, i64 0
br label %36
24: ; preds = %10
%25 = load i32, i32* @EAI_SYSTEM
%26 = icmp eq i32 %16, %25
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %33
29: ; preds = %24
%30 = load i32, i32* @stderr
%31 = call i8* @gai_strerror(i32 %16)
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %29, %27
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %21, %66
%37 = phi %struct.addrinfo* [ %19, %21 ], [ %68, %66 ]
%38 = load i32, i32* @INET6_ADDRSTRLEN
%39 = zext i32 %38 to i64
%40 = call i8* @llvm.stacksave()
%41 = alloca i8, i64 %39
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 0
%43 = load %struct.TYPE_2__*, %struct.TYPE_2__** %42
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 1
%45 = load i32, i32* %44
%46 = call i32 @getnameinfo(%struct.TYPE_2__* %43, i32 %45, i8* %22, i32 1025, i8* %23, i32 1025, i32 0)
%47 = icmp eq i32 %46, 0
br i1 %47, label %52, label %48
48: ; preds = %36
%49 = load i32, i32* @stderr
%50 = call i8* @gai_strerror(i32 %46)
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %50)
br label %66
52: ; preds = %36
%53 = load %struct.TYPE_2__*, %struct.TYPE_2__** %42
%54 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %53, i64 0, i32 0
%55 = load i32, i32* %54
switch i32 %55, label %61 [
i32 129, label %57
i32 128, label %56
]
56: ; preds = %52
br label %57
57: ; preds = %52, %56
%58 = phi i32 [ 128, %56 ], [ %55, %52 ]
%59 = load i32, i32* @INET6_ADDRSTRLEN
%60 = call i32 @inet_ntop(i32 %58, i32* %54, i8* %41, i32 %59)
br label %61
61: ; preds = %57, %52
%62 = load i8, i8* %22
%63 = icmp eq i8 %62, 0
br i1 %63, label %66, label %64
64: ; preds = %61
%65 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %22, i8* %23, i8* %41)
br label %66
66: ; preds = %61, %64, %48
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 2
%68 = load %struct.addrinfo*, %struct.addrinfo** %67
%69 = icmp eq %struct.addrinfo* %68, null
br i1 %69, label %70, label %36
70: ; preds = %66
%71 = load %struct.addrinfo*, %struct.addrinfo** %3
br label %72
72: ; preds = %70, %18
%73 = phi %struct.addrinfo* [ %71, %70 ], [ null, %18 ]
%74 = call i32 @freeaddrinfo(%struct.addrinfo* %73)
br label %75
75: ; preds = %72, %7
%76 = phi i32 [ 1, %7 ], [ 0, %72 ]
ret i32 %76
}