#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 navaid {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ destroy_navaid(int /*<<< orphan*/);
int /*<<< orphan*/ free(struct navaid **);
void destroy_cache(struct navaid **cache) {
  struct navaid **p = cache;
  while (*p)
    destroy_navaid(*p++);
  free(cache);
}


x86 assembly (clang, -O0):
<destroy_cache>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1160 <destroy_cache+0x40>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%rax
mov    %eax,%edi
call   1040 <destroy_navaid@plt>
jmp    1134 <destroy_cache+0x14>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<destroy_cache>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1151 <destroy_cache+0x31>
lea    0x8(%r14),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1040 <destroy_navaid@plt>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1140 <destroy_cache+0x20>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

LLVM IR (-O0):
%struct.navaid = type { i32 }
define void @destroy_cache(%struct.navaid** %0) {
%2 = alloca %struct.navaid**
%3 = alloca %struct.navaid**
store %struct.navaid** %0, %struct.navaid*** %2
%4 = load %struct.navaid**, %struct.navaid*** %2
store %struct.navaid** %4, %struct.navaid*** %3
br label %5
5: ; preds = %9, %1
%6 = load %struct.navaid**, %struct.navaid*** %3
%7 = load %struct.navaid*, %struct.navaid** %6
%8 = icmp ne %struct.navaid* %7, null
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = load %struct.navaid**, %struct.navaid*** %3
%11 = getelementptr inbounds %struct.navaid*, %struct.navaid** %10, i32 1
store %struct.navaid** %11, %struct.navaid*** %3
%12 = load %struct.navaid*, %struct.navaid** %10
%13 = ptrtoint %struct.navaid* %12 to i32
%14 = call i32 @destroy_navaid(i32 %13)
br label %5
15: ; preds = %5
%16 = load %struct.navaid**, %struct.navaid*** %2
%17 = call i32 @free(%struct.navaid** %16)
ret void
}

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