#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() {
  struct if_nameindex *t = if_nameindex();
  if (t) {
    struct if_nameindex *t1 = t;
    while (t->if_index) {
      printf("index %u: \"%s\"\n", t->if_index, t->if_name);
      ++t;
    }
    if_freenameindex(t1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <if_nameindex@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119e <main+0x6e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
je     1195 <main+0x65>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
jmp    115d <main+0x2d>
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>
test   %rax,%rax
je     117e <main+0x4e>
mov    %rax,%r14
mov    (%rax),%esi
test   %esi,%esi
je     1176 <main+0x46>
mov    %r14,%rbx
add    $0x10,%rbx
lea    0xea8(%rip),%r15
nopl   0x0(%rax,%rax,1)
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 = [16 x i8] c"index %u: \22%s\22\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.if_nameindex*
%3 = alloca %struct.if_nameindex*
store i32 0, i32* %1
%4 = call %struct.if_nameindex* (...) @if_nameindex()
store %struct.if_nameindex* %4, %struct.if_nameindex** %2
%5 = load %struct.if_nameindex*, %struct.if_nameindex** %2
%6 = icmp ne %struct.if_nameindex* %5, null
br i1 %6, label %7, label %27
7: ; preds = %0
%8 = load %struct.if_nameindex*, %struct.if_nameindex** %2
store %struct.if_nameindex* %8, %struct.if_nameindex** %3
br label %9
9: ; preds = %14, %7
%10 = load %struct.if_nameindex*, %struct.if_nameindex** %2
%11 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %9
%15 = load %struct.if_nameindex*, %struct.if_nameindex** %2
%16 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %15, i32 0, i32 0
%17 = load i32, i32* %16
%18 = load %struct.if_nameindex*, %struct.if_nameindex** %2
%19 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %18, i32 0, i32 1
%20 = load i8*, i8** %19
%21 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %17, i8* %20)
%22 = load %struct.if_nameindex*, %struct.if_nameindex** %2
%23 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %22, i32 1
store %struct.if_nameindex* %23, %struct.if_nameindex** %2
br label %9
24: ; preds = %9
%25 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%26 = call i32 @if_freenameindex(%struct.if_nameindex* %25)
br label %27
27: ; preds = %24, %0
ret i32 0
}

LLVM IR (-O2):
%struct.if_nameindex = type { i32, i8* }
@.str = [16 x i8] c"index %u: \22%s\22\0A\00"
define i32 @main() {
%1 = tail call %struct.if_nameindex* (...) @if_nameindex()
%2 = icmp eq %struct.if_nameindex* %1, null
br i1 %2, label %19, label %3
3: ; preds = %0
%4 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %1, i64 0, i32 0
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %3, %7
%8 = phi i32 [ %15, %7 ], [ %5, %3 ]
%9 = phi %struct.if_nameindex* [ %13, %7 ], [ %1, %3 ]
%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 ([16 x i8], [16 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, %3
%18 = tail call i32 @if_freenameindex(%struct.if_nameindex* %1)
br label %19
19: ; preds = %17, %0
ret i32 0
}