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

/* Variables and functions */
scalar_t__ NULL_PTR_P(struct binary_search_tree **);
int /*<<< orphan*/
binary_search_tree_destroy_internal(struct binary_search_tree **);
scalar_t__ binary_search_tree_structure_legal_p(struct binary_search_tree *);
void binary_search_tree_destroy(struct binary_search_tree **tree) {
  if (NULL_PTR_P(tree)) {
    return;
  } else if (binary_search_tree_structure_legal_p(*tree)) {
    binary_search_tree_destroy_internal(tree);
  }
}


x86 assembly (clang, -O0):
<binary_search_tree_destroy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <NULL_PTR_P@plt>
cmp    $0x0,%rax
je     1154 <binary_search_tree_destroy+0x24>
jmp    1178 <binary_search_tree_destroy+0x48>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <binary_search_tree_structure_legal_p@plt>
cmp    $0x0,%rax
je     1173 <binary_search_tree_destroy+0x43>
mov    -0x8(%rbp),%rdi
call   1050 <binary_search_tree_destroy_internal@plt>
jmp    1178 <binary_search_tree_destroy+0x48>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binary_search_tree_destroy>:
push   %rbx
mov    %rdi,%rbx
call   1040 <NULL_PTR_P@plt>
test   %rax,%rax
je     1140 <binary_search_tree_destroy+0x10>
pop    %rbx
ret
mov    (%rbx),%rdi
call   1030 <binary_search_tree_structure_legal_p@plt>
test   %rax,%rax
je     113e <binary_search_tree_destroy+0xe>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <binary_search_tree_destroy_internal@plt>

LLVM IR (-O0):
%struct.binary_search_tree = type { i32 }
define void @binary_search_tree_destroy(%struct.binary_search_tree** %0) {
%2 = alloca %struct.binary_search_tree**
store %struct.binary_search_tree** %0, %struct.binary_search_tree*** %2
%3 = load %struct.binary_search_tree**, %struct.binary_search_tree*** %2
%4 = call i64 @NULL_PTR_P(%struct.binary_search_tree** %3)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
br label %16
7: ; preds = %1
%8 = load %struct.binary_search_tree**, %struct.binary_search_tree*** %2
%9 = load %struct.binary_search_tree*, %struct.binary_search_tree** %8
%10 = call i64 @binary_search_tree_structure_legal_p(%struct.binary_search_tree* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load %struct.binary_search_tree**, %struct.binary_search_tree*** %2
%14 = call i32 @binary_search_tree_destroy_internal(%struct.binary_search_tree** %13)
br label %15
15: ; preds = %12, %7
br label %16
16: ; preds = %6, %15
ret void
}

LLVM IR (-O2):
%struct.binary_search_tree = type { i32 }
define void @binary_search_tree_destroy(%struct.binary_search_tree** %0) {
%2 = tail call i64 @NULL_PTR_P(%struct.binary_search_tree** %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = load %struct.binary_search_tree*, %struct.binary_search_tree** %0
%6 = tail call i64 @binary_search_tree_structure_legal_p(%struct.binary_search_tree* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = tail call i32 @binary_search_tree_destroy_internal(%struct.binary_search_tree** %0)
br label %10
10: ; preds = %4, %8, %1
ret void
}