#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 {
  struct if_nameindex *if_name;
  scalar_t__ if_index;
};

/* Variables and functions */
int /*<<< orphan*/ free(struct if_nameindex *);
void if_freenameindex(struct if_nameindex *ifn) {
  struct if_nameindex *ptr = ifn;
  while (ptr->if_name || ptr->if_index) {
    if (ptr->if_name) {
      free(ptr->if_name);
    }
    ++ptr;
  }
  free(ifn);
}


x86 assembly (clang, -O0):
<if_freenameindex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
mov    $0x1,%al
cmpq   $0x0,(%rcx)
mov    %al,-0x11(%rbp)
jne    1146 <if_freenameindex+0x36>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1156 <if_freenameindex+0x46>
jmp    1181 <if_freenameindex+0x71>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1170 <if_freenameindex+0x60>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
jmp    1124 <if_freenameindex+0x14>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<if_freenameindex>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0x8(%rdi),%rbx
jmp    1129 <if_freenameindex+0x19>
nopl   (%rax)
call   1030 <free@plt>
add    $0x10,%rbx
mov    -0x8(%rbx),%rdi
test   %rdi,%rdi
jne    1120 <if_freenameindex+0x10>
cmpq   $0x0,(%rbx)
jne    1125 <if_freenameindex+0x15>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

LLVM IR (-O0):
%struct.if_nameindex = type { %struct.if_nameindex*, i64 }
define void @if_freenameindex(%struct.if_nameindex* %0) {
%2 = alloca %struct.if_nameindex*
%3 = alloca %struct.if_nameindex*
store %struct.if_nameindex* %0, %struct.if_nameindex** %2
%4 = load %struct.if_nameindex*, %struct.if_nameindex** %2
store %struct.if_nameindex* %4, %struct.if_nameindex** %3
br label %5
5: ; preds = %27, %1
%6 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%7 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %6, i32 0, i32 0
%8 = load %struct.if_nameindex*, %struct.if_nameindex** %7
%9 = icmp ne %struct.if_nameindex* %8, null
br i1 %9, label %15, label %10
10: ; preds = %5
%11 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%12 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %11, i32 0, i32 1
%13 = load i64, i64* %12
%14 = icmp ne i64 %13, 0
br label %15
15: ; preds = %10, %5
%16 = phi i1 [ true, %5 ], [ %14, %10 ]
br i1 %16, label %17, label %30
17: ; preds = %15
%18 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%19 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %18, i32 0, i32 0
%20 = load %struct.if_nameindex*, %struct.if_nameindex** %19
%21 = icmp ne %struct.if_nameindex* %20, null
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%24 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %23, i32 0, i32 0
%25 = load %struct.if_nameindex*, %struct.if_nameindex** %24
%26 = call i32 @free(%struct.if_nameindex* %25)
br label %27
27: ; preds = %22, %17
%28 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%29 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %28, i32 1
store %struct.if_nameindex* %29, %struct.if_nameindex** %3
br label %5
30: ; preds = %15
%31 = load %struct.if_nameindex*, %struct.if_nameindex** %2
%32 = call i32 @free(%struct.if_nameindex* %31)
ret void
}

LLVM IR (-O2):
%struct.if_nameindex = type { %struct.if_nameindex*, i64 }
define void @if_freenameindex(%struct.if_nameindex* nocapture %0) {
br label %2
2: ; preds = %13, %1
%3 = phi %struct.if_nameindex* [ %0, %1 ], [ %14, %13 ]
%4 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %3, i64 0, i32 0
%5 = load %struct.if_nameindex*, %struct.if_nameindex** %4
%6 = icmp eq %struct.if_nameindex* %5, null
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %3, i64 0, i32 1
%9 = load i64, i64* %8
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %13
11: ; preds = %2
%12 = tail call i32 @free(%struct.if_nameindex* %5)
br label %13
13: ; preds = %7, %11
%14 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %3, i64 1
br label %2
15: ; preds = %7
%16 = tail call i32 @free(%struct.if_nameindex* %0)
ret void
}