#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 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 /*<<< orphan*/ EXIT_SUCCESS;
int INET6_ADDRSTRLEN;
int INET_ADDRSTRLEN;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ freeifaddrs(struct ifaddrs *);
int /*<<< orphan*/ getifaddrs(struct ifaddrs **);
int /*<<< orphan*/ inet_ntop(scalar_t__, int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ printf(char *, char *, char *);
int main(int argc, char **argv) {
  char addr4[INET_ADDRSTRLEN];
  char addr6[INET6_ADDRSTRLEN];
  struct ifaddrs *ifaddrs = NULL;
  struct ifaddrs *ifaddr = NULL;
  getifaddrs(&ifaddrs);
  for (ifaddr = ifaddrs; ifaddr != NULL; ifaddr = ifaddr->ifa_next) {
    if ((ifaddr->ifa_addr != NULL) &&
        (ifaddr->ifa_addr->sa_family == AF_INET)) {
      struct sockaddr_in *addr = (struct sockaddr_in *)ifaddr->ifa_addr;
      inet_ntop(AF_INET, &addr->sin_addr, addr4, INET_ADDRSTRLEN);
      printf("%s: %s\n", ifaddr->ifa_name, addr4);
    }
    if ((ifaddr->ifa_addr != NULL) &&
        (ifaddr->ifa_addr->sa_family == AF_INET6)) {
      struct sockaddr_in6 *addr = (struct sockaddr_in6 *)ifaddr->ifa_addr;
      inet_ntop(AF_INET6, &addr->sin6_addr, addr6, INET6_ADDRSTRLEN);
      printf("%s: %s\n", ifaddr->ifa_name, addr6);
    }
  }
  if (ifaddrs != NULL)
    freeifaddrs(ifaddrs);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    0x2e4f(%rip),%rax
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
call   1050 <getifaddrs@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     12d3 <main+0x183>
mov    -0x38(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1250 <main+0x100>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    0x2ddc(%rip),%rcx
cmp    (%rcx),%rax
jne    1250 <main+0x100>
mov    -0x58(%rbp),%rdx
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    0x2dbc(%rip),%rax
mov    (%rax),%rdi
mov    -0x40(%rbp),%rsi
mov    0x2d96(%rip),%rax
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
mov    -0x58(%rbp),%rdx
mov    -0x38(%rbp),%rax
mov    (%rax),%rsi
lea    0xdb5(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     12bd <main+0x16d>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    0x2d67(%rip),%rcx
cmp    (%rcx),%rax
jne    12bd <main+0x16d>
mov    -0x50(%rbp),%rdx
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d47(%rip),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rsi
mov    0x2d49(%rip),%rax
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
mov    -0x50(%rbp),%rdx
mov    -0x38(%rbp),%rax
mov    (%rax),%rsi
lea    0xd48(%rip),%rdi
call   1040 <printf@plt>
jmp    12c2 <main+0x172>
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    11d8 <main+0x88>
cmpq   $0x0,-0x30(%rbp)
je     12e7 <main+0x197>
mov    -0x30(%rbp),%rdi
call   1060 <freeifaddrs@plt>
mov    0x2cd2(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e63(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
movq   $0x0,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
call   1050 <getifaddrs@plt>
mov    -0x30(%rbp),%r13
test   %r13,%r13
je     1243 <main+0xf3>
mov    0x2e29(%rip),%r12
lea    0xe42(%rip),%r15
jmp    11c9 <main+0x79>
mov    0x10(%r13),%r13
test   %r13,%r13
je     1235 <main+0xe5>
mov    0x8(%r13),%rsi
test   %rsi,%rsi
je     11c0 <main+0x70>
mov    (%rsi),%rdi
cmp    (%r12),%rdi
jne    1204 <main+0xb4>
mov    0x2de6(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdx
call   1030 <inet_ntop@plt>
mov    0x0(%r13),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
call   1040 <printf@plt>
mov    0x8(%r13),%rsi
test   %rsi,%rsi
je     11c0 <main+0x70>
mov    (%rsi),%rdi
mov    0x2dca(%rip),%rax
cmp    (%rax),%rdi
jne    11c0 <main+0x70>
mov    0x2dce(%rip),%rax
mov    (%rax),%ecx
mov    %r14,%rdx
call   1030 <inet_ntop@plt>
mov    0x0(%r13),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
call   1040 <printf@plt>
jmp    11c0 <main+0x70>
mov    -0x30(%rbp),%rdi
test   %rdi,%rdi
je     1243 <main+0xf3>
call   1060 <freeifaddrs@plt>
mov    0x2d76(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.ifaddrs = type { i8*, %struct.TYPE_2__*, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i64 }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr_in6 = type { i32 }
@INET_ADDRSTRLEN = global i32 0
@INET6_ADDRSTRLEN = global i32 0
@AF_INET = global i64 0
@.str = [8 x i8] c"%s: %s\0A\00"
@AF_INET6 = global i64 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca %struct.ifaddrs*
%10 = alloca %struct.ifaddrs*
%11 = alloca %struct.sockaddr_in*
%12 = alloca %struct.sockaddr_in6*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* @INET_ADDRSTRLEN
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %6
%16 = alloca i8, i64 %14
store i64 %14, i64* %7
%17 = load i32, i32* @INET6_ADDRSTRLEN
%18 = zext i32 %17 to i64
%19 = alloca i8, i64 %18
store i64 %18, i64* %8
store %struct.ifaddrs* null, %struct.ifaddrs** %9
store %struct.ifaddrs* null, %struct.ifaddrs** %10
%20 = call i32 @getifaddrs(%struct.ifaddrs** %9)
%21 = load %struct.ifaddrs*, %struct.ifaddrs** %9
store %struct.ifaddrs* %21, %struct.ifaddrs** %10
br label %22
22: ; preds = %80, %2
%23 = load %struct.ifaddrs*, %struct.ifaddrs** %10
%24 = icmp ne %struct.ifaddrs* %23, null
br i1 %24, label %25, label %84
25: ; preds = %22
%26 = load %struct.ifaddrs*, %struct.ifaddrs** %10
%27 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %26, i32 0, i32 1
%28 = load %struct.TYPE_2__*, %struct.TYPE_2__** %27
%29 = icmp ne %struct.TYPE_2__* %28, null
br i1 %29, label %30, label %52
30: ; preds = %25
%31 = load %struct.ifaddrs*, %struct.ifaddrs** %10
%32 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %31, i32 0, i32 1
%33 = load %struct.TYPE_2__*, %struct.TYPE_2__** %32
%34 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %33, i32 0, i32 0
%35 = load i64, i64* %34
%36 = load i64, i64* @AF_INET
%37 = icmp eq i64 %35, %36
br i1 %37, label %38, label %52
38: ; preds = %30
%39 = load %struct.ifaddrs*, %struct.ifaddrs** %10
%40 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %39, i32 0, i32 1
%41 = load %struct.TYPE_2__*, %struct.TYPE_2__** %40
%42 = bitcast %struct.TYPE_2__* %41 to %struct.sockaddr_in*
store %struct.sockaddr_in* %42, %struct.sockaddr_in** %11
%43 = load i64, i64* @AF_INET
%44 = load %struct.sockaddr_in*, %struct.sockaddr_in** %11
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %44, i32 0, i32 0
%46 = load i32, i32* @INET_ADDRSTRLEN
%47 = call i32 @inet_ntop(i64 %43, i32* %45, i8* %16, i32 %46)
%48 = load %struct.ifaddrs*, %struct.ifaddrs** %10
%49 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %48, i32 0, i32 0
%50 = load i8*, i8** %49
%51 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %50, i8* %16)
br label %52
52: ; preds = %38, %30, %25
%53 = load %struct.ifaddrs*, %struct.ifaddrs** %10
%54 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %53, i32 0, i32 1
%55 = load %struct.TYPE_2__*, %struct.TYPE_2__** %54
%56 = icmp ne %struct.TYPE_2__* %55, null
br i1 %56, label %57, label %79
57: ; preds = %52
%58 = load %struct.ifaddrs*, %struct.ifaddrs** %10
%59 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %58, i32 0, i32 1
%60 = load %struct.TYPE_2__*, %struct.TYPE_2__** %59
%61 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %60, i32 0, i32 0
%62 = load i64, i64* %61
%63 = load i64, i64* @AF_INET6
%64 = icmp eq i64 %62, %63
br i1 %64, label %65, label %79
65: ; preds = %57
%66 = load %struct.ifaddrs*, %struct.ifaddrs** %10
%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_in6*
store %struct.sockaddr_in6* %69, %struct.sockaddr_in6** %12
%70 = load i64, i64* @AF_INET6
%71 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %12
%72 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %71, i32 0, i32 0
%73 = load i32, i32* @INET6_ADDRSTRLEN
%74 = call i32 @inet_ntop(i64 %70, i32* %72, i8* %19, i32 %73)
%75 = load %struct.ifaddrs*, %struct.ifaddrs** %10
%76 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %75, i32 0, i32 0
%77 = load i8*, i8** %76
%78 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %77, i8* %19)
br label %79
79: ; preds = %65, %57, %52
br label %80
80: ; preds = %79
%81 = load %struct.ifaddrs*, %struct.ifaddrs** %10
%82 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %81, i32 0, i32 2
%83 = load %struct.ifaddrs*, %struct.ifaddrs** %82
store %struct.ifaddrs* %83, %struct.ifaddrs** %10
br label %22
84: ; preds = %22
%85 = load %struct.ifaddrs*, %struct.ifaddrs** %9
%86 = icmp ne %struct.ifaddrs* %85, null
br i1 %86, label %87, label %90
87: ; preds = %84
%88 = load %struct.ifaddrs*, %struct.ifaddrs** %9
%89 = call i32 @freeifaddrs(%struct.ifaddrs* %88)
br label %90
90: ; preds = %87, %84
%91 = load i32, i32* @EXIT_SUCCESS
%92 = call i32 @exit(i32 %91)
unreachable
}

LLVM IR (-O2):
%struct.ifaddrs = type { i8*, %struct.TYPE_2__*, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i64 }
@INET_ADDRSTRLEN = global i32 0
@INET6_ADDRSTRLEN = global i32 0
@AF_INET = global i64 0
@.str = [8 x i8] c"%s: %s\0A\00"
@AF_INET6 = global i64 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.ifaddrs*
%4 = load i32, i32* @INET_ADDRSTRLEN
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = load i32, i32* @INET6_ADDRSTRLEN
%8 = zext i32 %7 to i64
%9 = alloca i8, i64 %8
%10 = bitcast %struct.ifaddrs** %3 to i8*
store %struct.ifaddrs* null, %struct.ifaddrs** %3
%11 = call i32 @getifaddrs(%struct.ifaddrs** %3)
%12 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%13 = icmp eq %struct.ifaddrs* %12, null
br i1 %13, label %55, label %14
14: ; preds = %2, %46
%15 = phi %struct.ifaddrs* [ %48, %46 ], [ %12, %2 ]
%16 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %15, i64 0, i32 1
%17 = load %struct.TYPE_2__*, %struct.TYPE_2__** %16
%18 = icmp eq %struct.TYPE_2__* %17, null
br i1 %18, label %46, label %19
19: ; preds = %14
%20 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %17, i64 0, i32 0
%21 = load i64, i64* %20
%22 = load i64, i64* @AF_INET
%23 = icmp eq i64 %21, %22
br i1 %23, label %24, label %33
24: ; preds = %19
%25 = bitcast %struct.TYPE_2__* %17 to i32*
%26 = load i32, i32* @INET_ADDRSTRLEN
%27 = call i32 @inet_ntop(i64 %21, i32* %25, i8* %6, i32 %26)
%28 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %15, i64 0, i32 0
%29 = load i8*, i8** %28
%30 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %29, i8* %6)
%31 = load %struct.TYPE_2__*, %struct.TYPE_2__** %16
%32 = icmp eq %struct.TYPE_2__* %31, null
br i1 %32, label %46, label %33
33: ; preds = %19, %24
%34 = phi %struct.TYPE_2__* [ %31, %24 ], [ %17, %19 ]
%35 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %34, i64 0, i32 0
%36 = load i64, i64* %35
%37 = load i64, i64* @AF_INET6
%38 = icmp eq i64 %36, %37
br i1 %38, label %39, label %46
39: ; preds = %33
%40 = bitcast %struct.TYPE_2__* %34 to i32*
%41 = load i32, i32* @INET6_ADDRSTRLEN
%42 = call i32 @inet_ntop(i64 %36, i32* %40, i8* %9, i32 %41)
%43 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %15, i64 0, i32 0
%44 = load i8*, i8** %43
%45 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %44, i8* %9)
br label %46
46: ; preds = %14, %24, %33, %39
%47 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %15, i64 0, i32 2
%48 = load %struct.ifaddrs*, %struct.ifaddrs** %47
%49 = icmp eq %struct.ifaddrs* %48, null
br i1 %49, label %50, label %14
50: ; preds = %46
%51 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%52 = icmp eq %struct.ifaddrs* %51, null
br i1 %52, label %55, label %53
53: ; preds = %50
%54 = call i32 @freeifaddrs(%struct.ifaddrs* %51)
br label %55
55: ; preds = %2, %53, %50
%56 = load i32, i32* @EXIT_SUCCESS
%57 = call i32 @exit(i32 %56)
unreachable
}