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

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ bst_empty(struct bst *);
int /*<<< orphan*/ bst_remove(struct bst **const, void *,
                              int (*)(void const *, void const *));
void *bst_rightmost(struct bst *);
void bst_destroy_without_free(struct bst **const t,
                              int (*compar)(const void *, const void *)) {
  void *data = NULL;
  assert(t != NULL);
  while (!bst_empty(*t)) {
    data = bst_rightmost(*t);
    bst_remove(t, data, compar);
  }
}


x86 assembly (clang, -O0):
<bst_destroy_without_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1040 <bst_empty@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    118b <bst_destroy_without_free+0x4b>
jmp    11b1 <bst_destroy_without_free+0x71>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1060 <bst_rightmost@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <bst_remove@plt>
jmp    116a <bst_destroy_without_free+0x2a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bst_destroy_without_free>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1050 <assert@plt>
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%rdi
call   1040 <bst_empty@plt>
test   %eax,%eax
jne    1184 <bst_destroy_without_free+0x44>
mov    (%rbx),%rdi
call   1060 <bst_rightmost@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
call   1030 <bst_remove@plt>
jmp    1160 <bst_destroy_without_free+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.bst = type { i32 }
define void @bst_destroy_without_free(%struct.bst** %0, i32 (i8*, i8*)* %1) {
%3 = alloca %struct.bst**
%4 = alloca i32 (i8*, i8*)*
%5 = alloca i8*
store %struct.bst** %0, %struct.bst*** %3
store i32 (i8*, i8*)* %1, i32 (i8*, i8*)** %4
store i8* null, i8** %5
%6 = load %struct.bst**, %struct.bst*** %3
%7 = icmp ne %struct.bst** %6, null
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
br label %10
10: ; preds = %16, %2
%11 = load %struct.bst**, %struct.bst*** %3
%12 = load %struct.bst*, %struct.bst** %11
%13 = call i32 @bst_empty(%struct.bst* %12)
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
br i1 %15, label %16, label %24
16: ; preds = %10
%17 = load %struct.bst**, %struct.bst*** %3
%18 = load %struct.bst*, %struct.bst** %17
%19 = call i8* @bst_rightmost(%struct.bst* %18)
store i8* %19, i8** %5
%20 = load %struct.bst**, %struct.bst*** %3
%21 = load i8*, i8** %5
%22 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %4
%23 = call i32 @bst_remove(%struct.bst** %20, i8* %21, i32 (i8*, i8*)* %22)
br label %10
24: ; preds = %10
ret void
}

LLVM IR (-O2):
%struct.bst = type { i32 }
define void @bst_destroy_without_free(%struct.bst** %0, i32 (i8*, i8*)* %1) {
%3 = icmp ne %struct.bst** %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = load %struct.bst*, %struct.bst** %0
%7 = tail call i32 @bst_empty(%struct.bst* %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %2, %9
%10 = load %struct.bst*, %struct.bst** %0
%11 = tail call i8* @bst_rightmost(%struct.bst* %10)
%12 = tail call i32 @bst_remove(%struct.bst** %0, i8* %11, i32 (i8*, i8*)* %1)
%13 = load %struct.bst*, %struct.bst** %0
%14 = tail call i32 @bst_empty(%struct.bst* %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %9, label %16
16: ; preds = %9, %2
ret void
}