#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 {
  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;
int /*<<< orphan*/ freeifaddrs(struct ifaddrs *);
int /*<<< orphan*/ getifaddrs(struct ifaddrs **);
char *inet_ntoa(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char *);
int main() {
  struct ifaddrs *ifap, *ifa;
  struct sockaddr_in *sa;
  char *addr;
  getifaddrs(&ifap);
  for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
    if (ifa->ifa_addr->sa_family == AF_INET) {
      sa = (struct sockaddr_in *)ifa->ifa_addr;
      addr = inet_ntoa(sa->sin_addr);
      printf("Interface: %s\tAddress: %s\n", ifa->ifa_name, addr);
    }
  }
  freeifaddrs(ifap);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
call   1050 <getifaddrs@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ce <main+0x8e>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    0x2e6b(%rip),%rcx
cmp    (%rcx),%rax
jne    11b8 <main+0x78>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe4d(%rip),%rdi
call   1040 <printf@plt>
jmp    11bd <main+0x7d>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1160 <main+0x20>
mov    -0x10(%rbp),%rdi
call   1060 <freeifaddrs@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
call   1050 <getifaddrs@plt>
mov    0x8(%rsp),%rbx
test   %rbx,%rbx
je     11a4 <main+0x64>
mov    0x2e84(%rip),%r15
mov    (%r15),%rax
lea    0xe92(%rip),%r14
jmp    1179 <main+0x39>
mov    0x10(%rbx),%rbx
test   %rbx,%rbx
je     119d <main+0x5d>
mov    0x8(%rbx),%rcx
mov    (%rcx),%rdi
cmp    %rax,%rdi
jne    1170 <main+0x30>
call   1030 <inet_ntoa@plt>
mov    (%rbx),%rsi
mov    %r14,%rdi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    (%r15),%rax
jmp    1170 <main+0x30>
mov    0x8(%rsp),%rdi
jmp    11a6 <main+0x66>
xor    %edi,%edi
call   1060 <freeifaddrs@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.ifaddrs = type { i8*, %struct.TYPE_2__*, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i64 }
%struct.sockaddr_in = type { i32 }
@AF_INET = global i64 0
@.str = [27 x i8] c"Interface: %s\09Address: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.ifaddrs*
%3 = alloca %struct.ifaddrs*
%4 = alloca %struct.sockaddr_in*
%5 = alloca i8*
store i32 0, i32* %1
%6 = call i32 @getifaddrs(%struct.ifaddrs** %2)
%7 = load %struct.ifaddrs*, %struct.ifaddrs** %2
store %struct.ifaddrs* %7, %struct.ifaddrs** %3
br label %8
8: ; preds = %34, %0
%9 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%10 = icmp ne %struct.ifaddrs* %9, null
br i1 %10, label %11, label %38
11: ; preds = %8
%12 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%13 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %12, i32 0, i32 1
%14 = load %struct.TYPE_2__*, %struct.TYPE_2__** %13
%15 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %14, i32 0, i32 0
%16 = load i64, i64* %15
%17 = load i64, i64* @AF_INET
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %33
19: ; preds = %11
%20 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%21 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %20, i32 0, i32 1
%22 = load %struct.TYPE_2__*, %struct.TYPE_2__** %21
%23 = bitcast %struct.TYPE_2__* %22 to %struct.sockaddr_in*
store %struct.sockaddr_in* %23, %struct.sockaddr_in** %4
%24 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %24, i32 0, i32 0
%26 = load i32, i32* %25
%27 = call i8* @inet_ntoa(i32 %26)
store i8* %27, i8** %5
%28 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%29 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %28, i32 0, i32 0
%30 = load i8*, i8** %29
%31 = load i8*, i8** %5
%32 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %30, i8* %31)
br label %33
33: ; preds = %19, %11
br label %34
34: ; preds = %33
%35 = load %struct.ifaddrs*, %struct.ifaddrs** %3
%36 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %35, i32 0, i32 2
%37 = load %struct.ifaddrs*, %struct.ifaddrs** %36
store %struct.ifaddrs* %37, %struct.ifaddrs** %3
br label %8
38: ; preds = %8
%39 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%40 = call i32 @freeifaddrs(%struct.ifaddrs* %39)
ret i32 0
}

LLVM IR (-O2):
%struct.ifaddrs = type { i8*, %struct.TYPE_2__*, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i64 }
@AF_INET = global i64 0
@.str = [27 x i8] c"Interface: %s\09Address: %s\0A\00"
define i32 @main() {
%1 = alloca %struct.ifaddrs*
%2 = bitcast %struct.ifaddrs** %1 to i8*
%3 = call i32 @getifaddrs(%struct.ifaddrs** %1)
%4 = load %struct.ifaddrs*, %struct.ifaddrs** %1
%5 = icmp eq %struct.ifaddrs* %4, null
br i1 %5, label %30, label %6
6: ; preds = %0
%7 = load i64, i64* @AF_INET
br label %8
8: ; preds = %6, %23
%9 = phi i64 [ %24, %23 ], [ %7, %6 ]
%10 = phi %struct.ifaddrs* [ %26, %23 ], [ %4, %6 ]
%11 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %10, i64 0, i32 1
%12 = load %struct.TYPE_2__*, %struct.TYPE_2__** %11
%13 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %12, i64 0, i32 0
%14 = load i64, i64* %13
%15 = icmp eq i64 %14, %9
br i1 %15, label %16, label %23
16: ; preds = %8
%17 = trunc i64 %14 to i32
%18 = call i8* @inet_ntoa(i32 %17)
%19 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %10, i64 0, i32 0
%20 = load i8*, i8** %19
%21 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %20, i8* %18)
%22 = load i64, i64* @AF_INET
br label %23
23: ; preds = %8, %16
%24 = phi i64 [ %9, %8 ], [ %22, %16 ]
%25 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %10, i64 0, i32 2
%26 = load %struct.ifaddrs*, %struct.ifaddrs** %25
%27 = icmp eq %struct.ifaddrs* %26, null
br i1 %27, label %28, label %8
28: ; preds = %23
%29 = load %struct.ifaddrs*, %struct.ifaddrs** %1
br label %30
30: ; preds = %28, %0
%31 = phi %struct.ifaddrs* [ %29, %28 ], [ null, %0 ]
%32 = call i32 @freeifaddrs(%struct.ifaddrs* %31)
ret i32 0
}