#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 */

/* Type definitions */
struct if_nameindex {
  int if_index;
  char *if_name;
};

/* Variables and functions */
int /*<<< orphan*/ if_freenameindex(struct if_nameindex *);
struct if_nameindex *if_nameindex();
int /*<<< orphan*/ printf(char *, int, char *);
int main(int argc, char *argv[]) {
  struct if_nameindex *table, *iface;
  table = if_nameindex();
  for (iface = table; iface->if_index; ++iface) {
    printf("%i: %s\n", iface->if_index, iface->if_name);
  }
  if_freenameindex(table);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <if_nameindex@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
je     1191 <main+0x61>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x20(%rbp)
jmp    1159 <main+0x29>
mov    -0x18(%rbp),%rdi
call   1050 <if_freenameindex@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <if_nameindex@plt>
mov    %rax,%r14
mov    (%rax),%esi
test   %esi,%esi
je     1176 <main+0x46>
mov    %r14,%rbx
add    $0x10,%rbx
lea    0xead(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    -0x8(%rbx),%rdx
mov    %r15,%rdi
call   1030 <printf@plt>
mov    (%rbx),%esi
add    $0x10,%rbx
test   %esi,%esi
jne    1160 <main+0x30>
mov    %r14,%rdi
call   1050 <if_freenameindex@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.if_nameindex = type { i32, i8* }
@.str = [8 x i8] c"%i: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.if_nameindex*
%7 = alloca %struct.if_nameindex*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call %struct.if_nameindex* (...) @if_nameindex()
store %struct.if_nameindex* %8, %struct.if_nameindex** %6
%9 = load %struct.if_nameindex*, %struct.if_nameindex** %6
store %struct.if_nameindex* %9, %struct.if_nameindex** %7
br label %10
10: ; preds = %23, %2
%11 = load %struct.if_nameindex*, %struct.if_nameindex** %7
%12 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %10
%16 = load %struct.if_nameindex*, %struct.if_nameindex** %7
%17 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = load %struct.if_nameindex*, %struct.if_nameindex** %7
%20 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %19, i32 0, i32 1
%21 = load i8*, i8** %20
%22 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %18, i8* %21)
br label %23
23: ; preds = %15
%24 = load %struct.if_nameindex*, %struct.if_nameindex** %7
%25 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %24, i32 1
store %struct.if_nameindex* %25, %struct.if_nameindex** %7
br label %10
26: ; preds = %10
%27 = load %struct.if_nameindex*, %struct.if_nameindex** %6
%28 = call i32 @if_freenameindex(%struct.if_nameindex* %27)
ret i32 0
}

LLVM IR (-O2):
%struct.if_nameindex = type { i32, i8* }
@.str = [8 x i8] c"%i: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call %struct.if_nameindex* (...) @if_nameindex()
%4 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %3, i64 0, i32 0
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %2, %7
%8 = phi i32 [ %15, %7 ], [ %5, %2 ]
%9 = phi %struct.if_nameindex* [ %13, %7 ], [ %3, %2 ]
%10 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %9, i64 0, i32 1
%11 = load i8*, i8** %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %8, i8* %11)
%13 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %9, i64 1
%14 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %13, i64 0, i32 0
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %7
17: ; preds = %7, %2
%18 = tail call i32 @if_freenameindex(%struct.if_nameindex* %3)
ret i32 0
}