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

/* Variables and functions */
int /*<<< orphan*/ bst_delete(struct bst_node **, int);
int /*<<< orphan*/ bst_insert(struct bst_node **, int);
int /*<<< orphan*/ bst_print(struct bst_node *);
int /*<<< orphan*/ printf(char *, int);
int main() {
  struct bst_node *tree = ((void *)0);
  bst_insert(&tree, 5);
  bst_insert(&tree, 3);
  bst_insert(&tree, 7);
  bst_insert(&tree, 4);
  bst_insert(&tree, 8);
  bst_insert(&tree, 2);
  bst_insert(&tree, 6);
  bst_print(tree);
  printf("delete %i\n", 5);
  bst_delete(&tree, 5);
  bst_print(tree);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0x5,%esi
call   1060 <bst_insert@plt>
lea    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1060 <bst_insert@plt>
lea    -0x10(%rbp),%rdi
mov    $0x7,%esi
call   1060 <bst_insert@plt>
lea    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1060 <bst_insert@plt>
lea    -0x10(%rbp),%rdi
mov    $0x8,%esi
call   1060 <bst_insert@plt>
lea    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1060 <bst_insert@plt>
lea    -0x10(%rbp),%rdi
mov    $0x6,%esi
call   1060 <bst_insert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <bst_print@plt>
lea    0xe37(%rip),%rdi
mov    $0x5,%esi
call   1040 <printf@plt>
lea    -0x10(%rbp),%rdi
mov    $0x5,%esi
call   1050 <bst_delete@plt>
mov    -0x10(%rbp),%rdi
call   1030 <bst_print@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1060 <bst_insert@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1060 <bst_insert@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1060 <bst_insert@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1060 <bst_insert@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1060 <bst_insert@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1060 <bst_insert@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1060 <bst_insert@plt>
mov    0x8(%rsp),%rdi
call   1030 <bst_print@plt>
lea    0xe41(%rip),%rdi
mov    $0x5,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1050 <bst_delete@plt>
mov    0x8(%rsp),%rdi
call   1030 <bst_print@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.bst_node = type { i32 }
@.str = [11 x i8] c"delete %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.bst_node*
store i32 0, i32* %1
store %struct.bst_node* null, %struct.bst_node** %2
%3 = call i32 @bst_insert(%struct.bst_node** %2, i32 5)
%4 = call i32 @bst_insert(%struct.bst_node** %2, i32 3)
%5 = call i32 @bst_insert(%struct.bst_node** %2, i32 7)
%6 = call i32 @bst_insert(%struct.bst_node** %2, i32 4)
%7 = call i32 @bst_insert(%struct.bst_node** %2, i32 8)
%8 = call i32 @bst_insert(%struct.bst_node** %2, i32 2)
%9 = call i32 @bst_insert(%struct.bst_node** %2, i32 6)
%10 = load %struct.bst_node*, %struct.bst_node** %2
%11 = call i32 @bst_print(%struct.bst_node* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 5)
%13 = call i32 @bst_delete(%struct.bst_node** %2, i32 5)
%14 = load %struct.bst_node*, %struct.bst_node** %2
%15 = call i32 @bst_print(%struct.bst_node* %14)
ret i32 0
}

LLVM IR (-O2):
%struct.bst_node = type { i32 }
@.str = [11 x i8] c"delete %i\0A\00"
define i32 @main() {
%1 = alloca %struct.bst_node*
%2 = bitcast %struct.bst_node** %1 to i8*
store %struct.bst_node* null, %struct.bst_node** %1
%3 = call i32 @bst_insert(%struct.bst_node** %1, i32 5)
%4 = call i32 @bst_insert(%struct.bst_node** %1, i32 3)
%5 = call i32 @bst_insert(%struct.bst_node** %1, i32 7)
%6 = call i32 @bst_insert(%struct.bst_node** %1, i32 4)
%7 = call i32 @bst_insert(%struct.bst_node** %1, i32 8)
%8 = call i32 @bst_insert(%struct.bst_node** %1, i32 2)
%9 = call i32 @bst_insert(%struct.bst_node** %1, i32 6)
%10 = load %struct.bst_node*, %struct.bst_node** %1
%11 = call i32 @bst_print(%struct.bst_node* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 5)
%13 = call i32 @bst_delete(%struct.bst_node** %1, i32 5)
%14 = load %struct.bst_node*, %struct.bst_node** %1
%15 = call i32 @bst_print(%struct.bst_node* %14)
ret i32 0
}