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

/* Variables and functions */
int /*<<< orphan*/ clearStackHLevels(struct StackHLevels *);
int /*<<< orphan*/ free(struct StackHLevels *);
void freeStackHLevels(struct StackHLevels **stack) {
  if (!stack || !*stack)
    return;
  clearStackHLevels(*stack);
  free(*stack);
  *stack = NULL;
}


x86 assembly (clang, -O0):
<freeStackHLevels>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1145 <freeStackHLevels+0x25>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    114a <freeStackHLevels+0x2a>
jmp    116d <freeStackHLevels+0x4d>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1040 <clearStackHLevels@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<freeStackHLevels>:
push   %rbx
test   %rdi,%rdi
je     1145 <freeStackHLevels+0x25>
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1145 <freeStackHLevels+0x25>
call   1040 <clearStackHLevels@plt>
mov    (%rbx),%rdi
call   1030 <free@plt>
movq   $0x0,(%rbx)
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.StackHLevels = type { i32 }
define void @freeStackHLevels(%struct.StackHLevels** %0) {
%2 = icmp eq %struct.StackHLevels** %0, null
br i1 %2, label %10, label %3
3: ; preds = %1
%4 = load %struct.StackHLevels*, %struct.StackHLevels** %0
%5 = icmp eq %struct.StackHLevels* %4, null
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = tail call i32 @clearStackHLevels(%struct.StackHLevels* %4)
%8 = load %struct.StackHLevels*, %struct.StackHLevels** %0
%9 = tail call i32 @free(%struct.StackHLevels* %8)
store %struct.StackHLevels* null, %struct.StackHLevels** %0
br label %10
10: ; preds = %1, %3, %6
ret void
}