#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_6__ TYPE_3__;
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in6 {
  TYPE_3__ sin6_addr;
};
struct sockaddr_in {
  TYPE_3__ sin_addr;
};
struct ifaddrs {
  char *ifa_name;
  int ifa_flags;
  struct ifaddrs *ifa_next;
  TYPE_2__ *ifa_netmask;
  TYPE_1__ *ifa_addr;
};
typedef int /*<<< orphan*/ addr_str;
struct TYPE_5__ {
  int sa_family;
};
struct TYPE_4__ {
  int sa_family;
};

/* Variables and functions */
int AF_INET;
int AF_INET6;
int /*<<< orphan*/ freeifaddrs(struct ifaddrs *);
scalar_t__ getifaddrs(struct ifaddrs **);
scalar_t__ inet_ntop(int, TYPE_3__ *, char *, int);
int ntohl(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int af = AF_INET;
  char addr_str[32];
  struct ifaddrs *ifap = NULL, *tmp_ifap;
  struct sockaddr_in *sk_addr;
  if (getifaddrs(&ifap) < 0) {
    perror("getifaddrs failed:");
    return -1;
  }
  tmp_ifap = ifap;
  while (tmp_ifap) {
    printf("ifa_name: %s\n", tmp_ifap->ifa_name);
    printf("ifa_flags: %x\n", tmp_ifap->ifa_flags);
    sk_addr = (struct sockaddr_in *)tmp_ifap->ifa_addr;
    printf("ifa_addr: %0x\n", ntohl(sk_addr->sin_addr.s_addr));
    if (tmp_ifap->ifa_addr) {
      if (tmp_ifap->ifa_addr->sa_family == AF_INET &&
          inet_ntop(AF_INET,
                    &(((struct sockaddr_in *)tmp_ifap->ifa_addr)->sin_addr),
                    addr_str, sizeof(addr_str))) {
        printf("addr: %s\n", addr_str);
      } else if (tmp_ifap->ifa_addr->sa_family == AF_INET6 &&
                 inet_ntop(
                     AF_INET6,
                     &(((struct sockaddr_in6 *)tmp_ifap->ifa_addr)->sin6_addr),
                     addr_str, sizeof(addr_str))) {
        printf("addr: %s\n", addr_str);
      }
    }
    if (tmp_ifap->ifa_netmask) {
      if (tmp_ifap->ifa_netmask->sa_family == AF_INET &&
          inet_ntop(AF_INET,
                    &(((struct sockaddr_in *)tmp_ifap->ifa_netmask)->sin_addr),
                    addr_str, sizeof(addr_str))) {
        printf("netmask: %s\n", addr_str);
      } else if (tmp_ifap->ifa_addr->sa_family == AF_INET6 &&
                 inet_ntop(AF_INET6,
                           &(((struct sockaddr_in6 *)tmp_ifap->ifa_netmask)
                                 ->sin6_addr),
                           addr_str, sizeof(addr_str))) {
        printf("netmask: %s\n", addr_str);
      }
    }
    printf("\n\n");
    tmp_ifap = tmp_ifap->ifa_next;
  }
  freeifaddrs(tmp_ifap);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x38(%rbp),%rdi
call   1050 <getifaddrs@plt>
cmp    $0x0,%rax
jge    11ae <main+0x4e>
lea    0xe63(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13c6 <main+0x266>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     13bd <main+0x25d>
mov    -0x40(%rbp),%rax
mov    (%rax),%rsi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    (%rax),%edi
call   1080 <ntohl@plt>
mov    %eax,%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40(%rbp),%rax
cmpq   $0x0,0x20(%rax)
je     12d8 <main+0x178>
mov    -0x40(%rbp),%rax
mov    0x20(%rax),%rax
mov    (%rax),%eax
mov    0x2db6(%rip),%rcx
cmp    (%rcx),%eax
jne    127a <main+0x11a>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rax
mov    0x20(%rax),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x20,%ecx
call   1030 <inet_ntop@plt>
cmp    $0x0,%rax
je     127a <main+0x11a>
lea    -0x30(%rbp),%rsi
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12d3 <main+0x173>
mov    -0x40(%rbp),%rax
mov    0x20(%rax),%rax
mov    (%rax),%eax
mov    0x2d55(%rip),%rcx
cmp    (%rcx),%eax
jne    12ce <main+0x16e>
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rax
mov    0x20(%rax),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x20,%ecx
call   1030 <inet_ntop@plt>
cmp    $0x0,%rax
je     12ce <main+0x16e>
lea    -0x30(%rbp),%rsi
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12d3 <main+0x173>
jmp    12d8 <main+0x178>
mov    -0x40(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     139e <main+0x23e>
mov    -0x40(%rbp),%rax
mov    0x18(%rax),%rax
mov    (%rax),%eax
mov    0x2cf0(%rip),%rcx
cmp    (%rcx),%eax
jne    1340 <main+0x1e0>
mov    0x2ce1(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rax
mov    0x18(%rax),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x20,%ecx
call   1030 <inet_ntop@plt>
cmp    $0x0,%rax
je     1340 <main+0x1e0>
lea    -0x30(%rbp),%rsi
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1399 <main+0x239>
mov    -0x40(%rbp),%rax
mov    0x20(%rax),%rax
mov    (%rax),%eax
mov    0x2c8f(%rip),%rcx
cmp    (%rcx),%eax
jne    1394 <main+0x234>
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rax
mov    0x18(%rax),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x20,%ecx
call   1030 <inet_ntop@plt>
cmp    $0x0,%rax
je     1394 <main+0x234>
lea    -0x30(%rbp),%rsi
lea    0xcbc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1399 <main+0x239>
jmp    139e <main+0x23e>
lea    0xcb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x40(%rbp)
jmp    11b6 <main+0x56>
mov    -0x40(%rbp),%rdi
call   1060 <freeifaddrs@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1060 <getifaddrs@plt>
test   %rax,%rax
js     12fe <main+0x18e>
mov    0x8(%rsp),%rbp
test   %rbp,%rbp
je     12e4 <main+0x174>
lea    0xe72(%rip),%r15
lea    0xe7a(%rip),%r12
lea    0xe62(%rip),%r13
mov    0x2e24(%rip),%r14
lea    0x10(%rsp),%rbx
jmp    120c <main+0x9c>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdx
mov    $0x20,%ecx
call   1030 <inet_ntop@plt>
test   %rax,%rax
je     12b0 <main+0x140>
lea    0xe5c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    0x10(%rbp),%rbp
test   %rbp,%rbp
je     12e4 <main+0x174>
mov    0x0(%rbp),%rsi
lea    0xdfc(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbp),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rbp),%rax
mov    (%rax),%edi
call   1090 <ntohl@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rbp),%rsi
test   %rsi,%rsi
je     1298 <main+0x128>
mov    (%rsi),%edi
cmp    (%r14),%edi
jne    126a <main+0xfa>
mov    %rbx,%rdx
mov    $0x20,%ecx
call   1030 <inet_ntop@plt>
test   %rax,%rax
jne    1287 <main+0x117>
mov    0x20(%rbp),%rsi
mov    (%rsi),%edi
mov    0x2d6f(%rip),%rax
cmp    (%rax),%edi
jne    1298 <main+0x128>
mov    %rbx,%rdx
mov    $0x20,%ecx
call   1030 <inet_ntop@plt>
test   %rax,%rax
je     1298 <main+0x128>
lea    0xdb1(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rbp),%rsi
test   %rsi,%rsi
je     11f7 <main+0x87>
mov    (%rsi),%edi
cmp    (%r14),%edi
je     11d0 <main+0x60>
mov    0x20(%rbp),%rax
mov    (%rax),%edi
mov    0x2d23(%rip),%rax
cmp    (%rax),%edi
jne    11f7 <main+0x87>
mov    0x18(%rbp),%rsi
mov    %rbx,%rdx
mov    $0x20,%ecx
call   1030 <inet_ntop@plt>
test   %rax,%rax
jne    11e6 <main+0x76>
jmp    11f7 <main+0x87>
xor    %ebx,%ebx
xor    %edi,%edi
call   1070 <freeifaddrs@plt>
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcfb(%rip),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%ebx
jmp    12ed <main+0x17d>

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

LLVM IR (-O2):
%struct.ifaddrs = type { i8*, i32, %struct.ifaddrs*, %struct.TYPE_5__*, %struct.TYPE_4__* }
%struct.TYPE_5__ = type { i32 }
%struct.TYPE_4__ = type { i32 }
%struct.sockaddr_in = type { %struct.TYPE_6__ }
%struct.TYPE_6__ = type { i32 }
%struct.sockaddr_in6 = type { %struct.TYPE_6__ }
@AF_INET = global i32 0
@.str = [19 x i8] c"getifaddrs failed:\00"
@.str.1 = [14 x i8] c"ifa_name: %s\0A\00"
@.str.2 = [15 x i8] c"ifa_flags: %x\0A\00"
@.str.3 = [15 x i8] c"ifa_addr: %0x\0A\00"
@.str.4 = [10 x i8] c"addr: %s\0A\00"
@AF_INET6 = global i32 0
@.str.5 = [13 x i8] c"netmask: %s\0A\00"
@str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca [32 x i8]
%2 = alloca %struct.ifaddrs*
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%4 = bitcast %struct.ifaddrs** %2 to i8*
store %struct.ifaddrs* null, %struct.ifaddrs** %2
%5 = call i64 @getifaddrs(%struct.ifaddrs** %2)
%6 = icmp slt i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%9 = icmp eq %struct.ifaddrs* %8, null
br i1 %9, label %85, label %12
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %87
12: ; preds = %7, %80
%13 = phi %struct.ifaddrs* [ %83, %80 ], [ %8, %7 ]
%14 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %13, i64 0, i32 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %13, i64 0, i32 1
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %13, i64 0, i32 4
%21 = bitcast %struct.TYPE_4__** %20 to %struct.sockaddr_in**
%22 = load %struct.sockaddr_in*, %struct.sockaddr_in** %21
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %22, i64 0, i32 0, i32 0
%24 = load i32, i32* %23
%25 = call i32 @ntohl(i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load %struct.TYPE_4__*, %struct.TYPE_4__** %20
%28 = icmp eq %struct.TYPE_4__* %27, null
br i1 %28, label %53, label %29
29: ; preds = %12
%30 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %27, i64 0, i32 0
%31 = load i32, i32* %30
%32 = load i32, i32* @AF_INET
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %42
34: ; preds = %29
%35 = bitcast %struct.TYPE_4__* %27 to %struct.TYPE_6__*
%36 = call i64 @inet_ntop(i32 %31, %struct.TYPE_6__* %35, i8* %3, i32 32)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %51
38: ; preds = %34
%39 = load %struct.TYPE_4__*, %struct.TYPE_4__** %20
%40 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %39, i64 0, i32 0
%41 = load i32, i32* %40
br label %42
42: ; preds = %38, %29
%43 = phi i32 [ %41, %38 ], [ %31, %29 ]
%44 = phi %struct.TYPE_4__* [ %39, %38 ], [ %27, %29 ]
%45 = load i32, i32* @AF_INET6
%46 = icmp eq i32 %43, %45
br i1 %46, label %47, label %53
47: ; preds = %42
%48 = bitcast %struct.TYPE_4__* %44 to %struct.TYPE_6__*
%49 = call i64 @inet_ntop(i32 %43, %struct.TYPE_6__* %48, i8* %3, i32 32)
%50 = icmp eq i64 %49, 0
br i1 %50, label %53, label %51
51: ; preds = %47, %34
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %3)
br label %53
53: ; preds = %51, %47, %42, %12
%54 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %13, i64 0, i32 3
%55 = load %struct.TYPE_5__*, %struct.TYPE_5__** %54
%56 = icmp eq %struct.TYPE_5__* %55, null
br i1 %56, label %80, label %57
57: ; preds = %53
%58 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %55, i64 0, i32 0
%59 = load i32, i32* %58
%60 = load i32, i32* @AF_INET
%61 = icmp eq i32 %59, %60
br i1 %61, label %62, label %66
62: ; preds = %57
%63 = bitcast %struct.TYPE_5__* %55 to %struct.TYPE_6__*
%64 = call i64 @inet_ntop(i32 %59, %struct.TYPE_6__* %63, i8* %3, i32 32)
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %78
66: ; preds = %62, %57
%67 = load %struct.TYPE_4__*, %struct.TYPE_4__** %20
%68 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %67, i64 0, i32 0
%69 = load i32, i32* %68
%70 = load i32, i32* @AF_INET6
%71 = icmp eq i32 %69, %70
br i1 %71, label %72, label %80
72: ; preds = %66
%73 = bitcast %struct.TYPE_5__** %54 to %struct.sockaddr_in6**
%74 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %73
%75 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %74, i64 0, i32 0
%76 = call i64 @inet_ntop(i32 %69, %struct.TYPE_6__* %75, i8* %3, i32 32)
%77 = icmp eq i64 %76, 0
br i1 %77, label %80, label %78
78: ; preds = %72, %62
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %3)
br label %80
80: ; preds = %78, %72, %66, %53
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%82 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %13, i64 0, i32 2
%83 = load %struct.ifaddrs*, %struct.ifaddrs** %82
%84 = icmp eq %struct.ifaddrs* %83, null
br i1 %84, label %85, label %12
85: ; preds = %80, %7
%86 = call i32 @freeifaddrs(%struct.ifaddrs* null)
br label %87
87: ; preds = %85, %10
%88 = phi i32 [ -1, %10 ], [ 0, %85 ]
ret i32 %88
}