#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 dummy;
};
struct sockaddr_in {
  int dummy;
};
struct ifaddrs {
  char *ifa_name;
  TYPE_1__ *ifa_addr;
  struct ifaddrs *ifa_next;
};
struct TYPE_2__ {
  int sa_family;
};

/* Variables and functions */
int AF_INET;
int ENOENT;
int NI_MAXHOST;
int /*<<< orphan*/ NI_NUMERICHOST;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
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*/);
unsigned int if_nametoindex(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ strncmp(char *, char const *, int /*<<< orphan*/);
int select_interface(int npref, const char **pref, char *ifname, char *ip,
                     unsigned int *ifindex) {
  struct ifaddrs *ifaddr, *ifa;
  int family, s, n, i;
  char host[NI_MAXHOST];
  const char *p;
  if (getifaddrs(&ifaddr) == -1) {
    perror("getifaddrs");
    return -ENOENT;
  }
  for (i = 0; i < npref; i++) {
    p = pref[i];
    for (ifa = ifaddr, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) {
      if (ifa->ifa_addr == NULL)
        continue;
      family = ifa->ifa_addr->sa_family;
      if (family != AF_INET)
        continue;
      s = getnameinfo(ifa->ifa_addr,
                      (family == AF_INET) ? sizeof(struct sockaddr_in)
                                          : sizeof(struct sockaddr_in6),
                      host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
      if (s != 0) {
        fprintf(stderr, "getnameinfo() failed: %s\n", gai_strerror(s));
        goto fail;
      }
      if (!strncmp(ifa->ifa_name, p, strlen(p))) {
        unsigned int ii = if_nametoindex(ifa->ifa_name);
        if (ii) {
          if (ifindex)
            *ifindex = ii;
        } else {
          fprintf(stderr, "if_nametoindex() failed: %s\n", strerror(errno));
        }
        strcpy(ifname, ifa->ifa_name);
        strcpy(ip, host);
        freeifaddrs(ifaddr);
        return 0;
      }
    }
  }
fail:
  freeifaddrs(ifaddr);
  return -ENOENT;
}


x86 assembly (clang, -O0):
<select_interface>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    0x2deb(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
lea    -0x30(%rbp),%rdi
call   10a0 <getifaddrs@plt>
cmp    $0xffffffff,%eax
jne    1232 <select_interface+0x82>
lea    0xded(%rip),%rdi
call   10c0 <perror@plt>
xor    %eax,%eax
mov    0x2d8f(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x64(%rbp)
jmp    1458 <select_interface+0x2a8>
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1435 <select_interface+0x285>
mov    -0x10(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x60(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x44(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1422 <select_interface+0x272>
mov    -0x38(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    1283 <select_interface+0xd3>
jmp    1408 <select_interface+0x258>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    0x2d4e(%rip),%rcx
cmp    (%rcx),%eax
je     12a7 <select_interface+0xf7>
jmp    1408 <select_interface+0x258>
mov    -0x70(%rbp),%rdx
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x3c(%rbp),%ecx
mov    0x2d2b(%rip),%rax
mov    (%rax),%esi
mov    $0x4,%eax
cmp    %esi,%ecx
cmove  %rax,%rax
mov    %eax,%esi
mov    0x2ced(%rip),%rax
mov    (%rax),%ecx
mov    0x2cf4(%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,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
je     132c <select_interface+0x17c>
mov    0x2cd0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x40(%rbp),%edi
call   1060 <gai_strerror@plt>
mov    -0x74(%rbp),%edi
mov    %rax,%rdx
lea    0xce9(%rip),%rsi
call   1080 <fprintf@plt>
jmp    143a <select_interface+0x28a>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x88(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x60(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x88(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1403 <select_interface+0x253>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
call   1090 <if_nametoindex@plt>
mov    %eax,-0x68(%rbp)
cmpl   $0x0,-0x68(%rbp)
je     1398 <select_interface+0x1e8>
cmpq   $0x0,-0x28(%rbp)
je     1393 <select_interface+0x1e3>
mov    -0x68(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
jmp    13ca <select_interface+0x21a>
mov    0x2c39(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    0x2c1a(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x8c(%rbp),%edi
mov    %rax,%rdx
lea    0xc60(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    (%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x70(%rbp),%rsi
mov    -0x20(%rbp),%rdi
call   1040 <strcpy@plt>
mov    -0x30(%rbp),%rdi
call   10b0 <freeifaddrs@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x64(%rbp)
jmp    1458 <select_interface+0x2a8>
jmp    1408 <select_interface+0x258>
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1264 <select_interface+0xb4>
jmp    1427 <select_interface+0x277>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1239 <select_interface+0x89>
jmp    143a <select_interface+0x28a>
mov    -0x30(%rbp),%rdi
call   10b0 <freeifaddrs@plt>
xor    %eax,%eax
mov    0x2b64(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x64(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<select_interface>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r8,-0x58(%rbp)
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,-0x68(%rbp)
mov    %edi,%r14d
mov    %rsp,%rbx
mov    0x2de4(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
lea    -0x38(%rbp),%rdi
call   10a0 <getifaddrs@plt>
cmp    $0xffffffff,%eax
je     1391 <select_interface+0x1e1>
mov    %r12,-0x40(%rbp)
mov    %r15,-0x48(%rbp)
mov    %rbx,-0x30(%rbp)
test   %r14d,%r14d
jle    130f <select_interface+0x15f>
mov    %r14d,%eax
mov    %rax,-0x60(%rbp)
xor    %r12d,%r12d
mov    0x2dbd(%rip),%rbx
jmp    123e <select_interface+0x8e>
nopl   (%rax)
add    $0x1,%r12
cmp    -0x60(%rbp),%r12
je     130f <select_interface+0x15f>
mov    -0x38(%rbp),%r13
test   %r13,%r13
je     1230 <select_interface+0x80>
mov    -0x68(%rbp),%rax
mov    (%rax,%r12,8),%r14
jmp    1269 <select_interface+0xb9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%r13),%r13
test   %r13,%r13
je     1230 <select_interface+0x80>
mov    0x8(%r13),%rdi
test   %rdi,%rdi
je     1260 <select_interface+0xb0>
mov    (%rdi),%eax
cmp    (%rbx),%eax
jne    1260 <select_interface+0xb0>
mov    0x2d41(%rip),%rax
mov    (%rax),%ecx
mov    0x2d48(%rip),%rax
mov    (%rax),%eax
sub    $0x8,%rsp
mov    $0x4,%esi
mov    -0x50(%rbp),%rdx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   %rax
call   1070 <getnameinfo@plt>
add    $0x10,%rsp
test   %eax,%eax
jne    12ee <select_interface+0x13e>
mov    0x0(%r13),%r15
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    1260 <select_interface+0xb0>
mov    0x0(%r13),%rdi
call   1090 <if_nametoindex@plt>
test   %eax,%eax
je     1329 <select_interface+0x179>
mov    -0x58(%rbp),%rcx
test   %rcx,%rcx
mov    -0x30(%rbp),%rbx
mov    -0x48(%rbp),%r14
mov    -0x40(%rbp),%rdi
je     135f <select_interface+0x1af>
mov    %eax,(%rcx)
jmp    135f <select_interface+0x1af>
mov    0x2ce3(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1060 <gai_strerror@plt>
lea    0xd06(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1080 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   10b0 <freeifaddrs@plt>
mov    0x2c91(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
mov    -0x30(%rbp),%rbx
jmp    137f <select_interface+0x1cf>
mov    0x2ca8(%rip),%rax
mov    (%rax),%r14d
mov    0x2c8e(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xcdd(%rip),%rsi
mov    %r14d,%edi
mov    %rax,%rdx
call   1080 <fprintf@plt>
mov    -0x30(%rbp),%rbx
mov    -0x48(%rbp),%r14
mov    -0x40(%rbp),%rdi
mov    0x0(%r13),%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
mov    -0x50(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x38(%rbp),%rdi
call   10b0 <freeifaddrs@plt>
xor    %eax,%eax
mov    %rbx,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc68(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2c0c(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
jmp    137f <select_interface+0x1cf>

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

LLVM IR (-O2):
%struct.ifaddrs = type { i8*, %struct.TYPE_2__*, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i32 }
@NI_MAXHOST = global i32 0
@.str = [11 x i8] c"getifaddrs\00"
@ENOENT = global i32 0
@AF_INET = global i32 0
@NI_NUMERICHOST = global i32 0
@stderr = global i32 0
@.str.1 = [26 x i8] c"getnameinfo() failed: %s\0A\00"
@.str.2 = [29 x i8] c"if_nametoindex() failed: %s\0A\00"
@errno = global i32 0
define i32 @select_interface(i32 %0, i8** nocapture %1, i8* %2, i8* %3, i32* writeonly %4) {
%6 = alloca %struct.ifaddrs*
%7 = bitcast %struct.ifaddrs** %6 to i8*
%8 = load i32, i32* @NI_MAXHOST
%9 = zext i32 %8 to i64
%10 = tail call i8* @llvm.stacksave()
%11 = alloca i8, i64 %9
%12 = call i32 @getifaddrs(%struct.ifaddrs** %6)
%13 = icmp eq i32 %12, -1
br i1 %13, label %18, label %14
14: ; preds = %5
%15 = icmp sgt i32 %0, 0
br i1 %15, label %16, label %79
16: ; preds = %14
%17 = zext i32 %0 to i64
br label %22
18: ; preds = %5
%19 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @ENOENT
%21 = sub nsw i32 0, %20
br label %84
22: ; preds = %16, %76
%23 = phi i64 [ 0, %16 ], [ %77, %76 ]
%24 = getelementptr inbounds i8*, i8** %1, i64 %23
%25 = load i8*, i8** %24
%26 = load %struct.ifaddrs*, %struct.ifaddrs** %6
%27 = icmp eq %struct.ifaddrs* %26, null
br i1 %27, label %76, label %28
28: ; preds = %22, %72
%29 = phi %struct.ifaddrs* [ %74, %72 ], [ %26, %22 ]
%30 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %29, i64 0, i32 1
%31 = load %struct.TYPE_2__*, %struct.TYPE_2__** %30
%32 = icmp eq %struct.TYPE_2__* %31, null
br i1 %32, label %72, label %33
33: ; preds = %28
%34 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %31, i64 0, i32 0
%35 = load i32, i32* %34
%36 = load i32, i32* @AF_INET
%37 = icmp eq i32 %35, %36
br i1 %37, label %38, label %72
38: ; preds = %33
%39 = load i32, i32* @NI_MAXHOST
%40 = load i32, i32* @NI_NUMERICHOST
%41 = call i32 @getnameinfo(%struct.TYPE_2__* %31, i32 4, i8* %11, i32 %39, i32* null, i32 0, i32 %40)
%42 = icmp eq i32 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %38
%44 = load i32, i32* @stderr
%45 = call i8* @gai_strerror(i32 %41)
%46 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %45)
br label %79
47: ; preds = %38
%48 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %29, i64 0, i32 0
%49 = load i8*, i8** %48
%50 = call i32 @strlen(i8* %25)
%51 = call i32 @strncmp(i8* %49, i8* %25, i32 %50)
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %72
53: ; preds = %47
%54 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %29, i64 0, i32 0
%55 = load i8*, i8** %54
%56 = call i32 @if_nametoindex(i8* %55)
%57 = icmp eq i32 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %53
%59 = icmp eq i32* %4, null
br i1 %59, label %66, label %60
60: ; preds = %58
store i32 %56, i32* %4
br label %66
61: ; preds = %53
%62 = load i32, i32* @stderr
%63 = load i32, i32* @errno
%64 = call i8* @strerror(i32 %63)
%65 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %64)
br label %66
66: ; preds = %58, %60, %61
%67 = load i8*, i8** %54
%68 = call i32 @strcpy(i8* %2, i8* %67)
%69 = call i32 @strcpy(i8* %3, i8* %11)
%70 = load %struct.ifaddrs*, %struct.ifaddrs** %6
%71 = call i32 @freeifaddrs(%struct.ifaddrs* %70)
br label %84
72: ; preds = %47, %33, %28
%73 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %29, i64 0, i32 2
%74 = load %struct.ifaddrs*, %struct.ifaddrs** %73
%75 = icmp eq %struct.ifaddrs* %74, null
br i1 %75, label %76, label %28
76: ; preds = %72, %22
%77 = add nuw nsw i64 %23, 1
%78 = icmp eq i64 %77, %17
br i1 %78, label %79, label %22
79: ; preds = %76, %14, %43
%80 = load %struct.ifaddrs*, %struct.ifaddrs** %6
%81 = call i32 @freeifaddrs(%struct.ifaddrs* %80)
%82 = load i32, i32* @ENOENT
%83 = sub nsw i32 0, %82
br label %84
84: ; preds = %79, %66, %18
%85 = phi i32 [ %21, %18 ], [ %83, %79 ], [ 0, %66 ]
ret i32 %85
}