#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 ifaddrs {
  char *ifa_name;
  TYPE_1__ *ifa_addr;
  scalar_t__ ifa_netmask;
  scalar_t__ ifa_dstaddr;
  struct ifaddrs *ifa_next;
};
typedef int /*<<< orphan*/ straddr;
struct TYPE_2__ {
  int sa_family;
};

/* Variables and functions */
int AF_INET;
int AF_INET6;
int AF_PACKET;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int INET6_ADDRSTRLEN;
int NI_MAXHOST;
int /*<<< orphan*/ NI_NUMERICHOST;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ freeifaddrs(struct ifaddrs *);
char *gai_strerror(int);
int getifaddrs(struct ifaddrs **);
int getnameinfo(TYPE_1__ *, int, char *, int, int /*<<< orphan*/ *,
                int /*<<< orphan*/, int /*<<< orphan*/);
char *inet_ntoa(int /*<<< orphan*/);
int /*<<< orphan*/ inet_ntop(int, int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  struct ifaddrs *ifaddr, *ifa;
  int family, s;
  char host[NI_MAXHOST];
  if (getifaddrs(&ifaddr) == -1) {
    perror("getifaddrs");
    exit(EXIT_FAILURE);
  }
  for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
    if (ifa->ifa_addr == NULL)
      continue;
    family = ifa->ifa_addr->sa_family;
    printf("%s  address family: %d%s\n", ifa->ifa_name, family,
           (family == AF_PACKET)  ? " (AF_PACKET)"
           : (family == AF_INET)  ? " (AF_INET)"
           : (family == AF_INET6) ? " (AF_INET6)"
                                  : "");
    if (family == AF_INET || family == AF_INET6) {
      s = getnameinfo(ifa->ifa_addr,
                      (family == AF_INET) ? sizeof(struct sockaddr_in)
                                          : sizeof(struct sockaddr_in6),
                      host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
      if (family == AF_INET) {
        printf("bcast: %s\n",
               inet_ntoa(((struct sockaddr_in *)ifa->ifa_dstaddr)->sin_addr));
        printf("addr : %s\n",
               inet_ntoa(((struct sockaddr_in *)ifa->ifa_addr)->sin_addr));
        printf("netm : %s\n",
               inet_ntoa(((struct sockaddr_in *)ifa->ifa_netmask)->sin_addr));
      }
      if (family == AF_INET6) {
        char straddr[INET6_ADDRSTRLEN];
        struct sockaddr_in6 *addr = ((struct sockaddr_in6 *)ifa->ifa_addr);
        inet_ntop(AF_INET6, &addr->sin6_addr, straddr, sizeof(straddr));
        printf("bcast: %s\n", straddr);
      }
      if (s != 0) {
        printf("getnameinfo() failed: %s\n", gai_strerror(s));
        exit(EXIT_FAILURE);
      }
      printf("\taddress: <%s>\n", host);
    }
    printf("\n\n");
  }
  freeifaddrs(ifaddr);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2df8(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
lea    -0x18(%rbp),%rdi
call   1080 <getifaddrs@plt>
cmp    $0xffffffff,%eax
jne    1201 <main+0x71>
lea    0xe12(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     148e <main+0x2fe>
mov    -0x20(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    1228 <main+0x98>
jmp    147d <main+0x2ed>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2d78(%rip),%rcx
cmp    (%rcx),%eax
jne    1268 <main+0xd8>
lea    0xdc6(%rip),%rax
mov    %rax,-0x70(%rbp)
jmp    12b6 <main+0x126>
mov    -0x24(%rbp),%eax
mov    0x2d6e(%rip),%rcx
cmp    (%rcx),%eax
jne    128a <main+0xfa>
lea    0xdb1(%rip),%rax
mov    %rax,-0x78(%rbp)
jmp    12ae <main+0x11e>
mov    -0x24(%rbp),%edx
mov    0x2d44(%rip),%rax
mov    (%rax),%esi
lea    0xdf9(%rip),%rax
lea    0xd99(%rip),%rcx
cmp    %esi,%edx
cmove  %rcx,%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x5c(%rbp),%edx
mov    -0x68(%rbp),%rsi
mov    -0x70(%rbp),%rcx
lea    0xd43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
mov    0x2d07(%rip),%rcx
cmp    (%rcx),%eax
je     12f3 <main+0x163>
mov    -0x24(%rbp),%eax
mov    0x2ced(%rip),%rcx
cmp    (%rcx),%eax
jne    146f <main+0x2df>
mov    -0x58(%rbp),%rdx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x24(%rbp),%ecx
mov    0x2cd7(%rip),%rax
mov    (%rax),%esi
mov    $0x4,%eax
cmp    %esi,%ecx
cmove  %rax,%rax
mov    %eax,%esi
mov    0x2c89(%rip),%rax
mov    (%rax),%ecx
mov    0x2c98(%rip),%rax
mov    (%rax),%eax
xor    %r8d,%r8d
xor    %r9d,%r9d
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1070 <getnameinfo@plt>
add    $0x10,%rsp
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2c93(%rip),%rcx
cmp    (%rcx),%eax
jne    13b5 <main+0x225>
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%rax
mov    (%rax),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xcdb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xcc6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xcb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
mov    0x2c19(%rip),%rcx
cmp    (%rcx),%eax
jne    142c <main+0x29c>
mov    0x2c1a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x80(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rcx
mov    0x8(%rcx),%rcx
mov    %rcx,-0x50(%rbp)
mov    0x2bd2(%rip),%rcx
mov    (%rcx),%edi
mov    -0x50(%rbp),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0x80(%rbp),%rsi
lea    0xc2b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
cmpl   $0x0,-0x28(%rbp)
je     145d <main+0x2cd>
mov    -0x28(%rbp),%edi
call   1060 <gai_strerror@plt>
mov    %rax,%rsi
lea    0xc22(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2b62(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x58(%rbp),%rsi
lea    0xc1c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xc1e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1209 <main+0x79>
mov    -0x18(%rbp),%rdi
call   1090 <freeifaddrs@plt>
mov    0x2b12(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2df0(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
lea    -0x38(%rbp),%rdi
call   1090 <getifaddrs@plt>
cmp    $0xffffffff,%eax
jne    11f7 <main+0x57>
lea    0xe1c(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x38(%rbp),%r13
test   %r13,%r13
jne    1207 <main+0x67>
xor    %edi,%edi
jmp    13b2 <main+0x212>
mov    0x2dba(%rip),%rbx
jmp    1229 <main+0x89>
lea    0xe7b(%rip),%rdi
call   1040 <puts@plt>
mov    0x20(%r13),%r13
test   %r13,%r13
je     13ae <main+0x20e>
mov    0x8(%r13),%rax
test   %rax,%rax
je     121c <main+0x7c>
mov    (%rax),%r15d
lea    0xde9(%rip),%rcx
cmp    (%rbx),%r15d
je     1270 <main+0xd0>
lea    0xdea(%rip),%rcx
mov    0x2d91(%rip),%rax
cmp    (%rax),%r15d
je     1270 <main+0xd0>
mov    0x2d7d(%rip),%rax
cmp    (%rax),%r15d
lea    0xe2e(%rip),%rcx
lea    0xdd1(%rip),%rax
cmove  %rax,%rcx
mov    0x0(%r13),%rsi
lea    0xd90(%rip),%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2d54(%rip),%rax
cmp    (%rax),%r15d
je     12a1 <main+0x101>
mov    0x2d40(%rip),%rax
cmp    (%rax),%r15d
jne    1210 <main+0x70>
mov    0x8(%r13),%rdi
mov    0x2cfc(%rip),%rax
mov    (%rax),%ecx
mov    0x2d0b(%rip),%rax
mov    (%rax),%eax
sub    $0x8,%rsp
mov    $0x4,%esi
mov    -0x30(%rbp),%rdx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   %rax
call   1080 <getnameinfo@plt>
add    $0x10,%rsp
mov    %eax,%r14d
mov    0x2d02(%rip),%rax
cmp    (%rax),%r15d
jne    1337 <main+0x197>
mov    0x18(%r13),%rax
mov    (%rax),%edi
call   1050 <inet_ntoa@plt>
lea    0xd54(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%r13),%rax
mov    (%rax),%edi
call   1050 <inet_ntoa@plt>
lea    0xd43(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%r13),%rax
mov    (%rax),%edi
call   1050 <inet_ntoa@plt>
lea    0xd32(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2c9a(%rip),%rax
cmp    (%rax),%r15d
jne    1392 <main+0x1f2>
mov    %rsp,%r12
mov    0x2c9b(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%r15
mov    %rsp,%rbx
mov    %rcx,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x8(%r13),%rsi
mov    0x2c67(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rdx
call   1030 <inet_ntop@plt>
lea    0xcc7(%rip),%rdi
mov    %rbx,%rsi
mov    %r15,%rbx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rsp
test   %r14d,%r14d
jne    13c5 <main+0x225>
lea    0xce6(%rip),%rdi
mov    -0x30(%rbp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1210 <main+0x70>
mov    -0x38(%rbp),%rdi
call   10a0 <freeifaddrs@plt>
mov    0x2bf2(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    %r14d,%edi
call   1070 <gai_strerror@plt>
lea    0xc96(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11e9 <main+0x49>

LLVM IR (-O0):
%struct.ifaddrs = type { i8*, %struct.TYPE_2__*, i64, i64, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr_in6 = type { i32 }
%struct.sockaddr_in = type { i32 }
@NI_MAXHOST = global i32 0
@.str = [11 x i8] c"getifaddrs\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [26 x i8] c"%s address family: %d%s\0A\00"
@AF_PACKET = global i32 0
@.str.2 = [13 x i8] c" (AF_PACKET)\00"
@AF_INET = global i32 0
@.str.3 = [11 x i8] c" (AF_INET)\00"
@AF_INET6 = global i32 0
@.str.4 = [12 x i8] c" (AF_INET6)\00"
@.str.5 = [1 x i8] zeroinitializer
@NI_NUMERICHOST = global i32 0
@.str.6 = [11 x i8] c"bcast: %s\0A\00"
@.str.7 = [11 x i8] c"addr : %s\0A\00"
@.str.8 = [11 x i8] c"netm : %s\0A\00"
@INET6_ADDRSTRLEN = global i32 0
@.str.9 = [26 x i8] c"getnameinfo() failed: %s\0A\00"
@.str.10 = [16 x i8] c"\09address: <%s>\0A\00"
@.str.11 = [3 x i8] c"\0A\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.ifaddrs*
%7 = alloca %struct.ifaddrs*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i64
%14 = alloca %struct.sockaddr_in6*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* @NI_MAXHOST
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %10
%18 = alloca i8, i64 %16
store i64 %16, i64* %11
%19 = call i32 @getifaddrs(%struct.ifaddrs** %6)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %25
21: ; preds = %2
%22 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %2
%26 = load %struct.ifaddrs*, %struct.ifaddrs** %6
store %struct.ifaddrs* %26, %struct.ifaddrs** %7
br label %27
27: ; preds = %147, %25
%28 = load %struct.ifaddrs*, %struct.ifaddrs** %7
%29 = icmp ne %struct.ifaddrs* %28, null
br i1 %29, label %30, label %151
30: ; preds = %27
%31 = load %struct.ifaddrs*, %struct.ifaddrs** %7
%32 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %31, i32 0, i32 1
%33 = load %struct.TYPE_2__*, %struct.TYPE_2__** %32
%34 = icmp eq %struct.TYPE_2__* %33, null
br i1 %34, label %35, label %36
35: ; preds = %30
br label %147
36: ; preds = %30
%37 = load %struct.ifaddrs*, %struct.ifaddrs** %7
%38 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %37, i32 0, i32 1
%39 = load %struct.TYPE_2__*, %struct.TYPE_2__** %38
%40 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %39, i32 0, i32 0
%41 = load i32, i32* %40
store i32 %41, i32* %8
%42 = load %struct.ifaddrs*, %struct.ifaddrs** %7
%43 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %42, i32 0, i32 0
%44 = load i8*, i8** %43
%45 = load i32, i32* %8
%46 = load i32, i32* %8
%47 = load i32, i32* @AF_PACKET
%48 = icmp eq i32 %46, %47
br i1 %48, label %49, label %50
49: ; preds = %36
br label %63
50: ; preds = %36
%51 = load i32, i32* %8
%52 = load i32, i32* @AF_INET
%53 = icmp eq i32 %51, %52
br i1 %53, label %54, label %55
54: ; preds = %50
br label %61
55: ; preds = %50
%56 = load i32, i32* %8
%57 = load i32, i32* @AF_INET6
%58 = icmp eq i32 %56, %57
%59 = zext i1 %58 to i64
%60 = select i1 %58, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0)
br label %61
61: ; preds = %55, %54
%62 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), %54 ], [ %60, %55 ]
br label %63
63: ; preds = %61, %49
%64 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), %49 ], [ %62, %61 ]
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %44, i32 %45, i8* %64)
%66 = load i32, i32* %8
%67 = load i32, i32* @AF_INET
%68 = icmp eq i32 %66, %67
br i1 %68, label %73, label %69
69: ; preds = %63
%70 = load i32, i32* %8
%71 = load i32, i32* @AF_INET6
%72 = icmp eq i32 %70, %71
br i1 %72, label %73, label %145
73: ; preds = %69, %63
%74 = load %struct.ifaddrs*, %struct.ifaddrs** %7
%75 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %74, i32 0, i32 1
%76 = load %struct.TYPE_2__*, %struct.TYPE_2__** %75
%77 = load i32, i32* %8
%78 = load i32, i32* @AF_INET
%79 = icmp eq i32 %77, %78
%80 = zext i1 %79 to i64
%81 = select i1 %79, i64 4, i64 4
%82 = trunc i64 %81 to i32
%83 = load i32, i32* @NI_MAXHOST
%84 = load i32, i32* @NI_NUMERICHOST
%85 = call i32 @getnameinfo(%struct.TYPE_2__* %76, i32 %82, i8* %18, i32 %83, i32* null, i32 0, i32 %84)
store i32 %85, i32* %9
%86 = load i32, i32* %8
%87 = load i32, i32* @AF_INET
%88 = icmp eq i32 %86, %87
br i1 %88, label %89, label %114
89: ; preds = %73
%90 = load %struct.ifaddrs*, %struct.ifaddrs** %7
%91 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %90, i32 0, i32 3
%92 = load i64, i64* %91
%93 = inttoptr i64 %92 to %struct.sockaddr_in*
%94 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %93, i32 0, i32 0
%95 = load i32, i32* %94
%96 = call i8* @inet_ntoa(i32 %95)
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %96)
%98 = load %struct.ifaddrs*, %struct.ifaddrs** %7
%99 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %98, i32 0, i32 1
%100 = load %struct.TYPE_2__*, %struct.TYPE_2__** %99
%101 = bitcast %struct.TYPE_2__* %100 to %struct.sockaddr_in*
%102 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %101, i32 0, i32 0
%103 = load i32, i32* %102
%104 = call i8* @inet_ntoa(i32 %103)
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* %104)
%106 = load %struct.ifaddrs*, %struct.ifaddrs** %7
%107 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %106, i32 0, i32 2
%108 = load i64, i64* %107
%109 = inttoptr i64 %108 to %struct.sockaddr_in*
%110 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %109, i32 0, i32 0
%111 = load i32, i32* %110
%112 = call i8* @inet_ntoa(i32 %111)
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* %112)
br label %114
114: ; preds = %89, %73
%115 = load i32, i32* %8
%116 = load i32, i32* @AF_INET6
%117 = icmp eq i32 %115, %116
br i1 %117, label %118, label %134
118: ; preds = %114
%119 = load i32, i32* @INET6_ADDRSTRLEN
%120 = zext i32 %119 to i64
%121 = call i8* @llvm.stacksave()
store i8* %121, i8** %12
%122 = alloca i8, i64 %120
store i64 %120, i64* %13
%123 = load %struct.ifaddrs*, %struct.ifaddrs** %7
%124 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %123, i32 0, i32 1
%125 = load %struct.TYPE_2__*, %struct.TYPE_2__** %124
%126 = bitcast %struct.TYPE_2__* %125 to %struct.sockaddr_in6*
store %struct.sockaddr_in6* %126, %struct.sockaddr_in6** %14
%127 = load i32, i32* @AF_INET6
%128 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %14
%129 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %128, i32 0, i32 0
%130 = trunc i64 %120 to i32
%131 = call i32 @inet_ntop(i32 %127, i32* %129, i8* %122, i32 %130)
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %122)
%133 = load i8*, i8** %12
br label %134
134: ; preds = %118, %114
%135 = load i32, i32* %9
%136 = icmp ne i32 %135, 0
br i1 %136, label %137, label %143
137: ; preds = %134
%138 = load i32, i32* %9
%139 = call i8* @gai_strerror(i32 %138)
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i8* %139)
%141 = load i32, i32* @EXIT_FAILURE
%142 = call i32 @exit(i32 %141)
unreachable
143: ; preds = %134
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %18)
br label %145
145: ; preds = %143, %69
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
br label %147
147: ; preds = %145, %35
%148 = load %struct.ifaddrs*, %struct.ifaddrs** %7
%149 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %148, i32 0, i32 4
%150 = load %struct.ifaddrs*, %struct.ifaddrs** %149
store %struct.ifaddrs* %150, %struct.ifaddrs** %7
br label %27
151: ; preds = %27
%152 = load %struct.ifaddrs*, %struct.ifaddrs** %6
%153 = call i32 @freeifaddrs(%struct.ifaddrs* %152)
%154 = load i32, i32* @EXIT_SUCCESS
%155 = call i32 @exit(i32 %154)
unreachable
}

LLVM IR (-O2):
%struct.ifaddrs = type { i8*, %struct.TYPE_2__*, i64, i64, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr_in6 = type { i32 }
@NI_MAXHOST = global i32 0
@.str = [11 x i8] c"getifaddrs\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [26 x i8] c"%s address family: %d%s\0A\00"
@AF_PACKET = global i32 0
@.str.2 = [13 x i8] c" (AF_PACKET)\00"
@AF_INET = global i32 0
@.str.3 = [11 x i8] c" (AF_INET)\00"
@AF_INET6 = global i32 0
@.str.4 = [12 x i8] c" (AF_INET6)\00"
@.str.5 = [1 x i8] zeroinitializer
@NI_NUMERICHOST = global i32 0
@.str.6 = [11 x i8] c"bcast: %s\0A\00"
@.str.7 = [11 x i8] c"addr : %s\0A\00"
@.str.8 = [11 x i8] c"netm : %s\0A\00"
@INET6_ADDRSTRLEN = global i32 0
@.str.9 = [26 x i8] c"getnameinfo() failed: %s\0A\00"
@.str.10 = [16 x i8] c"\09address: <%s>\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.ifaddrs*
%4 = bitcast %struct.ifaddrs** %3 to i8*
%5 = load i32, i32* @NI_MAXHOST
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = call i32 @getifaddrs(%struct.ifaddrs** %3)
%9 = icmp eq i32 %8, -1
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%12 = icmp eq %struct.ifaddrs* %11, null
br i1 %12, label %103, label %17
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %10, %97
%18 = phi %struct.ifaddrs* [ %99, %97 ], [ %11, %10 ]
%19 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %18, i64 0, i32 1
%20 = load %struct.TYPE_2__*, %struct.TYPE_2__** %19
%21 = icmp eq %struct.TYPE_2__* %20, null
br i1 %21, label %97, label %22
22: ; preds = %17
%23 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %20, i64 0, i32 0
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %18, i64 0, i32 0
%26 = load i8*, i8** %25
%27 = load i32, i32* @AF_PACKET
%28 = icmp eq i32 %24, %27
br i1 %28, label %36, label %29
29: ; preds = %22
%30 = load i32, i32* @AF_INET
%31 = icmp eq i32 %24, %30
br i1 %31, label %36, label %32
32: ; preds = %29
%33 = load i32, i32* @AF_INET6
%34 = icmp eq i32 %24, %33
%35 = select i1 %34, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0)
br label %36
36: ; preds = %32, %29, %22
%37 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), %22 ], [ %35, %32 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), %29 ]
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %26, i32 %24, i8* %37)
%39 = load i32, i32* @AF_INET
%40 = icmp eq i32 %24, %39
%41 = load i32, i32* @AF_INET6
%42 = icmp eq i32 %24, %41
%43 = select i1 %40, i1 true, i1 %42
br i1 %43, label %44, label %95
44: ; preds = %36
%45 = load %struct.TYPE_2__*, %struct.TYPE_2__** %19
%46 = load i32, i32* @NI_MAXHOST
%47 = load i32, i32* @NI_NUMERICHOST
%48 = call i32 @getnameinfo(%struct.TYPE_2__* %45, i32 4, i8* %7, i32 %46, i32* null, i32 0, i32 %47)
%49 = load i32, i32* @AF_INET
%50 = icmp eq i32 %24, %49
br i1 %50, label %51, label %72
51: ; preds = %44
%52 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %18, i64 0, i32 3
%53 = load i64, i64* %52
%54 = inttoptr i64 %53 to %struct.sockaddr_in*
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %54, i64 0, i32 0
%56 = load i32, i32* %55
%57 = call i8* @inet_ntoa(i32 %56)
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %57)
%59 = bitcast %struct.TYPE_2__** %19 to %struct.sockaddr_in**
%60 = load %struct.sockaddr_in*, %struct.sockaddr_in** %59
%61 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %60, i64 0, i32 0
%62 = load i32, i32* %61
%63 = call i8* @inet_ntoa(i32 %62)
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* %63)
%65 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %18, i64 0, i32 2
%66 = load i64, i64* %65
%67 = inttoptr i64 %66 to %struct.sockaddr_in*
%68 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %67, i64 0, i32 0
%69 = load i32, i32* %68
%70 = call i8* @inet_ntoa(i32 %69)
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* %70)
br label %72
72: ; preds = %51, %44
%73 = load i32, i32* @AF_INET6
%74 = icmp eq i32 %24, %73
br i1 %74, label %75, label %86
75: ; preds = %72
%76 = load i32, i32* @INET6_ADDRSTRLEN
%77 = zext i32 %76 to i64
%78 = call i8* @llvm.stacksave()
%79 = alloca i8, i64 %77
%80 = bitcast %struct.TYPE_2__** %19 to %struct.sockaddr_in6**
%81 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %80
%82 = load i32, i32* @AF_INET6
%83 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %81, i64 0, i32 0
%84 = call i32 @inet_ntop(i32 %82, i32* %83, i8* %79, i32 %76)
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %79)
br label %86
86: ; preds = %75, %72
%87 = icmp eq i32 %48, 0
br i1 %87, label %93, label %88
88: ; preds = %86
%89 = call i8* @gai_strerror(i32 %48)
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i8* %89)
%91 = load i32, i32* @EXIT_FAILURE
%92 = call i32 @exit(i32 %91)
unreachable
93: ; preds = %86
%94 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %7)
br label %95
95: ; preds = %36, %93
%96 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %97
97: ; preds = %17, %95
%98 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %18, i64 0, i32 4
%99 = load %struct.ifaddrs*, %struct.ifaddrs** %98
%100 = icmp eq %struct.ifaddrs* %99, null
br i1 %100, label %101, label %17
101: ; preds = %97
%102 = load %struct.ifaddrs*, %struct.ifaddrs** %3
br label %103
103: ; preds = %101, %10
%104 = phi %struct.ifaddrs* [ %102, %101 ], [ null, %10 ]
%105 = call i32 @freeifaddrs(%struct.ifaddrs* %104)
%106 = load i32, i32* @EXIT_SUCCESS
%107 = call i32 @exit(i32 %106)
unreachable
}