#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_in {
  int /*<<< orphan*/ sin_addr;
};
struct ifaddrs {
  scalar_t__ ifa_netmask;
  TYPE_1__ *ifa_addr;
  struct ifaddrs *ifa_next;
};
struct TYPE_2__ {
  scalar_t__ sa_family;
};

/* Variables and functions */
scalar_t__ AF_INET;
int NI_MAXHOST;
int /*<<< orphan*/ NI_NUMERICHOST;
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ freeifaddrs(struct ifaddrs *);
char *gai_strerror(int);
int /*<<< orphan*/ getifaddrs(struct ifaddrs **);
int getnameinfo(TYPE_1__ *, int, char *, int, int /*<<< orphan*/ *,
                int /*<<< orphan*/, int /*<<< orphan*/);
char *inet_ntoa(int /*<<< orphan*/);
unsigned int ipUtils_ipToUnsignedInt(char *);
int ipUtils_netmaskToPrefix(char *);
unsigned int ipUtils_prefixToBitmask(unsigned int);
int /*<<< orphan*/ printf(char *, char *);
char *strndup(char const *, int);
char *strtok_r(char *, char *, char **);
scalar_t__ strtoul(char *, int /*<<< orphan*/ *, int);
char *ipUtils_findIpBySubnet(const char *ipWithPrefix) {
  char *ip = NULL;
  char *input = strndup(ipWithPrefix, 19);
  char *savePtr;
  char *inputIp = strtok_r(input, "/", &savePtr);
  char *inputPrefixStr = strtok_r(NULL, "\0", &savePtr);
  unsigned int inputPrefix = (unsigned int)strtoul(inputPrefixStr, NULL, 10);
  unsigned int ipAsUint = ipUtils_ipToUnsignedInt(inputIp);
  unsigned int bitmask = ipUtils_prefixToBitmask(inputPrefix);
  unsigned int ipRangeStart = ipAsUint & bitmask;
  unsigned int ipRangeStop = ipAsUint | ~bitmask;
  struct ifaddrs *ifap, *ifa;
  getifaddrs(&ifap);
  for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
    if (ifa->ifa_addr == NULL)
      continue;
    if (ifa->ifa_addr->sa_family != AF_INET)
      continue;
    char if_addr[NI_MAXHOST];
    int rv = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), if_addr,
                         NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
    if (rv != 0) {
      printf("getnameinfo() failed: %s\n", gai_strerror(rv));
      continue;
    }
    struct sockaddr_in *sa = (struct sockaddr_in *)ifa->ifa_netmask;
    char *if_netmask = inet_ntoa(sa->sin_addr);
    unsigned int ifIpAsUint = ipUtils_ipToUnsignedInt(if_addr);
    int ifPrefix = ipUtils_netmaskToPrefix(if_netmask);
    if (ifPrefix == -1) {
      break;
    }
    if (ifIpAsUint >= ipRangeStart && ifIpAsUint <= ipRangeStop &&
        inputPrefix >= ifPrefix) {
      ip = strndup(if_addr, 1024);
      break;
    }
  }
  freeifaddrs(ifap);
  free(input);
  return ip;
}


