#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 /*<<< orphan*/ sin6_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
};
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ const member_1;
};
struct ifaddrs {
  char *ifa_name;
  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_INET6;
int INET6_ADDRSTRLEN;
int INET_ADDRSTRLEN;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ freeifaddrs(struct ifaddrs *);
int /*<<< orphan*/ getifaddrs(struct ifaddrs **);
int getopt_long(int, char **, char *, struct option *, int *);
int /*<<< orphan*/ inet_ntop(scalar_t__, void *, char *, int);
#define no_argument 129
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *, char *, char *);
#define required_argument 128
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
char *strdup(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int c;
  char *dev = NULL;
  int show_ipv4 = 0;
  int show_ipv6 = 0;
  while (1) {
    static struct option long_options[] = {
        {"all", no_argument, 0, 'a'},
        {"device", required_argument, 0, 'd'},
        {"ipv4", no_argument, 0, '4'},
        {"ipv6", no_argument, 0, '6'},
        {0, 0, 0, 0}};
    int option_index = 0;
    c = getopt_long(argc, argv, "ad:46", long_options, &option_index);
    if (c == -1)
      break;
    switch (c) {
    case '4':
      show_ipv4 = 1;
      break;
    case '6':
      show_ipv6 = 1;
      break;
    case 'a':
      show_ipv4 = 1;
      show_ipv6 = 1;
      break;
    case 'd':
      dev = strdup(optarg);
      break;
    case '?':
      exit(1);
      break;
    default:
      fprintf(stderr, "Unknown argument");
      exit(1);
    }
  }
  struct ifaddrs *ifAddrStruct = NULL;
  struct ifaddrs *ifa = NULL;
  void *tmpAddrPtr = NULL;
  getifaddrs(&ifAddrStruct);
  for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) {
    if (ifa && ifa->ifa_addr) {
      if (ifa->ifa_addr->sa_family == AF_INET && show_ipv4) {
        tmpAddrPtr = &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
        char addressBuffer[INET_ADDRSTRLEN];
        inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN);
        if ((dev == NULL) || (strcmp(dev, ifa->ifa_name) == 0))
          printf("%s %s\n", ifa->ifa_name, addressBuffer);
      } else if (ifa->ifa_addr->sa_family == AF_INET6 && show_ipv6) {
        tmpAddrPtr = &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr;
        char addressBuffer[INET6_ADDRSTRLEN];
        inet_ntop(AF_INET6, tmpAddrPtr, addressBuffer, INET6_ADDRSTRLEN);
        if ((dev == NULL) || (strcmp(dev, ifa->ifa_name) == 0))
          printf("%s %s\n", ifa->ifa_name, addressBuffer);
      }
    }
  }
  if (ifAddrStruct != NULL)
    freeifaddrs(ifAddrStruct);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf05(%rip),%rdx
