#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_10__ TYPE_5__;
typedef struct TYPE_9__ TYPE_4__;
typedef struct TYPE_8__ TYPE_3__;
typedef struct TYPE_7__ TYPE_2__;
typedef struct TYPE_6__ TYPE_1__;

/* Type definitions */
struct sockaddr_in6 {
  int /*<<< orphan*/ sin6_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
};
struct TYPE_10__ {
  TYPE_4__ *ifu_broadaddr;
  TYPE_3__ *ifu_dstaddr;
};
struct ifaddrs {
  char *ifa_name;
  int ifa_flags;
  TYPE_5__ ifa_ifu;
  TYPE_2__ *ifa_netmask;
  TYPE_1__ *ifa_addr;
  struct ifaddrs *ifa_next;
};
typedef int /*<<< orphan*/ addressOutputBuffer;
struct TYPE_9__ {
  scalar_t__ sa_family;
};
struct TYPE_8__ {
  scalar_t__ sa_family;
};
struct TYPE_7__ {
  scalar_t__ sa_family;
};
struct TYPE_6__ {
  scalar_t__ sa_family;
};

/* Variables and functions */
scalar_t__ AF_INET;
int IFF_POINTOPOINT;
int INET6_ADDRSTRLEN;
int errno;
int /*<<< orphan*/ freeifaddrs(struct ifaddrs *);
int getifaddrs(struct ifaddrs **);
char *inet_ntop(scalar_t__, void *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
char *strerror(int);
int getIP(void) {
  struct ifaddrs *interfaceArray = NULL, *tempIfAddr = NULL;
  void *tempAddrPtr = NULL;
  int rc = 0;
  char addressOutputBuffer[INET6_ADDRSTRLEN];
  rc = getifaddrs(&interfaceArray);
  if (rc == 0) {
    for (tempIfAddr = interfaceArray; tempIfAddr != NULL;
         tempIfAddr = tempIfAddr->ifa_next) {
      if (tempIfAddr->ifa_addr->sa_family == AF_INET)
        tempAddrPtr = &((struct sockaddr_in *)tempIfAddr->ifa_addr)->sin_addr;
      else
        tempAddrPtr = &((struct sockaddr_in6 *)tempIfAddr->ifa_addr)->sin6_addr;
      printf("Internet Address:  %s \n",
             inet_ntop(tempIfAddr->ifa_addr->sa_family, tempAddrPtr,
                       addressOutputBuffer, sizeof(addressOutputBuffer)));
      printf("LineDescription :  %s \n", tempIfAddr->ifa_name);
      if (tempIfAddr->ifa_netmask != NULL) {
        if (tempIfAddr->ifa_netmask->sa_family == AF_INET)
          tempAddrPtr =
              &((struct sockaddr_in *)tempIfAddr->ifa_netmask)->sin_addr;
        else
          tempAddrPtr =
              &((struct sockaddr_in6 *)tempIfAddr->ifa_netmask)->sin6_addr;
        printf("Netmask         :  %s \n",
               inet_ntop(tempIfAddr->ifa_netmask->sa_family, tempAddrPtr,
                         addressOutputBuffer, sizeof(addressOutputBuffer)));
      }
      if (tempIfAddr->ifa_ifu.ifu_broadaddr != NULL) {
        if (tempIfAddr->ifa_flags & IFF_POINTOPOINT) {
          printf("Destination Addr:  ");
          if (tempIfAddr->ifa_ifu.ifu_dstaddr->sa_family == AF_INET)
            tempAddrPtr =
                &((struct sockaddr_in *)tempIfAddr->ifa_ifu.ifu_dstaddr)
                     ->sin_addr;
          else
            tempAddrPtr =
                &((struct sockaddr_in6 *)tempIfAddr->ifa_ifu.ifu_dstaddr)
                     ->sin6_addr;
        } else {
          printf("Broadcast Addr  :  ");
          if (tempIfAddr->ifa_ifu.ifu_broadaddr->sa_family == AF_INET)
            tempAddrPtr =
                &((struct sockaddr_in *)tempIfAddr->ifa_ifu.ifu_broadaddr)
                     ->sin_addr;
          else
            tempAddrPtr =
                &((struct sockaddr_in6 *)tempIfAddr->ifa_ifu.ifu_broadaddr)
                     ->sin6_addr;
        }
        printf("%s \n", inet_ntop(tempIfAddr->ifa_ifu.ifu_broadaddr->sa_family,
                                  tempAddrPtr, addressOutputBuffer,
                                  sizeof(addressOutputBuffer)));
      }
      printf("\n");
    }
    freeifaddrs(interfaceArray);
    interfaceArray = NULL;
  } else {
    printf("getifaddrs() failed with errno =  %d %s \n", errno,
           strerror(errno));
    return rc;
  }
}


x86 assembly (clang, -O0):
<getIP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x50(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
lea    -0x10(%rbp),%rdi
call   1050 <getifaddrs@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    13e4 <getIP+0x294>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     13ce <getIP+0x27e>
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%rax
mov    (%rax),%rax
mov    0x2dfe(%rip),%rcx
cmp    (%rcx),%rax
jne    11fc <getIP+0xac>
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1208 <getIP+0xb8>
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    0x28(%rcx),%rcx
mov    (%rcx),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%rsi
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x20(%rax)
je     12c2 <getIP+0x172>
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rax
mov    (%rax),%rax
mov    0x2d73(%rip),%rcx
cmp    (%rcx),%rax
jne    1287 <getIP+0x137>
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1293 <getIP+0x143>
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    0x20(%rcx),%rcx
mov    (%rcx),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%rsi
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     13af <getIP+0x25f>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x2cf9(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1335 <getIP+0x1e5>
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    (%rax),%rax
mov    0x2cd6(%rip),%rcx
cmp    (%rcx),%rax
jne    1324 <getIP+0x1d4>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1330 <getIP+0x1e0>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1380 <getIP+0x230>
lea    0xd20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%rax
mov    0x2c8b(%rip),%rcx
cmp    (%rcx),%rax
jne    136f <getIP+0x21f>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    137b <getIP+0x22b>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1380 <getIP+0x230>
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    0x10(%rcx),%rcx
mov    (%rcx),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%rsi
lea    0xc9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x30(%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    11c5 <getIP+0x75>
mov    -0x10(%rbp),%rdi
call   1060 <freeifaddrs@plt>
movq   $0x0,-0x10(%rbp)
jmp    1424 <getIP+0x2d4>
mov    0x2bdd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    0x2bd1(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x54(%rbp),%esi
mov    %rax,%rdx
lea    0xc65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    142b <getIP+0x2db>
movl   $0x0,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getIP>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsp,%r12
movq   $0x0,-0x30(%rbp)
mov    0x2e65(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%rbx
lea    0xf(%r15),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    -0x30(%rbp),%rdi
call   1060 <getifaddrs@plt>
mov    %eax,%r13d
test   %eax,%eax
je     11cf <getIP+0x6f>
mov    0x2e22(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1080 <strerror@plt>
lea    0xeb2(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12e8 <getIP+0x188>
mov    -0x30(%rbp),%r14
test   %r14,%r14
je     12d9 <getIP+0x179>
mov    %r13d,-0x34(%rbp)
mov    %r12,-0x40(%rbp)
lea    0xe2d(%rip),%r13
jmp    123e <getIP+0xde>
nopl   (%rax)
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rax
mov    (%rax),%rsi
mov    (%r12),%rax
mov    (%rax),%rdi
mov    %rbx,%rdx
mov    %r15d,%ecx
call   1030 <inet_ntop@plt>
lea    0xe26(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x30(%r14),%r14
test   %r14,%r14
je     12cb <getIP+0x16b>
mov    0x28(%r14),%rsi
mov    (%rsi),%rdi
mov    %rbx,%rdx
mov    %r15d,%ecx
call   1030 <inet_ntop@plt>
lea    0xda9(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r14),%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%r14),%rsi
test   %rsi,%rsi
je     1296 <getIP+0x136>
mov    (%rsi),%rdi
mov    %rbx,%rdx
mov    %r15d,%ecx
call   1030 <inet_ntop@plt>
lea    0xda4(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
cmpq   $0x0,0x10(%r14)
je     1227 <getIP+0xc7>
lea    0x10(%r14),%r12
mov    0x2d38(%rip),%rax
mov    (%rax),%eax
test   %eax,0x8(%r14)
je     11f0 <getIP+0x90>
lea    0xd8d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x18(%r14),%rax
jmp    1201 <getIP+0xa1>
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%r12
mov    -0x34(%rbp),%r13d
jmp    12db <getIP+0x17b>
xor    %edi,%edi
call   1070 <freeifaddrs@plt>
movq   $0x0,-0x30(%rbp)
mov    %r12,%rsp
mov    %r13d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ifaddrs = type { i8*, i32, %struct.TYPE_10__, %struct.TYPE_7__*, %struct.TYPE_6__*, %struct.ifaddrs* }
%struct.TYPE_10__ = type { %struct.TYPE_9__*, %struct.TYPE_8__* }
%struct.TYPE_9__ = type { i64 }
%struct.TYPE_8__ = type { i64 }
%struct.TYPE_7__ = type { i64 }
%struct.TYPE_6__ = type { i64 }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr_in6 = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@AF_INET = global i64 0
@.str = [24 x i8] c"Internet Address: %s \0A\00"
@.str.1 = [24 x i8] c"LineDescription : %s \0A\00"
@.str.2 = [24 x i8] c"Netmask : %s \0A\00"
@IFF_POINTOPOINT = global i32 0
@.str.3 = [20 x i8] c"Destination Addr: \00"
@.str.4 = [20 x i8] c"Broadcast Addr : \00"
@.str.5 = [5 x i8] c"%s \0A\00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [42 x i8] c"getifaddrs() failed with errno = %d %s \0A\00"
@errno = global i32 0
define i32 @getIP() {
%1 = alloca i32
%2 = alloca %struct.ifaddrs*
%3 = alloca %struct.ifaddrs*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
store %struct.ifaddrs* null, %struct.ifaddrs** %2
store %struct.ifaddrs* null, %struct.ifaddrs** %3
store i8* null, i8** %4
store i32 0, i32* %5
%9 = load i32, i32* @INET6_ADDRSTRLEN
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %6
%12 = alloca i8, i64 %10
store i64 %10, i64* %7
%13 = call i32 @getifaddrs(%struct.ifaddrs** %2)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %180
16: ; preds = %0
%17 = load %struct.ifaddrs*, %struct.ifaddrs** %2
store %struct.ifaddrs* %17, %struct.ifaddrs** %3
br label %18
18: ; preds = %173, %16
%19 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%20 = icmp ne %struct.ifaddrs* %19, null
br i1 %20, label %21, label %177
21: ; preds = %18
%22 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%23 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %22, i32 0, i32 4
%24 = load %struct.TYPE_6__*, %struct.TYPE_6__** %23
%25 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %24, i32 0, i32 0
%26 = load i64, i64* %25
%27 = load i64, i64* @AF_INET
%28 = icmp eq i64 %26, %27
br i1 %28, label %29, label %36
29: ; preds = %21
%30 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%31 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %30, i32 0, i32 4
%32 = load %struct.TYPE_6__*, %struct.TYPE_6__** %31
%33 = bitcast %struct.TYPE_6__* %32 to %struct.sockaddr_in*
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %33, i32 0, i32 0
%35 = bitcast i32* %34 to i8*
store i8* %35, i8** %4
br label %43
36: ; preds = %21
%37 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%38 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %37, i32 0, i32 4
%39 = load %struct.TYPE_6__*, %struct.TYPE_6__** %38
%40 = bitcast %struct.TYPE_6__* %39 to %struct.sockaddr_in6*
%41 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %40, i32 0, i32 0
%42 = bitcast i32* %41 to i8*
store i8* %42, i8** %4
br label %43
43: ; preds = %36, %29
%44 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%45 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %44, i32 0, i32 4
%46 = load %struct.TYPE_6__*, %struct.TYPE_6__** %45
%47 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %46, i32 0, i32 0
%48 = load i64, i64* %47
%49 = load i8*, i8** %4
%50 = trunc i64 %10 to i32
%51 = call i8* @inet_ntop(i64 %48, i8* %49, i8* %12, i32 %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %51)
%53 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%54 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %53, i32 0, i32 0
%55 = load i8*, i8** %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %55)
%57 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%58 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %57, i32 0, i32 3
%59 = load %struct.TYPE_7__*, %struct.TYPE_7__** %58
%60 = icmp ne %struct.TYPE_7__* %59, null
br i1 %60, label %61, label %93
61: ; preds = %43
%62 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%63 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %62, i32 0, i32 3
%64 = load %struct.TYPE_7__*, %struct.TYPE_7__** %63
%65 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %64, i32 0, i32 0
%66 = load i64, i64* %65
%67 = load i64, i64* @AF_INET
%68 = icmp eq i64 %66, %67
br i1 %68, label %69, label %76
69: ; preds = %61
%70 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%71 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %70, i32 0, i32 3
%72 = load %struct.TYPE_7__*, %struct.TYPE_7__** %71
%73 = bitcast %struct.TYPE_7__* %72 to %struct.sockaddr_in*
%74 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %73, i32 0, i32 0
%75 = bitcast i32* %74 to i8*
store i8* %75, i8** %4
br label %83
76: ; preds = %61
%77 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%78 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %77, i32 0, i32 3
%79 = load %struct.TYPE_7__*, %struct.TYPE_7__** %78
%80 = bitcast %struct.TYPE_7__* %79 to %struct.sockaddr_in6*
%81 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %80, i32 0, i32 0
%82 = bitcast i32* %81 to i8*
store i8* %82, i8** %4
br label %83
83: ; preds = %76, %69
%84 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%85 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %84, i32 0, i32 3
%86 = load %struct.TYPE_7__*, %struct.TYPE_7__** %85
%87 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %86, i32 0, i32 0
%88 = load i64, i64* %87
%89 = load i8*, i8** %4
%90 = trunc i64 %10 to i32
%91 = call i8* @inet_ntop(i64 %88, i8* %89, i8* %12, i32 %90)
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %91)
br label %93
93: ; preds = %83, %43
%94 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%95 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %94, i32 0, i32 2
%96 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %95, i32 0, i32 0
%97 = load %struct.TYPE_9__*, %struct.TYPE_9__** %96
%98 = icmp ne %struct.TYPE_9__* %97, null
br i1 %98, label %99, label %171
99: ; preds = %93
%100 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%101 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %100, i32 0, i32 1
%102 = load i32, i32* %101
%103 = load i32, i32* @IFF_POINTOPOINT
%104 = and i32 %102, %103
%105 = icmp ne i32 %104, 0
br i1 %105, label %106, label %133
106: ; preds = %99
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%108 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%109 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %108, i32 0, i32 2
%110 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %109, i32 0, i32 1
%111 = load %struct.TYPE_8__*, %struct.TYPE_8__** %110
%112 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %111, i32 0, i32 0
%113 = load i64, i64* %112
%114 = load i64, i64* @AF_INET
%115 = icmp eq i64 %113, %114
br i1 %115, label %116, label %124
116: ; preds = %106
%117 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%118 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %117, i32 0, i32 2
%119 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %118, i32 0, i32 1
%120 = load %struct.TYPE_8__*, %struct.TYPE_8__** %119
%121 = bitcast %struct.TYPE_8__* %120 to %struct.sockaddr_in*
%122 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %121, i32 0, i32 0
%123 = bitcast i32* %122 to i8*
store i8* %123, i8** %4
br label %132
124: ; preds = %106
%125 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%126 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %125, i32 0, i32 2
%127 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %126, i32 0, i32 1
%128 = load %struct.TYPE_8__*, %struct.TYPE_8__** %127
%129 = bitcast %struct.TYPE_8__* %128 to %struct.sockaddr_in6*
%130 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %129, i32 0, i32 0
%131 = bitcast i32* %130 to i8*
store i8* %131, i8** %4
br label %132
132: ; preds = %124, %116
br label %160
133: ; preds = %99
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%135 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%136 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %135, i32 0, i32 2
%137 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %136, i32 0, i32 0
%138 = load %struct.TYPE_9__*, %struct.TYPE_9__** %137
%139 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %138, i32 0, i32 0
%140 = load i64, i64* %139
%141 = load i64, i64* @AF_INET
%142 = icmp eq i64 %140, %141
br i1 %142, label %143, label %151
143: ; preds = %133
%144 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%145 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %144, i32 0, i32 2
%146 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %145, i32 0, i32 0
%147 = load %struct.TYPE_9__*, %struct.TYPE_9__** %146
%148 = bitcast %struct.TYPE_9__* %147 to %struct.sockaddr_in*
%149 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %148, i32 0, i32 0
%150 = bitcast i32* %149 to i8*
store i8* %150, i8** %4
br label %159
151: ; preds = %133
%152 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%153 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %152, i32 0, i32 2
%154 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %153, i32 0, i32 0
%155 = load %struct.TYPE_9__*, %struct.TYPE_9__** %154
%156 = bitcast %struct.TYPE_9__* %155 to %struct.sockaddr_in6*
%157 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %156, i32 0, i32 0
%158 = bitcast i32* %157 to i8*
store i8* %158, i8** %4
br label %159
159: ; preds = %151, %143
br label %160
160: ; preds = %159, %132
%161 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%162 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %161, i32 0, i32 2
%163 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %162, i32 0, i32 0
%164 = load %struct.TYPE_9__*, %struct.TYPE_9__** %163
%165 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %164, i32 0, i32 0
%166 = load i64, i64* %165
%167 = load i8*, i8** %4
%168 = trunc i64 %10 to i32
%169 = call i8* @inet_ntop(i64 %166, i8* %167, i8* %12, i32 %168)
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %169)
br label %171
171: ; preds = %160, %93
%172 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %173
173: ; preds = %171
%174 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%175 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %174, i32 0, i32 5
%176 = load %struct.ifaddrs*, %struct.ifaddrs** %175
store %struct.ifaddrs* %176, %struct.ifaddrs** %3
br label %18
177: ; preds = %18
%178 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%179 = call i32 @freeifaddrs(%struct.ifaddrs* %178)
store %struct.ifaddrs* null, %struct.ifaddrs** %2
br label %186
180: ; preds = %0
%181 = load i32, i32* @errno
%182 = load i32, i32* @errno
%183 = call i8* @strerror(i32 %182)
%184 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i32 %181, i8* %183)
%185 = load i32, i32* %5
store i32 %185, i32* %1
store i32 1, i32* %8
br label %187
186: ; preds = %177
store i32 0, i32* %8
br label %187
187: ; preds = %186, %180
%188 = load i8*, i8** %6
%189 = load i32, i32* %8
switch i32 %189, label %192 [
i32 0, label %190
i32 1, label %190
]
190: ; preds = %187, %187
%191 = load i32, i32* %1
ret i32 %191
192: ; preds = %187
unreachable
}

LLVM IR (-O2):
%struct.ifaddrs = type { i8*, i32, %struct.TYPE_10__, %struct.TYPE_7__*, %struct.TYPE_6__*, %struct.ifaddrs* }
%struct.TYPE_10__ = type { %struct.TYPE_9__*, %struct.TYPE_8__* }
%struct.TYPE_9__ = type { i64 }
%struct.TYPE_8__ = type { i64 }
%struct.TYPE_7__ = type { i64 }
%struct.TYPE_6__ = type { i64 }
@INET6_ADDRSTRLEN = global i32 0
@AF_INET = global i64 0
@.str = [24 x i8] c"Internet Address: %s \0A\00"
@.str.1 = [24 x i8] c"LineDescription : %s \0A\00"
@.str.2 = [24 x i8] c"Netmask : %s \0A\00"
@IFF_POINTOPOINT = global i32 0
@.str.3 = [20 x i8] c"Destination Addr: \00"
@.str.4 = [20 x i8] c"Broadcast Addr : \00"
@.str.5 = [5 x i8] c"%s \0A\00"
@.str.7 = [42 x i8] c"getifaddrs() failed with errno = %d %s \0A\00"
@errno = global i32 0
define i32 @getIP() {
%1 = alloca %struct.ifaddrs*
%2 = bitcast %struct.ifaddrs** %1 to i8*
store %struct.ifaddrs* null, %struct.ifaddrs** %1
%3 = load i32, i32* @INET6_ADDRSTRLEN
%4 = zext i32 %3 to i64
%5 = tail call i8* @llvm.stacksave()
%6 = alloca i8, i64 %4
%7 = call i32 @getifaddrs(%struct.ifaddrs** %1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %68
9: ; preds = %0
%10 = load %struct.ifaddrs*, %struct.ifaddrs** %1
%11 = icmp eq %struct.ifaddrs* %10, null
br i1 %11, label %65, label %12
12: ; preds = %9, %58
%13 = phi %struct.ifaddrs* [ %61, %58 ], [ %10, %9 ]
%14 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %13, i64 0, i32 4
%15 = load %struct.TYPE_6__*, %struct.TYPE_6__** %14
%16 = bitcast %struct.TYPE_6__* %15 to i8*
%17 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %15, i64 0, i32 0
%18 = load i64, i64* %17
%19 = call i8* @inet_ntop(i64 %18, i8* %16, i8* %6, i32 %3)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %13, i64 0, i32 0
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %13, i64 0, i32 3
%25 = load %struct.TYPE_7__*, %struct.TYPE_7__** %24
%26 = icmp eq %struct.TYPE_7__* %25, null
br i1 %26, label %33, label %27
27: ; preds = %12
%28 = bitcast %struct.TYPE_7__* %25 to i8*
%29 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %25, i64 0, i32 0
%30 = load i64, i64* %29
%31 = call i8* @inet_ntop(i64 %30, i8* %28, i8* %6, i32 %3)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %27, %12
%34 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %13, i64 0, i32 2, i32 0
%35 = load %struct.TYPE_9__*, %struct.TYPE_9__** %34
%36 = icmp eq %struct.TYPE_9__* %35, null
br i1 %36, label %58, label %37
37: ; preds = %33
%38 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %13, i64 0, i32 1
%39 = load i32, i32* %38
%40 = load i32, i32* @IFF_POINTOPOINT
%41 = and i32 %40, %39
%42 = icmp eq i32 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %37
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%45 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %13, i64 0, i32 2, i32 1
%46 = bitcast %struct.TYPE_8__** %45 to i8**
br label %50
47: ; preds = %37
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%49 = bitcast %struct.TYPE_9__** %34 to i8**
br label %50
50: ; preds = %47, %43
%51 = phi i8** [ %46, %43 ], [ %49, %47 ]
%52 = load i8*, i8** %51
%53 = load %struct.TYPE_9__*, %struct.TYPE_9__** %34
%54 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %53, i64 0, i32 0
%55 = load i64, i64* %54
%56 = call i8* @inet_ntop(i64 %55, i8* %52, i8* %6, i32 %3)
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %56)
br label %58
58: ; preds = %50, %33
%59 = call i32 @putchar(i32 10)
%60 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %13, i64 0, i32 5
%61 = load %struct.ifaddrs*, %struct.ifaddrs** %60
%62 = icmp eq %struct.ifaddrs* %61, null
br i1 %62, label %63, label %12
63: ; preds = %58
%64 = load %struct.ifaddrs*, %struct.ifaddrs** %1
br label %65
65: ; preds = %63, %9
%66 = phi %struct.ifaddrs* [ %64, %63 ], [ null, %9 ]
%67 = call i32 @freeifaddrs(%struct.ifaddrs* %66)
store %struct.ifaddrs* null, %struct.ifaddrs** %1
br label %72
68: ; preds = %0
%69 = load i32, i32* @errno
%70 = call i8* @strerror(i32 %69)
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i32 %69, i8* %70)
br label %72
72: ; preds = %65, %68
ret i32 %7
}