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

/* Variables and functions */
scalar_t__ AF_INET;
scalar_t__ AF_PACKET;
int IFF_BROADCAST;
int IFF_LOOPBACK;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ freeifaddrs(struct ifaddrs *);
int getifaddrs(struct ifaddrs **);
char *ip_to_string(TYPE_1__ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_iff_flags(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
void print_iff_list() {
  struct ifaddrs *ifaddrs = NULL;
  int res = getifaddrs(&ifaddrs);
  if (res != 0) {
    fprintf(stderr, "Error: could not get interface list\n");
    perror("getifaddrs()");
    exit(1);
  }
  printf(" [*] Interface list:\n");
  for (struct ifaddrs *ifaddr = ifaddrs; ifaddr != NULL;
       ifaddr = ifaddr->ifa_next) {
    printf(" %s (%s", ifaddr->ifa_name,
           (ifaddr->ifa_addr == NULL ? "no addr"
                                     : ip_to_string(ifaddr->ifa_addr)));
    print_iff_flags(ifaddr->ifa_flags);
    printf(")\n");
  }
  int loopback_found = 0;
  struct ifaddrs *lo_ipv4 = NULL;
  struct ifaddrs *eth0_ipv4 = NULL, *eth0_packet = NULL;
  for (struct ifaddrs *ifaddr = ifaddrs; ifaddr != NULL;
       ifaddr = ifaddr->ifa_next) {
    if ((ifaddr->ifa_flags & IFF_LOOPBACK) != 0) {
      loopback_found = 1;
      if (ifaddr->ifa_addr->sa_family == AF_INET)
        lo_ipv4 = ifaddr;
    } else if ((ifaddr->ifa_flags & IFF_BROADCAST) != 0) {
      if (ifaddr->ifa_addr->sa_family == AF_INET)
        eth0_ipv4 = ifaddr;
      else if (ifaddr->ifa_addr->sa_family == AF_PACKET)
        eth0_packet = ifaddr;
    }
  }
  if (!loopback_found) {
    fprintf(stderr, "Error: no loopback interface\n");
    exit(2);
  } else if (lo_ipv4 == NULL) {
    fprintf(stderr, "Error: no address on loopback\n");
    exit(3);
  }
  if (eth0_packet == NULL) {
    fprintf(stderr, "Error: no eth0 interface\n");
    exit(4);
  } else if (eth0_ipv4 == NULL) {
    fprintf(stderr, "Error: no address on eth0\n");
    exit(5);
  }
  freeifaddrs(ifaddrs);
}


x86 assembly (clang, -O0):
<print_iff_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movq   $0x0,-0x8(%rbp)
lea    -0x8(%rbp),%rdi
call   1050 <getifaddrs@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11d1 <print_iff_list+0x51>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe63(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     126e <print_iff_list+0xee>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x10(%rax)
jne    121c <print_iff_list+0x9c>
lea    0xe3d(%rip),%rax
mov    %rax,-0x50(%rbp)
jmp    122d <print_iff_list+0xad>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <ip_to_string@plt>
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rsi
mov    -0x50(%rbp),%rdx
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
call   1060 <print_iff_flags@plt>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    11e7 <print_iff_list+0x67>
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     1371 <print_iff_list+0x1f1>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x2d4a(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12e8 <print_iff_list+0x168>
movl   $0x1,-0x1c(%rbp)
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%rax
mov    0x2d0e(%rip),%rcx
cmp    (%rcx),%rax
jne    12e3 <print_iff_list+0x163>
mov    -0x40(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    135b <print_iff_list+0x1db>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x2cca(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1356 <print_iff_list+0x1d6>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%rax
mov    0x2ccd(%rip),%rcx
cmp    (%rcx),%rax
jne    1329 <print_iff_list+0x1a9>
mov    -0x40(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1351 <print_iff_list+0x1d1>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%rax
mov    0x2c95(%rip),%rcx
cmp    (%rcx),%rax
jne    134c <print_iff_list+0x1cc>
mov    -0x40(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1351 <print_iff_list+0x1d1>
jmp    1356 <print_iff_list+0x1d6>
jmp    135b <print_iff_list+0x1db>
jmp    1360 <print_iff_list+0x1e0>
mov    -0x40(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x40(%rbp)
jmp    1295 <print_iff_list+0x115>
cmpl   $0x0,-0x1c(%rbp)
jne    139a <print_iff_list+0x21a>
mov    0x2c46(%rip),%rax
mov    (%rax),%edi
lea    0xcd0(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x2,%edi
call   10a0 <exit@plt>
cmpq   $0x0,-0x28(%rbp)
jne    13c4 <print_iff_list+0x244>
mov    0x2c1c(%rip),%rax
mov    (%rax),%edi
lea    0xcc4(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x3,%edi
call   10a0 <exit@plt>
jmp    13c9 <print_iff_list+0x249>
cmpq   $0x0,-0x38(%rbp)
jne    13f3 <print_iff_list+0x273>
mov    0x2bed(%rip),%rax
mov    (%rax),%edi
lea    0xcb4(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x4,%edi
call   10a0 <exit@plt>
cmpq   $0x0,-0x30(%rbp)
jne    141d <print_iff_list+0x29d>
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
lea    0xca4(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x5,%edi
call   10a0 <exit@plt>
jmp    1422 <print_iff_list+0x2a2>
mov    -0x8(%rbp),%rdi
call   1080 <freeifaddrs@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_iff_list>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movq   $0x0,(%rsp)
mov    %rsp,%rdi
call   1060 <getifaddrs@plt>
test   %eax,%eax
jne    130e <print_iff_list+0x17e>
lea    0xefa(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%rbx
test   %rbx,%rbx
je     12ef <print_iff_list+0x15f>
lea    0xe67(%rip),%r13
lea    0xe58(%rip),%r14
lea    0xe4f(%rip),%r15
jmp    1216 <print_iff_list+0x86>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%edi
call   1070 <print_iff_flags@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
je     122f <print_iff_list+0x9f>
mov    (%rbx),%r12
mov    0x10(%rbx),%rdi
mov    %r13,%rdx
test   %rdi,%rdi
je     11f0 <print_iff_list+0x60>
call   1080 <ip_to_string@plt>
mov    %rax,%rdx
jmp    11f0 <print_iff_list+0x60>
mov    (%rsp),%rdi
test   %rdi,%rdi
je     12ef <print_iff_list+0x15f>
mov    0x2db5(%rip),%rax
mov    (%rax),%ecx
mov    0x2d94(%rip),%rax
mov    (%rax),%rsi
mov    0x2d6a(%rip),%rax
mov    (%rax),%r11d
mov    0x2d70(%rip),%rax
mov    (%rax),%r8
xor    %r10d,%r10d
mov    %rdi,%rax
xor    %r9d,%r9d
xor    %edx,%edx
xor    %ebx,%ebx
jmp    1299 <print_iff_list+0x109>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x10(%rax),%rbx
cmp    %rsi,(%rbx)
cmove  %rax,%rdx
mov    $0x1,%ebx
mov    0x18(%rax),%rax
test   %rax,%rax
je     12c0 <print_iff_list+0x130>
mov    0x8(%rax),%ebp
test   %ebp,%ecx
jne    1280 <print_iff_list+0xf0>
test   %ebp,%r11d
je     1290 <print_iff_list+0x100>
mov    0x10(%rax),%rbp
mov    0x0(%rbp),%rbp
cmp    %rsi,%rbp
jne    12b7 <print_iff_list+0x127>
mov    %rax,%r9
jmp    1290 <print_iff_list+0x100>
cmp    %r8,%rbp
cmove  %rax,%r10
jmp    1290 <print_iff_list+0x100>
test   %ebx,%ebx
je     12ef <print_iff_list+0x15f>
test   %rdx,%rdx
je     1339 <print_iff_list+0x1a9>
test   %r10,%r10
je     1358 <print_iff_list+0x1c8>
test   %r9,%r9
je     1377 <print_iff_list+0x1e7>
call   1090 <freeifaddrs@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cd2(%rip),%rax
mov    (%rax),%edi
lea    0xd43(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>
mov    0x2cb3(%rip),%rax
mov    (%rax),%edi
lea    0xce2(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xcfb(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0x2c88(%rip),%rax
mov    (%rax),%edi
lea    0xd17(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x3,%edi
call   10b0 <exit@plt>
mov    0x2c69(%rip),%rax
mov    (%rax),%edi
lea    0xd17(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x4,%edi
call   10b0 <exit@plt>
mov    0x2c4a(%rip),%rax
mov    (%rax),%edi
lea    0xd12(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x5,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.ifaddrs = type { i8*, i32, %struct.TYPE_2__*, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i64 }
@stderr = global i32 0
@.str = [37 x i8] c"Error: could not get interface list\0A\00"
@.str.1 = [13 x i8] c"getifaddrs()\00"
@.str.2 = [22 x i8] c" [*] Interface list:\0A\00"
@.str.3 = [8 x i8] c" %s (%s\00"
@.str.4 = [8 x i8] c"no addr\00"
@.str.5 = [3 x i8] c")\0A\00"
@IFF_LOOPBACK = global i32 0
@AF_INET = global i64 0
@IFF_BROADCAST = global i32 0
@AF_PACKET = global i64 0
@.str.6 = [30 x i8] c"Error: no loopback interface\0A\00"
@.str.7 = [31 x i8] c"Error: no address on loopback\0A\00"
@.str.8 = [26 x i8] c"Error: no eth0 interface\0A\00"
@.str.9 = [27 x i8] c"Error: no address on eth0\0A\00"
define void @print_iff_list() {
%1 = alloca %struct.ifaddrs*
%2 = alloca i32
%3 = alloca %struct.ifaddrs*
%4 = alloca i32
%5 = alloca %struct.ifaddrs*
%6 = alloca %struct.ifaddrs*
%7 = alloca %struct.ifaddrs*
%8 = alloca %struct.ifaddrs*
store %struct.ifaddrs* null, %struct.ifaddrs** %1
%9 = call i32 @getifaddrs(%struct.ifaddrs** %1)
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%19 = load %struct.ifaddrs*, %struct.ifaddrs** %1
store %struct.ifaddrs* %19, %struct.ifaddrs** %3
br label %20
20: ; preds = %45, %17
%21 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%22 = icmp ne %struct.ifaddrs* %21, null
br i1 %22, label %23, label %49
23: ; preds = %20
%24 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%25 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %24, i32 0, i32 0
%26 = load i8*, i8** %25
%27 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%28 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %27, i32 0, i32 2
%29 = load %struct.TYPE_2__*, %struct.TYPE_2__** %28
%30 = icmp eq %struct.TYPE_2__* %29, null
br i1 %30, label %31, label %32
31: ; preds = %23
br label %37
32: ; preds = %23
%33 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%34 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %33, i32 0, i32 2
%35 = load %struct.TYPE_2__*, %struct.TYPE_2__** %34
%36 = call i8* @ip_to_string(%struct.TYPE_2__* %35)
br label %37
37: ; preds = %32, %31
%38 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), %31 ], [ %36, %32 ]
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %26, i8* %38)
%40 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%41 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %40, i32 0, i32 1
%42 = load i32, i32* %41
%43 = call i32 @print_iff_flags(i32 %42)
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %45
45: ; preds = %37
%46 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%47 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %46, i32 0, i32 3
%48 = load %struct.ifaddrs*, %struct.ifaddrs** %47
store %struct.ifaddrs* %48, %struct.ifaddrs** %3
br label %20
49: ; preds = %20
store i32 0, i32* %4
store %struct.ifaddrs* null, %struct.ifaddrs** %5
store %struct.ifaddrs* null, %struct.ifaddrs** %6
store %struct.ifaddrs* null, %struct.ifaddrs** %7
%50 = load %struct.ifaddrs*, %struct.ifaddrs** %1
store %struct.ifaddrs* %50, %struct.ifaddrs** %8
br label %51
51: ; preds = %103, %49
%52 = load %struct.ifaddrs*, %struct.ifaddrs** %8
%53 = icmp ne %struct.ifaddrs* %52, null
br i1 %53, label %54, label %107
54: ; preds = %51
%55 = load %struct.ifaddrs*, %struct.ifaddrs** %8
%56 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %55, i32 0, i32 1
%57 = load i32, i32* %56
%58 = load i32, i32* @IFF_LOOPBACK
%59 = and i32 %57, %58
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %72
61: ; preds = %54
store i32 1, i32* %4
%62 = load %struct.ifaddrs*, %struct.ifaddrs** %8
%63 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %62, i32 0, i32 2
%64 = load %struct.TYPE_2__*, %struct.TYPE_2__** %63
%65 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %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 %71
69: ; preds = %61
%70 = load %struct.ifaddrs*, %struct.ifaddrs** %8
store %struct.ifaddrs* %70, %struct.ifaddrs** %5
br label %71
71: ; preds = %69, %61
br label %102
72: ; preds = %54
%73 = load %struct.ifaddrs*, %struct.ifaddrs** %8
%74 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %73, i32 0, i32 1
%75 = load i32, i32* %74
%76 = load i32, i32* @IFF_BROADCAST
%77 = and i32 %75, %76
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %101
79: ; preds = %72
%80 = load %struct.ifaddrs*, %struct.ifaddrs** %8
%81 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %80, i32 0, i32 2
%82 = load %struct.TYPE_2__*, %struct.TYPE_2__** %81
%83 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %82, i32 0, i32 0
%84 = load i64, i64* %83
%85 = load i64, i64* @AF_INET
%86 = icmp eq i64 %84, %85
br i1 %86, label %87, label %89
87: ; preds = %79
%88 = load %struct.ifaddrs*, %struct.ifaddrs** %8
store %struct.ifaddrs* %88, %struct.ifaddrs** %6
br label %100
89: ; preds = %79
%90 = load %struct.ifaddrs*, %struct.ifaddrs** %8
%91 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %90, i32 0, i32 2
%92 = load %struct.TYPE_2__*, %struct.TYPE_2__** %91
%93 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %92, i32 0, i32 0
%94 = load i64, i64* %93
%95 = load i64, i64* @AF_PACKET
%96 = icmp eq i64 %94, %95
br i1 %96, label %97, label %99
97: ; preds = %89
%98 = load %struct.ifaddrs*, %struct.ifaddrs** %8
store %struct.ifaddrs* %98, %struct.ifaddrs** %7
br label %99
99: ; preds = %97, %89
br label %100
100: ; preds = %99, %87
br label %101
101: ; preds = %100, %72
br label %102
102: ; preds = %101, %71
br label %103
103: ; preds = %102
%104 = load %struct.ifaddrs*, %struct.ifaddrs** %8
%105 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %104, i32 0, i32 3
%106 = load %struct.ifaddrs*, %struct.ifaddrs** %105
store %struct.ifaddrs* %106, %struct.ifaddrs** %8
br label %51
107: ; preds = %51
%108 = load i32, i32* %4
%109 = icmp ne i32 %108, 0
br i1 %109, label %114, label %110
110: ; preds = %107
%111 = load i32, i32* @stderr
%112 = call i32 @fprintf(i32 %111, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%113 = call i32 @exit(i32 2)
unreachable
114: ; preds = %107
%115 = load %struct.ifaddrs*, %struct.ifaddrs** %5
%116 = icmp eq %struct.ifaddrs* %115, null
br i1 %116, label %117, label %121
117: ; preds = %114
%118 = load i32, i32* @stderr
%119 = call i32 @fprintf(i32 %118, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
%120 = call i32 @exit(i32 3)
unreachable
121: ; preds = %114
br label %122
122: ; preds = %121
%123 = load %struct.ifaddrs*, %struct.ifaddrs** %7
%124 = icmp eq %struct.ifaddrs* %123, null
br i1 %124, label %125, label %129
125: ; preds = %122
%126 = load i32, i32* @stderr
%127 = call i32 @fprintf(i32 %126, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
%128 = call i32 @exit(i32 4)
unreachable
129: ; preds = %122
%130 = load %struct.ifaddrs*, %struct.ifaddrs** %6
%131 = icmp eq %struct.ifaddrs* %130, null
br i1 %131, label %132, label %136
132: ; preds = %129
%133 = load i32, i32* @stderr
%134 = call i32 @fprintf(i32 %133, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%135 = call i32 @exit(i32 5)
unreachable
136: ; preds = %129
br label %137
137: ; preds = %136
%138 = load %struct.ifaddrs*, %struct.ifaddrs** %1
%139 = call i32 @freeifaddrs(%struct.ifaddrs* %138)
ret void
}

LLVM IR (-O2):
%struct.ifaddrs = type { i8*, i32, %struct.TYPE_2__*, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i64 }
@stderr = global i32 0
@.str = [37 x i8] c"Error: could not get interface list\0A\00"
@.str.1 = [13 x i8] c"getifaddrs()\00"
@.str.3 = [8 x i8] c" %s (%s\00"
@.str.4 = [8 x i8] c"no addr\00"
@IFF_LOOPBACK = global i32 0
@AF_INET = global i64 0
@IFF_BROADCAST = global i32 0
@AF_PACKET = global i64 0
@.str.6 = [30 x i8] c"Error: no loopback interface\0A\00"
@.str.7 = [31 x i8] c"Error: no address on loopback\0A\00"
@.str.8 = [26 x i8] c"Error: no eth0 interface\0A\00"
@.str.9 = [27 x i8] c"Error: no address on eth0\0A\00"
@str = [21 x i8] c" [*] Interface list:\00"
@str.10 = [2 x i8] c")\00"
define void @print_iff_list() {
%1 = alloca %struct.ifaddrs*
%2 = bitcast %struct.ifaddrs** %1 to i8*
store %struct.ifaddrs* null, %struct.ifaddrs** %1
%3 = call i32 @getifaddrs(%struct.ifaddrs** %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%12 = load %struct.ifaddrs*, %struct.ifaddrs** %1
%13 = icmp eq %struct.ifaddrs* %12, null
br i1 %13, label %80, label %22
14: ; preds = %31
%15 = load %struct.ifaddrs*, %struct.ifaddrs** %1
%16 = icmp eq %struct.ifaddrs* %15, null
br i1 %16, label %80, label %17
17: ; preds = %14
%18 = load i32, i32* @IFF_LOOPBACK
%19 = load i64, i64* @AF_INET
%20 = load i32, i32* @IFF_BROADCAST
%21 = load i64, i64* @AF_PACKET
br label %43
22: ; preds = %10, %31
%23 = phi %struct.ifaddrs* [ %39, %31 ], [ %12, %10 ]
%24 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %23, i64 0, i32 0
%25 = load i8*, i8** %24
%26 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %23, i64 0, i32 2
%27 = load %struct.TYPE_2__*, %struct.TYPE_2__** %26
%28 = icmp eq %struct.TYPE_2__* %27, null
br i1 %28, label %31, label %29
29: ; preds = %22
%30 = call i8* @ip_to_string(%struct.TYPE_2__* %27)
br label %31
31: ; preds = %22, %29
%32 = phi i8* [ %30, %29 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), %22 ]
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %25, i8* %32)
%34 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %23, i64 0, i32 1
%35 = load i32, i32* %34
%36 = call i32 @print_iff_flags(i32 %35)
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.10, i64 0, i64 0))
%38 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %23, i64 0, i32 3
%39 = load %struct.ifaddrs*, %struct.ifaddrs** %38
%40 = icmp eq %struct.ifaddrs* %39, null
br i1 %40, label %14, label %22
41: ; preds = %72
%42 = icmp eq i32 %73, 0
br i1 %42, label %80, label %84
43: ; preds = %17, %72
%44 = phi %struct.ifaddrs* [ %15, %17 ], [ %78, %72 ]
%45 = phi %struct.ifaddrs* [ null, %17 ], [ %76, %72 ]
%46 = phi %struct.ifaddrs* [ null, %17 ], [ %75, %72 ]
%47 = phi %struct.ifaddrs* [ null, %17 ], [ %74, %72 ]
%48 = phi i32 [ 0, %17 ], [ %73, %72 ]
%49 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %44, i64 0, i32 1
%50 = load i32, i32* %49
%51 = and i32 %18, %50
%52 = icmp eq i32 %51, 0
br i1 %52, label %60, label %53
53: ; preds = %43
%54 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %44, i64 0, i32 2
%55 = load %struct.TYPE_2__*, %struct.TYPE_2__** %54
%56 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %55, i64 0, i32 0
%57 = load i64, i64* %56
%58 = icmp eq i64 %57, %19
%59 = select i1 %58, %struct.ifaddrs* %44, %struct.ifaddrs* %47
br label %72
60: ; preds = %43
%61 = and i32 %20, %50
%62 = icmp eq i32 %61, 0
br i1 %62, label %72, label %63
63: ; preds = %60
%64 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %44, i64 0, i32 2
%65 = load %struct.TYPE_2__*, %struct.TYPE_2__** %64
%66 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %65, i64 0, i32 0
%67 = load i64, i64* %66
%68 = icmp eq i64 %67, %19
br i1 %68, label %72, label %69
69: ; preds = %63
%70 = icmp eq i64 %67, %21
%71 = select i1 %70, %struct.ifaddrs* %44, %struct.ifaddrs* %45
br label %72
72: ; preds = %69, %53, %63, %60
%73 = phi i32 [ %48, %60 ], [ 1, %53 ], [ %48, %63 ], [ %48, %69 ]
%74 = phi %struct.ifaddrs* [ %47, %60 ], [ %59, %53 ], [ %47, %63 ], [ %47, %69 ]
%75 = phi %struct.ifaddrs* [ %46, %60 ], [ %46, %53 ], [ %44, %63 ], [ %46, %69 ]
%76 = phi %struct.ifaddrs* [ %45, %60 ], [ %45, %53 ], [ %45, %63 ], [ %71, %69 ]
%77 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %44, i64 0, i32 3
%78 = load %struct.ifaddrs*, %struct.ifaddrs** %77
%79 = icmp eq %struct.ifaddrs* %78, null
br i1 %79, label %41, label %43
80: ; preds = %10, %14, %41
%81 = load i32, i32* @stderr
%82 = call i32 @fprintf(i32 %81, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%83 = call i32 @exit(i32 2)
unreachable
84: ; preds = %41
%85 = icmp eq %struct.ifaddrs* %74, null
br i1 %85, label %86, label %90
86: ; preds = %84
%87 = load i32, i32* @stderr
%88 = call i32 @fprintf(i32 %87, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
%89 = call i32 @exit(i32 3)
unreachable
90: ; preds = %84
%91 = icmp eq %struct.ifaddrs* %76, null
br i1 %91, label %92, label %96
92: ; preds = %90
%93 = load i32, i32* @stderr
%94 = call i32 @fprintf(i32 %93, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
%95 = call i32 @exit(i32 4)
unreachable
96: ; preds = %90
%97 = icmp eq %struct.ifaddrs* %75, null
br i1 %97, label %98, label %102
98: ; preds = %96
%99 = load i32, i32* @stderr
%100 = call i32 @fprintf(i32 %99, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%101 = call i32 @exit(i32 5)
unreachable
102: ; preds = %96
%103 = call i32 @freeifaddrs(%struct.ifaddrs* %15)
ret void
}