#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;
  struct ifaddrs *ifa_next;
  TYPE_1__ *ifa_addr;
};
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 *addrs;
  struct ifaddrs *tmp;
  getifaddrs(&addrs);
  tmp = addrs;
  while (tmp) {
    if (tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_INET) {
      struct sockaddr_in *pAddr = (struct sockaddr_in *)tmp->ifa_addr;
      printf("%s: %s\n", tmp->ifa_name, inet_ntoa(pAddr->sin_addr));
    }
    tmp = tmp->ifa_next;
  }
  freeifaddrs(addrs);
}


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     11db <main+0x9b>
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     11ca <main+0x8a>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%rax
mov    0x2e5c(%rip),%rcx
cmp    (%rcx),%rax
jne    11ca <main+0x8a>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
call   1030 <inet_ntoa@plt>
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1160 <main+0x20>
mov    -0x10(%rbp),%rdi
call   1060 <freeifaddrs@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsp,%rdi
call   1050 <getifaddrs@plt>
mov    (%rsp),%rbx
test   %rbx,%rbx
je     11a9 <main+0x69>
mov    0x2e88(%rip),%r12
lea    0xe99(%rip),%r14
jmp    1179 <main+0x39>
nopl   0x0(%rax)
mov    0x8(%rbx),%rbx
test   %rbx,%rbx
je     11a3 <main+0x63>
mov    0x10(%rbx),%rax
test   %rax,%rax
je     1170 <main+0x30>
mov    (%rax),%rdi
cmp    (%r12),%rdi
jne    1170 <main+0x30>
mov    (%rbx),%r15
call   1030 <inet_ntoa@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1040 <printf@plt>
jmp    1170 <main+0x30>
mov    (%rsp),%rdi
jmp    11ab <main+0x6b>
xor    %edi,%edi
call   1060 <freeifaddrs@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.ifaddrs = type { i8*, %struct.ifaddrs*, %struct.TYPE_2__* }
%struct.TYPE_2__ = type { i64 }
@AF_INET = global i64 0
@.str = [8 x i8] c"%s: %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 %28, label %6
6: ; preds = %0, %22
%7 = phi %struct.ifaddrs* [ %24, %22 ], [ %4, %0 ]
%8 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %7, i64 0, i32 2
%9 = load %struct.TYPE_2__*, %struct.TYPE_2__** %8
%10 = icmp eq %struct.TYPE_2__* %9, null
br i1 %10, label %22, label %11
11: ; preds = %6
%12 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %9, i64 0, i32 0
%13 = load i64, i64* %12
%14 = load i64, i64* @AF_INET
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %22
16: ; preds = %11
%17 = trunc i64 %13 to i32
%18 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %7, i64 0, i32 0
%19 = load i8*, i8** %18
%20 = call i8* @inet_ntoa(i32 %17)
%21 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %20)
br label %22
22: ; preds = %16, %11, %6
%23 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %7, i64 0, i32 1
%24 = load %struct.ifaddrs*, %struct.ifaddrs** %23
%25 = icmp eq %struct.ifaddrs* %24, null
br i1 %25, label %26, label %6
26: ; preds = %22
%27 = load %struct.ifaddrs*, %struct.ifaddrs** %1
br label %28
28: ; preds = %26, %0
%29 = phi %struct.ifaddrs* [ %27, %26 ], [ null, %0 ]
%30 = call i32 @freeifaddrs(%struct.ifaddrs* %29)
ret i32 0
}