lea    0x2e95(%rip),%rcx
lea    -0x2c(%rbp),%r8
call   1040 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11f6 <main+0x66>
jmp    128f <main+0xff>
mov    -0x14(%rbp),%eax
add    $0xffffffcc,%eax
mov    %eax,%ecx
mov    %rcx,-0x70(%rbp)
sub    $0x30,%eax
ja     126b <main+0xdb>
mov    -0x70(%rbp),%rax
lea    0xdea(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x24(%rbp)
jmp    128a <main+0xfa>
movl   $0x1,-0x28(%rbp)
jmp    128a <main+0xfa>
movl   $0x1,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
jmp    128a <main+0xfa>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
call   10b0 <strdup@plt>
mov    %rax,-0x20(%rbp)
jmp    128a <main+0xfa>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    11bf <main+0x2f>
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
lea    -0x38(%rbp),%rdi
call   1080 <getifaddrs@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     147a <main+0x2ea>
cmpq   $0x0,-0x40(%rbp)
je     1464 <main+0x2d4>
mov    -0x40(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1464 <main+0x2d4>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    0x2ce9(%rip),%rcx
cmp    (%rcx),%rax
jne    139e <main+0x20e>
cmpl   $0x0,-0x24(%rbp)
je     139e <main+0x20e>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    0x2ca3(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x78(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x58(%rbp)
mov    0x2c97(%rip),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rsi
mov    0x2c69(%rip),%rax
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
cmpq   $0x0,-0x20(%rbp)
je     137b <main+0x1eb>
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    (%rax),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1392 <main+0x202>
mov    -0x78(%rbp),%rdx
mov    -0x40(%rbp),%rax
mov    (%rax),%rsi
lea    0xd63(%rip),%rdi
call   1050 <printf@plt>
mov    -0x50(%rbp),%rax
mov    %rax,%rsp
jmp    145f <main+0x2cf>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    0x2c20(%rip),%rcx
cmp    (%rcx),%rax
jne    145a <main+0x2ca>
cmpl   $0x0,-0x28(%rbp)
je     145a <main+0x2ca>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    0x2c0a(%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,-0x80(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x68(%rbp)
mov    0x2bce(%rip),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rsi
mov    0x2bd0(%rip),%rax
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
cmpq   $0x0,-0x20(%rbp)
je     143c <main+0x2ac>
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    (%rax),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1453 <main+0x2c3>
mov    -0x80(%rbp),%rdx
mov    -0x40(%rbp),%rax
mov    (%rax),%rsi
lea    0xca2(%rip),%rdi
call   1050 <printf@plt>
mov    -0x60(%rbp),%rax
mov    %rax,%rsp
jmp    145f <main+0x2cf>
jmp    1464 <main+0x2d4>
jmp    1469 <main+0x2d9>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x40(%rbp)
jmp    12b8 <main+0x128>
cmpq   $0x0,-0x38(%rbp)
je     148e <main+0x2fe>
mov    -0x38(%rbp),%rdi
call   1090 <freeifaddrs@plt>
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
lea    -0x44(%rbp),%r15
lea    0xe49(%rip),%r13
xor    %r12d,%r12d
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
jmp    11df <main+0x4f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x1,%eax
mov    %rax,-0x38(%rbp)
mov    %r12d,%eax
mov    %eax,%r12d
movl   $0x0,-0x44(%rbp)
mov    %ebx,%edi
mov    %r14,%rsi
lea    0xee7(%rip),%rdx
lea    0x2e77(%rip),%rcx
mov    %r15,%r8
call   1040 <getopt_long@plt>
lea    -0x34(%rax),%ecx
cmp    $0x30,%ecx
ja     1244 <main+0xb4>
mov    $0x1,%eax
movslq 0x0(%r13,%rcx,4),%rcx
add    %r13,%rcx
jmp    *%rcx
mov    $0x1,%eax
mov    %rax,-0x38(%rbp)
mov    $0x1,%r12d
jmp    11df <main+0x4f>
nopl   0x0(%rax)
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
call   10b0 <strdup@plt>
mov    %rax,-0x30(%rbp)
jmp    11d9 <main+0x49>
cmp    $0xffffffff,%eax
jne    1365 <main+0x1d5>
movq   $0x0,-0x40(%rbp)
lea    -0x40(%rbp),%rdi
call   1080 <getifaddrs@plt>
mov    -0x40(%rbp),%rbx
test   %rbx,%rbx
je     1354 <main+0x1c4>
mov    0x2d66(%rip),%r13
jmp    12a2 <main+0x112>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rbx),%rsi
lea    0xe66(%rip),%rdi
mov    %r15,%rdx
call   1050 <printf@plt>
mov    %r14,%rsp
mov    0x10(%rbx),%rbx
test   %rbx,%rbx
je     1346 <main+0x1b6>
mov    0x8(%rbx),%rsi
test   %rsi,%rsi
je     1295 <main+0x105>
mov    (%rsi),%rax
cmp    0x0(%r13),%rax
jne    12e0 <main+0x150>
test   %r12d,%r12d
je     12e0 <main+0x150>
mov    %rsp,%r14
mov    0x2cf5(%rip),%rcx
mov    (%rcx),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    0x0(%r13),%rdi
jmp    1319 <main+0x189>
nopl   0x0(%rax)
mov    0x2ce9(%rip),%rcx
cmp    (%rcx),%rax
jne    1295 <main+0x105>
cmpl   $0x0,-0x38(%rbp)
je     1295 <main+0x105>
mov    %rsp,%r14
mov    0x2ce4(%rip),%rcx
mov    (%rcx),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    0x2cba(%rip),%rax
mov    (%rax),%rdi
mov    (%rcx),%ecx
mov    %r15,%rdx
call   1030 <inet_ntop@plt>
mov    -0x30(%rbp),%rdi
test   %rdi,%rdi
je     1280 <main+0xf0>
mov    (%rbx),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1292 <main+0x102>
jmp    1280 <main+0xf0>
mov    -0x40(%rbp),%rdi
test   %rdi,%rdi
je     1354 <main+0x1c4>
call   1090 <freeifaddrs@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c54(%rip),%rax
mov    (%rax),%edi
lea    0xd6a(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
%struct.ifaddrs = type { i8*, %struct.TYPE_2__*, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i64 }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr_in6 = type { i32 }
@main.long_options = internal global [5 x %struct.option] [%struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8 -127, i32 0, i32 97 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 100 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8 -127, i32 0, i32 52 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8 -127, i32 0, i32 54 }, %struct.option zeroinitializer]
@.str = [4 x i8] c"all\00"
@.str.1 = [7 x i8] c"device\00"
@.str.2 = [5 x i8] c"ipv4\00"
@.str.3 = [5 x i8] c"ipv6\00"
@.str.4 = [6 x i8] c"ad:46\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.5 = [17 x i8] c"Unknown argument\00"
@AF_INET = global i64 0
@INET_ADDRSTRLEN = global i32 0
@.str.6 = [7 x i8] c"%s %s\0A\00"
@AF_INET6 = global i64 0
@INET6_ADDRSTRLEN = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.ifaddrs*
%12 = alloca %struct.ifaddrs*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i8*
%17 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i32 0, i32* %8
store i32 0, i32* %9
br label %18
18: ; preds = %2, %39
store i32 0, i32* %10
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = call i32 @getopt_long(i32 %19, i8** %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %struct.option* getelementptr inbounds ([5 x %struct.option], [5 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %10)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %25
24: ; preds = %18
br label %40
25: ; preds = %18
%26 = load i32, i32* %6
switch i32 %26, label %35 [
i32 52, label %27
i32 54, label %28
i32 97, label %29
i32 100, label %30
i32 63, label %33
]
27: ; preds = %25
store i32 1, i32* %8
br label %39
28: ; preds = %25
store i32 1, i32* %9
br label %39
29: ; preds = %25
store i32 1, i32* %8
store i32 1, i32* %9
br label %39
30: ; preds = %25
%31 = load i32, i32* @optarg
%32 = call i8* @strdup(i32 %31)
store i8* %32, i8** %7
br label %39
33: ; preds = %25
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %25
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %30, %29, %28, %27
br label %18
40: ; preds = %24
store %struct.ifaddrs* null, %struct.ifaddrs** %11
store %struct.ifaddrs* null, %struct.ifaddrs** %12
store i8* null, i8** %13
%41 = call i32 @getifaddrs(%struct.ifaddrs** %11)
%42 = load %struct.ifaddrs*, %struct.ifaddrs** %11
store %struct.ifaddrs* %42, %struct.ifaddrs** %12
br label %43
43: ; preds = %141, %40
%44 = load %struct.ifaddrs*, %struct.ifaddrs** %12
%45 = icmp ne %struct.ifaddrs* %44, null
br i1 %45, label %46, label %145
46: ; preds = %43
%47 = load %struct.ifaddrs*, %struct.ifaddrs** %12
%48 = icmp ne %struct.ifaddrs* %47, null
br i1 %48, label %49, label %140
49: ; preds = %46
%50 = load %struct.ifaddrs*, %struct.ifaddrs** %12
%51 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %50, i32 0, i32 1
%52 = load %struct.TYPE_2__*, %struct.TYPE_2__** %51
%53 = icmp ne %struct.TYPE_2__* %52, null
br i1 %53, label %54, label %140
54: ; preds = %49
%55 = load %struct.ifaddrs*, %struct.ifaddrs** %12
%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 i64, i64* %58
%60 = load i64, i64* @AF_INET
%61 = icmp eq i64 %59, %60
br i1 %61, label %62, label %96
62: ; preds = %54
%63 = load i32, i32* %8
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %96
65: ; preds = %62
%66 = load %struct.ifaddrs*, %struct.ifaddrs** %12
%67 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %66, i32 0, i32 1
%68 = load %struct.TYPE_2__*, %struct.TYPE_2__** %67
%69 = bitcast %struct.TYPE_2__* %68 to %struct.sockaddr_in*
%70 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %69, i32 0, i32 0
%71 = bitcast i32* %70 to i8*
store i8* %71, i8** %13
%72 = load i32, i32* @INET_ADDRSTRLEN
%73 = zext i32 %72 to i64
%74 = call i8* @llvm.stacksave()
store i8* %74, i8** %14
%75 = alloca i8, i64 %73
store i64 %73, i64* %15
%76 = load i64, i64* @AF_INET
%77 = load i8*, i8** %13
%78 = load i32, i32* @INET_ADDRSTRLEN
%79 = call i32 @inet_ntop(i64 %76, i8* %77, i8* %75, i32 %78)
%80 = load i8*, i8** %7
%81 = icmp eq i8* %80, null
br i1 %81, label %89, label %82
82: ; preds = %65
%83 = load i8*, i8** %7
%84 = load %struct.ifaddrs*, %struct.ifaddrs** %12
%85 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %84, i32 0, i32 0
%86 = load i8*, i8** %85
%87 = call i64 @strcmp(i8* %83, i8* %86)
%88 = icmp eq i64 %87, 0
br i1 %88, label %89, label %94
89: ; preds = %82, %65
%90 = load %struct.ifaddrs*, %struct.ifaddrs** %12
%91 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %90, i32 0, i32 0
%92 = load i8*, i8** %91
%93 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %92, i8* %75)
br label %94
94: ; preds = %89, %82
%95 = load i8*, i8** %14
br label %139
96: ; preds = %62, %54
%97 = load %struct.ifaddrs*, %struct.ifaddrs** %12
%98 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %97, i32 0, i32 1
%99 = load %struct.TYPE_2__*, %struct.TYPE_2__** %98
%100 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %99, i32 0, i32 0
%101 = load i64, i64* %100
%102 = load i64, i64* @AF_INET6
%103 = icmp eq i64 %101, %102
br i1 %103, label %104, label %138
104: ; preds = %96
%105 = load i32, i32* %9
%106 = icmp ne i32 %105, 0
br i1 %106, label %107, label %138
107: ; preds = %104
%108 = load %struct.ifaddrs*, %struct.ifaddrs** %12
%109 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %108, i32 0, i32 1
%110 = load %struct.TYPE_2__*, %struct.TYPE_2__** %109
%111 = bitcast %struct.TYPE_2__* %110 to %struct.sockaddr_in6*
%112 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %111, i32 0, i32 0
%113 = bitcast i32* %112 to i8*
store i8* %113, i8** %13
%114 = load i32, i32* @INET6_ADDRSTRLEN
%115 = zext i32 %114 to i64
%116 = call i8* @llvm.stacksave()
store i8* %116, i8** %16
%117 = alloca i8, i64 %115
store i64 %115, i64* %17
%118 = load i64, i64* @AF_INET6
%119 = load i8*, i8** %13
%120 = load i32, i32* @INET6_ADDRSTRLEN
%121 = call i32 @inet_ntop(i64 %118, i8* %119, i8* %117, i32 %120)
%122 = load i8*, i8** %7
%123 = icmp eq i8* %122, null
br i1 %123, label %131, label %124
124: ; preds = %107
%125 = load i8*, i8** %7
%126 = load %struct.ifaddrs*, %struct.ifaddrs** %12
%127 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %126, i32 0, i32 0
%128 = load i8*, i8** %127
%129 = call i64 @strcmp(i8* %125, i8* %128)
%130 = icmp eq i64 %129, 0
br i1 %130, label %131, label %136
131: ; preds = %124, %107
%132 = load %struct.ifaddrs*, %struct.ifaddrs** %12
%133 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %132, i32 0, i32 0
%134 = load i8*, i8** %133
%135 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %134, i8* %117)
br label %136
136: ; preds = %131, %124
%137 = load i8*, i8** %16
br label %138
138: ; preds = %136, %104, %96
br label %139
139: ; preds = %138, %94
br label %140
140: ; preds = %139, %49, %46
br label %141
141: ; preds = %140
%142 = load %struct.ifaddrs*, %struct.ifaddrs** %12
%143 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %142, i32 0, i32 2
%144 = load %struct.ifaddrs*, %struct.ifaddrs** %143
store %struct.ifaddrs* %144, %struct.ifaddrs** %12
br label %43
145: ; preds = %43
%146 = load %struct.ifaddrs*, %struct.ifaddrs** %11
%147 = icmp ne %struct.ifaddrs* %146, null
br i1 %147, label %148, label %151
148: ; preds = %145
%149 = load %struct.ifaddrs*, %struct.ifaddrs** %11
%150 = call i32 @freeifaddrs(%struct.ifaddrs* %149)
br label %151
151: ; preds = %148, %145
ret i32 0
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
%struct.ifaddrs = type { i8*, %struct.TYPE_2__*, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i64 }
@main.long_options = internal global [5 x %struct.option] [%struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8 -127, i32 0, i32 97 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 100 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8 -127, i32 0, i32 52 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8 -127, i32 0, i32 54 }, %struct.option zeroinitializer]
@.str = [4 x i8] c"all\00"
@.str.1 = [7 x i8] c"device\00"
@.str.2 = [5 x i8] c"ipv4\00"
@.str.3 = [5 x i8] c"ipv6\00"
@.str.4 = [6 x i8] c"ad:46\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.5 = [17 x i8] c"Unknown argument\00"
@AF_INET = global i64 0
@INET_ADDRSTRLEN = global i32 0
@.str.6 = [7 x i8] c"%s %s\0A\00"
@AF_INET6 = global i64 0
@INET6_ADDRSTRLEN = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca %struct.ifaddrs*
%5 = bitcast i32* %3 to i8*
br label %6
6: ; preds = %22, %2
%7 = phi i32 [ 0, %2 ], [ %23, %22 ]
%8 = phi i32 [ 0, %2 ], [ %24, %22 ]
%9 = phi i8* [ null, %2 ], [ %25, %22 ]
store i32 0, i32* %3
%10 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %struct.option* getelementptr inbounds ([5 x %struct.option], [5 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %3)
switch i32 %10, label %18 [
i32 -1, label %26
i32 52, label %22
i32 54, label %11
i32 97, label %12
i32 100, label %13
i32 63, label %16
]
11: ; preds = %6
br label %22
12: ; preds = %6
br label %22
13: ; preds = %6
%14 = load i32, i32* @optarg
%15 = call i8* @strdup(i32 %14)
br label %22
16: ; preds = %6
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %6
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %11, %12, %13, %6
%23 = phi i32 [ %7, %13 ], [ 1, %12 ], [ 1, %11 ], [ %7, %6 ]
%24 = phi i32 [ %8, %13 ], [ 1, %12 ], [ %8, %11 ], [ 1, %6 ]
%25 = phi i8* [ %15, %13 ], [ %9, %12 ], [ %9, %11 ], [ %9, %6 ]
br label %6
26: ; preds = %6
%27 = bitcast %struct.ifaddrs** %4 to i8*
store %struct.ifaddrs* null, %struct.ifaddrs** %4
%28 = call i32 @getifaddrs(%struct.ifaddrs** %4)
%29 = load %struct.ifaddrs*, %struct.ifaddrs** %4
%30 = icmp eq %struct.ifaddrs* %29, null
br i1 %30, label %95, label %31
31: ; preds = %26
%32 = icmp ne i32 %8, 0
%33 = icmp ne i32 %7, 0
%34 = icmp eq i8* %9, null
br label %35
35: ; preds = %31, %86
%36 = phi %struct.ifaddrs* [ %29, %31 ], [ %88, %86 ]
%37 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %36, i64 0, i32 1
%38 = load %struct.TYPE_2__*, %struct.TYPE_2__** %37
%39 = icmp eq %struct.TYPE_2__* %38, null
br i1 %39, label %86, label %40
40: ; preds = %35
%41 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %38, i64 0, i32 0
%42 = load i64, i64* %41
%43 = load i64, i64* @AF_INET
%44 = icmp eq i64 %42, %43
%45 = select i1 %44, i1 %32, i1 false
br i1 %45, label %46, label %60
46: ; preds = %40
%47 = bitcast %struct.TYPE_2__* %38 to i8*
%48 = load i32, i32* @INET_ADDRSTRLEN
%49 = zext i32 %48 to i64
%50 = call i8* @llvm.stacksave()
%51 = alloca i8, i64 %49
%52 = load i64, i64* @AF_INET
%53 = load i32, i32* @INET_ADDRSTRLEN
%54 = call i32 @inet_ntop(i64 %52, i8* %47, i8* %51, i32 %53)
br i1 %34, label %78, label %55
55: ; preds = %46
%56 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %36, i64 0, i32 0
%57 = load i8*, i8** %56
%58 = call i64 @strcmp(i8* %9, i8* %57)
%59 = icmp eq i64 %58, 0
br i1 %59, label %78, label %84
60: ; preds = %40
%61 = load i64, i64* @AF_INET6
%62 = icmp eq i64 %42, %61
%63 = select i1 %62, i1 %33, i1 false
br i1 %63, label %64, label %86
64: ; preds = %60
%65 = bitcast %struct.TYPE_2__* %38 to i8*
%66 = load i32, i32* @INET6_ADDRSTRLEN
%67 = zext i32 %66 to i64
%68 = call i8* @llvm.stacksave()
%69 = alloca i8, i64 %67
%70 = load i64, i64* @AF_INET6
%71 = load i32, i32* @INET6_ADDRSTRLEN
%72 = call i32 @inet_ntop(i64 %70, i8* %65, i8* %69, i32 %71)
br i1 %34, label %78, label %73
73: ; preds = %64
%74 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %36, i64 0, i32 0
%75 = load i8*, i8** %74
%76 = call i64 @strcmp(i8* %9, i8* %75)
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %84
78: ; preds = %64, %73, %46, %55
%79 = phi i8* [ %51, %55 ], [ %51, %46 ], [ %69, %73 ], [ %69, %64 ]
%80 = phi i8* [ %50, %55 ], [ %50, %46 ], [ %68, %73 ], [ %68, %64 ]
%81 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %36, i64 0, i32 0
%82 = load i8*, i8** %81
%83 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %82, i8* %79)
br label %84
84: ; preds = %78, %73, %55
%85 = phi i8* [ %50, %55 ], [ %68, %73 ], [ %80, %78 ]
br label %86
86: ; preds = %84, %35, %60
%87 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %36, i64 0, i32 2
%88 = load %struct.ifaddrs*, %struct.ifaddrs** %87
%89 = icmp eq %struct.ifaddrs* %88, null
br i1 %89, label %90, label %35
90: ; preds = %86
%91 = load %struct.ifaddrs*, %struct.ifaddrs** %4
%92 = icmp eq %struct.ifaddrs* %91, null
br i1 %92, label %95, label %93
93: ; preds = %90
%94 = call i32 @freeifaddrs(%struct.ifaddrs* %91)
br label %95
95: ; preds = %26, %93, %90
ret i32 0
}