x86 assembly (clang, -O0):
<ipUtils_findIpBySubnet>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x13,%esi
call   10b0 <strndup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdfc(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   10a0 <strtok_r@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe00(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   10a0 <strtok_r@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   10f0 <strtoul@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <ipUtils_ipToUnsignedInt@plt>
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%edi
call   1050 <ipUtils_prefixToBitmask@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
and    -0x3c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x3c(%rbp),%ecx
xor    $0xffffffff,%ecx
or     %ecx,%eax
mov    %eax,-0x44(%rbp)
lea    -0x50(%rbp),%rdi
call   10d0 <getifaddrs@plt>
mov    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     1445 <ipUtils_findIpBySubnet+0x275>
mov    -0x58(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    129c <ipUtils_findIpBySubnet+0xcc>
jmp    1434 <ipUtils_findIpBySubnet+0x264>
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    0x2d3a(%rip),%rcx
cmp    (%rcx),%rax
je     12bc <ipUtils_findIpBySubnet+0xec>
jmp    1434 <ipUtils_findIpBySubnet+0x264>
mov    0x2d0d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x90(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x68(%rbp)
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2cd6(%rip),%rax
mov    (%rax),%ecx
mov    0x2cd5(%rip),%rax
mov    (%rax),%eax
mov    $0x4,%esi
xor    %r8d,%r8d
xor    %r9d,%r9d
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1090 <getnameinfo@plt>
add    $0x10,%rsp
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
je     1350 <ipUtils_findIpBySubnet+0x180>
mov    -0x6c(%rbp),%edi
call   1070 <gai_strerror@plt>
mov    %rax,%rsi
lea    0xcc3(%rip),%rdi
call   1060 <printf@plt>
movl   $0x4,-0x70(%rbp)
jmp    13f9 <ipUtils_findIpBySubnet+0x229>
mov    -0x58(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
mov    (%rax),%edi
call   1040 <inet_ntoa@plt>
mov    -0x90(%rbp),%rdi
mov    %rax,-0x80(%rbp)
call   1080 <ipUtils_ipToUnsignedInt@plt>
mov    %eax,-0x84(%rbp)
mov    -0x80(%rbp),%rdi
call   10c0 <ipUtils_netmaskToPrefix@plt>
mov    %eax,-0x88(%rbp)
cmpl   $0xffffffff,-0x88(%rbp)
jne    13a4 <ipUtils_findIpBySubnet+0x1d4>
movl   $0x2,-0x70(%rbp)
jmp    13f9 <ipUtils_findIpBySubnet+0x229>
mov    -0x84(%rbp),%eax
cmp    -0x40(%rbp),%eax
jb     13f2 <ipUtils_findIpBySubnet+0x222>
mov    -0x84(%rbp),%eax
cmp    -0x44(%rbp),%eax
ja     13f2 <ipUtils_findIpBySubnet+0x222>
mov    -0x34(%rbp),%eax
cmp    -0x88(%rbp),%eax
jb     13f2 <ipUtils_findIpBySubnet+0x222>
mov    -0x90(%rbp),%rdi
mov    $0x400,%esi
call   10b0 <strndup@plt>
mov    %rax,-0x10(%rbp)
movl   $0x2,-0x70(%rbp)
jmp    13f9 <ipUtils_findIpBySubnet+0x229>
movl   $0x0,-0x70(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,%rsp
mov    -0x70(%rbp),%eax
mov    %eax,-0x94(%rbp)
test   %eax,%eax
je     142f <ipUtils_findIpBySubnet+0x25f>
jmp    1416 <ipUtils_findIpBySubnet+0x246>
mov    -0x94(%rbp),%eax
sub    $0x2,%eax
je     1445 <ipUtils_findIpBySubnet+0x275>
jmp    142a <ipUtils_findIpBySubnet+0x25a>
jmp    1434 <ipUtils_findIpBySubnet+0x264>
jmp    1434 <ipUtils_findIpBySubnet+0x264>
mov    -0x58(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    127d <ipUtils_findIpBySubnet+0xad>
mov    -0x50(%rbp),%rdi
call   10e0 <freeifaddrs@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipUtils_findIpBySubnet>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    $0x13,%esi
call   10b0 <strndup@plt>
lea    0xe0e(%rip),%rsi
lea    -0x58(%rbp),%r14
mov    %rax,-0x50(%rbp)
mov    %rax,%rdi
mov    %r14,%rdx
call   10a0 <strtok_r@plt>
mov    %rax,%r15
lea    0xe0d(%rip),%rsi
xor    %r13d,%r13d
xor    %edi,%edi
mov    %r14,%rdx
call   10a0 <strtok_r@plt>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10f0 <strtoul@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1080 <ipUtils_ipToUnsignedInt@plt>
mov    %eax,%r14d
mov    %rbx,-0x48(%rbp)
mov    %ebx,%edi
call   1050 <ipUtils_prefixToBitmask@plt>
mov    %eax,%r15d
lea    -0x40(%rbp),%rdi
call   10d0 <getifaddrs@plt>
mov    -0x40(%rbp),%r12
test   %r12,%r12
je     136a <ipUtils_findIpBySubnet+0x19a>
mov    %r15d,%eax
and    %r14d,%eax
mov    %eax,-0x2c(%rbp)
not    %r15d
or     %r14d,%r15d
xor    %r13d,%r13d
mov    0x2d72(%rip),%rcx
jmp    12a7 <ipUtils_findIpBySubnet+0xd7>
mov    %eax,%edi
call   1070 <gai_strerror@plt>
lea    0xd7c(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
mov    -0x38(%rbp),%rsp
mov    0x2d4f(%rip),%rcx
mov    0x10(%r12),%r12
test   %r12,%r12
je     136a <ipUtils_findIpBySubnet+0x19a>
mov    0x8(%r12),%rax
test   %rax,%rax
je     1299 <ipUtils_findIpBySubnet+0xc9>
mov    (%rax),%rax
cmp    (%rcx),%rax
jne    1299 <ipUtils_findIpBySubnet+0xc9>
mov    %rsp,-0x38(%rbp)
mov    0x2d0c(%rip),%rcx
mov    (%rcx),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    0x8(%r12),%rdi
mov    (%rcx),%ecx
mov    0x2cf3(%rip),%rax
mov    (%rax),%eax
sub    $0x8,%rsp
mov    $0x4,%esi
mov    %r14,%rdx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   %rax
call   1090 <getnameinfo@plt>
add    $0x10,%rsp
test   %eax,%eax
jne    1278 <ipUtils_findIpBySubnet+0xa8>
mov    (%r12),%rax
mov    (%rax),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%r13
mov    %r14,%rdi
call   1080 <ipUtils_ipToUnsignedInt@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   10c0 <ipUtils_netmaskToPrefix@plt>
cmp    $0xffffffff,%eax
je     1363 <ipUtils_findIpBySubnet+0x193>
cmp    -0x2c(%rbp),%ebx
mov    $0x0,%r13d
jb     128e <ipUtils_findIpBySubnet+0xbe>
cmp    %r15d,%ebx
ja     128e <ipUtils_findIpBySubnet+0xbe>
cmp    -0x48(%rbp),%eax
ja     128e <ipUtils_findIpBySubnet+0xbe>
mov    %r14,%rdi
mov    $0x400,%esi
call   10b0 <strndup@plt>
mov    %rax,%r13
jmp    1366 <ipUtils_findIpBySubnet+0x196>
xor    %r13d,%r13d
mov    -0x38(%rbp),%rsp
mov    -0x40(%rbp),%rdi
call   10e0 <freeifaddrs@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    %r13,%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ifaddrs = type { i64, %struct.TYPE_2__*, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i64 }
%struct.sockaddr_in = type { i32 }
@.str = [2 x i8] c"/\00"
@.str.1 = [2 x i8] zeroinitializer
@AF_INET = global i64 0
@NI_MAXHOST = global i32 0
@NI_NUMERICHOST = global i32 0
@.str.2 = [26 x i8] c"getnameinfo() failed: %s\0A\00"
define i8* @ipUtils_findIpBySubnet(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.ifaddrs*
%14 = alloca %struct.ifaddrs*
%15 = alloca i8*
%16 = alloca i64
%17 = alloca i32
%18 = alloca i32
%19 = alloca %struct.sockaddr_in*
%20 = alloca i8*
%21 = alloca i32
%22 = alloca i32
store i8* %0, i8** %2
store i8* null, i8** %3
%23 = load i8*, i8** %2
%24 = call i8* @strndup(i8* %23, i32 19)
store i8* %24, i8** %4
%25 = load i8*, i8** %4
%26 = call i8* @strtok_r(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %5)
store i8* %26, i8** %6
%27 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %5)
store i8* %27, i8** %7
%28 = load i8*, i8** %7
%29 = call i64 @strtoul(i8* %28, i32* null, i32 10)
%30 = trunc i64 %29 to i32
store i32 %30, i32* %8
%31 = load i8*, i8** %6
%32 = call i32 @ipUtils_ipToUnsignedInt(i8* %31)
store i32 %32, i32* %9
%33 = load i32, i32* %8
%34 = call i32 @ipUtils_prefixToBitmask(i32 %33)
store i32 %34, i32* %10
%35 = load i32, i32* %9
%36 = load i32, i32* %10
%37 = and i32 %35, %36
store i32 %37, i32* %11
%38 = load i32, i32* %9
%39 = load i32, i32* %10
%40 = xor i32 %39, -1
%41 = or i32 %38, %40
store i32 %41, i32* %12
%42 = call i32 @getifaddrs(%struct.ifaddrs** %13)
%43 = load %struct.ifaddrs*, %struct.ifaddrs** %13
store %struct.ifaddrs* %43, %struct.ifaddrs** %14
br label %44
44: ; preds = %113, %1
%45 = load %struct.ifaddrs*, %struct.ifaddrs** %14
%46 = icmp ne %struct.ifaddrs* %45, null
br i1 %46, label %47, label %117
47: ; preds = %44
%48 = load %struct.ifaddrs*, %struct.ifaddrs** %14
%49 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %48, i32 0, i32 1
%50 = load %struct.TYPE_2__*, %struct.TYPE_2__** %49
%51 = icmp eq %struct.TYPE_2__* %50, null
br i1 %51, label %52, label %53
52: ; preds = %47
br label %113
53: ; preds = %47
%54 = load %struct.ifaddrs*, %struct.ifaddrs** %14
%55 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %54, i32 0, i32 1
%56 = load %struct.TYPE_2__*, %struct.TYPE_2__** %55
%57 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %56, i32 0, i32 0
%58 = load i64, i64* %57
%59 = load i64, i64* @AF_INET
%60 = icmp ne i64 %58, %59
br i1 %60, label %61, label %62
61: ; preds = %53
br label %113
62: ; preds = %53
%63 = load i32, i32* @NI_MAXHOST
%64 = zext i32 %63 to i64
%65 = call i8* @llvm.stacksave()
store i8* %65, i8** %15
%66 = alloca i8, i64 %64
store i64 %64, i64* %16
%67 = load %struct.ifaddrs*, %struct.ifaddrs** %14
%68 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %67, i32 0, i32 1
%69 = load %struct.TYPE_2__*, %struct.TYPE_2__** %68
%70 = load i32, i32* @NI_MAXHOST
%71 = load i32, i32* @NI_NUMERICHOST
%72 = call i32 @getnameinfo(%struct.TYPE_2__* %69, i32 4, i8* %66, i32 %70, i32* null, i32 0, i32 %71)
store i32 %72, i32* %17
%73 = load i32, i32* %17
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %79
75: ; preds = %62
%76 = load i32, i32* %17
%77 = call i8* @gai_strerror(i32 %76)
%78 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %77)
store i32 4, i32* %18
br label %109
79: ; preds = %62
%80 = load %struct.ifaddrs*, %struct.ifaddrs** %14
%81 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %80, i32 0, i32 0
%82 = load i64, i64* %81
%83 = inttoptr i64 %82 to %struct.sockaddr_in*
store %struct.sockaddr_in* %83, %struct.sockaddr_in** %19
%84 = load %struct.sockaddr_in*, %struct.sockaddr_in** %19
%85 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %84, i32 0, i32 0
%86 = load i32, i32* %85
%87 = call i8* @inet_ntoa(i32 %86)
store i8* %87, i8** %20
%88 = call i32 @ipUtils_ipToUnsignedInt(i8* %66)
store i32 %88, i32* %21
%89 = load i8*, i8** %20
%90 = call i32 @ipUtils_netmaskToPrefix(i8* %89)
store i32 %90, i32* %22
%91 = load i32, i32* %22
%92 = icmp eq i32 %91, -1
br i1 %92, label %93, label %94
93: ; preds = %79
store i32 2, i32* %18
br label %109
94: ; preds = %79
%95 = load i32, i32* %21
%96 = load i32, i32* %11
%97 = icmp uge i32 %95, %96
br i1 %97, label %98, label %108
98: ; preds = %94
%99 = load i32, i32* %21
%100 = load i32, i32* %12
%101 = icmp ule i32 %99, %100
br i1 %101, label %102, label %108
102: ; preds = %98
%103 = load i32, i32* %8
%104 = load i32, i32* %22
%105 = icmp uge i32 %103, %104
br i1 %105, label %106, label %108
106: ; preds = %102
%107 = call i8* @strndup(i8* %66, i32 1024)
store i8* %107, i8** %3
store i32 2, i32* %18
br label %109
108: ; preds = %102, %98, %94
store i32 0, i32* %18
br label %109
109: ; preds = %108, %106, %93, %75
%110 = load i8*, i8** %15
%111 = load i32, i32* %18
switch i32 %111, label %123 [
i32 0, label %112
i32 4, label %113
i32 2, label %117
]
112: ; preds = %109
br label %113
113: ; preds = %112, %109, %61, %52
%114 = load %struct.ifaddrs*, %struct.ifaddrs** %14
%115 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %114, i32 0, i32 2
%116 = load %struct.ifaddrs*, %struct.ifaddrs** %115
store %struct.ifaddrs* %116, %struct.ifaddrs** %14
br label %44
117: ; preds = %109, %44
%118 = load %struct.ifaddrs*, %struct.ifaddrs** %13
%119 = call i32 @freeifaddrs(%struct.ifaddrs* %118)
%120 = load i8*, i8** %4
%121 = call i32 @free(i8* %120)
%122 = load i8*, i8** %3
ret i8* %122
123: ; preds = %109
unreachable
}

LLVM IR (-O2):
%struct.ifaddrs = type { i64, %struct.TYPE_2__*, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i64 }
%struct.sockaddr_in = type { i32 }
@.str = [2 x i8] c"/\00"
@.str.1 = [2 x i8] zeroinitializer
@AF_INET = global i64 0
@NI_MAXHOST = global i32 0
@NI_NUMERICHOST = global i32 0
@.str.2 = [26 x i8] c"getnameinfo() failed: %s\0A\00"
define noalias i8* @ipUtils_findIpBySubnet(i8* nocapture %0) {
%2 = alloca i8*
%3 = alloca %struct.ifaddrs*
%4 = tail call i8* @strndup(i8* %0, i32 19)
%5 = bitcast i8** %2 to i8*
%6 = call i8* @strtok_r(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %2)
%7 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %2)
%8 = call i64 @strtoul(i8* nocapture %7, i32* null, i32 10)
%9 = trunc i64 %8 to i32
%10 = call i32 @ipUtils_ipToUnsignedInt(i8* %6)
%11 = call i32 @ipUtils_prefixToBitmask(i32 %9)
%12 = and i32 %11, %10
%13 = xor i32 %11, -1
%14 = or i32 %10, %13
%15 = bitcast %struct.ifaddrs** %3 to i8*
%16 = call i32 @getifaddrs(%struct.ifaddrs** %3)
%17 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%18 = icmp eq %struct.ifaddrs* %17, null
br i1 %18, label %67, label %19
19: ; preds = %1, %63
%20 = phi %struct.ifaddrs* [ %65, %63 ], [ %17, %1 ]
%21 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %20, i64 0, i32 1
%22 = load %struct.TYPE_2__*, %struct.TYPE_2__** %21
%23 = icmp eq %struct.TYPE_2__* %22, null
br i1 %23, label %63, label %24
24: ; preds = %19
%25 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %22, i64 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 %63
29: ; preds = %24
%30 = load i32, i32* @NI_MAXHOST
%31 = zext i32 %30 to i64
%32 = call i8* @llvm.stacksave()
%33 = alloca i8, i64 %31
%34 = load %struct.TYPE_2__*, %struct.TYPE_2__** %21
%35 = load i32, i32* @NI_MAXHOST
%36 = load i32, i32* @NI_NUMERICHOST
%37 = call i32 @getnameinfo(%struct.TYPE_2__* %34, i32 4, i8* %33, i32 %35, i32* null, i32 0, i32 %36)
%38 = icmp eq i32 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %29
%40 = call i8* @gai_strerror(i32 %37)
%41 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %40)
br label %62
42: ; preds = %29
%43 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %20, i64 0, i32 0
%44 = load i64, i64* %43
%45 = inttoptr i64 %44 to %struct.sockaddr_in*
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %45, i64 0, i32 0
%47 = load i32, i32* %46
%48 = call i8* @inet_ntoa(i32 %47)
%49 = call i32 @ipUtils_ipToUnsignedInt(i8* %33)
%50 = call i32 @ipUtils_netmaskToPrefix(i8* %48)
%51 = icmp eq i32 %50, -1
br i1 %51, label %60, label %52
52: ; preds = %42
%53 = icmp ult i32 %49, %12
%54 = icmp ugt i32 %49, %14
%55 = select i1 %53, i1 true, i1 %54
%56 = icmp ugt i32 %50, %9
%57 = select i1 %55, i1 true, i1 %56
br i1 %57, label %62, label %58
58: ; preds = %52
%59 = call i8* @strndup(i8* %33, i32 1024)
br label %60
60: ; preds = %42, %58
%61 = phi i8* [ %59, %58 ], [ null, %42 ]
br label %67
62: ; preds = %52, %39
br label %63
63: ; preds = %62, %24, %19
%64 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %20, i64 0, i32 2
%65 = load %struct.ifaddrs*, %struct.ifaddrs** %64
%66 = icmp eq %struct.ifaddrs* %65, null
br i1 %66, label %67, label %19
67: ; preds = %63, %1, %60
%68 = phi i8* [ %61, %60 ], [ null, %1 ], [ null, %63 ]
%69 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%70 = call i32 @freeifaddrs(%struct.ifaddrs* %69)
%71 = call i32 @free(i8* %4)
ret i8* %68
}