#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*/ assert(int /*<<< orphan*/);
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();
  assert(t != NULL);
  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   1050 <if_nameindex@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
je     11c0 <main+0x80>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
je     11b7 <main+0x77>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
jmp    117f <main+0x3f>
mov    -0x18(%rbp),%rdi
call   1060 <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   1050 <if_nameindex@plt>
mov    %rax,%r14
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1040 <assert@plt>
test   %r14,%r14
je     119e <main+0x5e>
mov    (%r14),%esi
test   %esi,%esi
je     1196 <main+0x56>
mov    %r14,%rbx
add    $0x10,%rbx
lea    0xe89(%rip),%r15
nopw   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    1180 <main+0x40>
mov    %r14,%rdi
call   1060 <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
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load %struct.if_nameindex*, %struct.if_nameindex** %2
%10 = icmp ne %struct.if_nameindex* %9, null
br i1 %10, label %11, label %31
11: ; preds = %0
%12 = load %struct.if_nameindex*, %struct.if_nameindex** %2
store %struct.if_nameindex* %12, %struct.if_nameindex** %3
br label %13
13: ; preds = %18, %11
%14 = load %struct.if_nameindex*, %struct.if_nameindex** %2
%15 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %13
%19 = load %struct.if_nameindex*, %struct.if_nameindex** %2
%20 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = load %struct.if_nameindex*, %struct.if_nameindex** %2
%23 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %22, i32 0, i32 1
%24 = load i8*, i8** %23
%25 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %21, i8* %24)
%26 = load %struct.if_nameindex*, %struct.if_nameindex** %2
%27 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %26, i32 1
store %struct.if_nameindex* %27, %struct.if_nameindex** %2
br label %13
28: ; preds = %13
%29 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%30 = call i32 @if_freenameindex(%struct.if_nameindex* %29)
br label %31
31: ; preds = %28, %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 ne %struct.if_nameindex* %1, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
br i1 %2, label %5, label %21
5: ; preds = %0
%6 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %1, i64 0, i32 0
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %5, %9
%10 = phi i32 [ %17, %9 ], [ %7, %5 ]
%11 = phi %struct.if_nameindex* [ %15, %9 ], [ %1, %5 ]
%12 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %11, i64 0, i32 1
%13 = load i8*, i8** %12
%14 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %10, i8* %13)
%15 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %11, i64 1
%16 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %15, i64 0, i32 0
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %9
19: ; preds = %9, %5
%20 = tail call i32 @if_freenameindex(%struct.if_nameindex* %1)
br label %21
21: ; preds = %19, %0
ret i32 0
}