#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 */
typedef void bee_tree;
struct bee_subtree {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(void *);
int /*<<< orphan*/ bee_subtree_delete_node(void *, struct bee_subtree *);
struct bee_subtree *bee_tree_search_node_by_key(void *, void *);
void *bee_tree_delete(struct bee_tree *tree, void *key) {
  struct bee_subtree *node;
  assert(tree);
  assert(key);
  node = bee_tree_search_node_by_key(tree, key);
  if (node)
    bee_subtree_delete_node(tree, node);
  return NULL;
}


x86 assembly (clang, -O0):
<bee_tree_delete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <bee_tree_search_node_by_key@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     117b <bee_tree_delete+0x4b>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <bee_subtree_delete_node@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bee_tree_delete>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
call   1040 <assert@plt>
mov    %rbx,%rdi
call   1040 <assert@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <bee_tree_search_node_by_key@plt>
test   %rax,%rax
je     1162 <bee_tree_delete+0x32>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <bee_subtree_delete_node@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.bee_tree = type opaque
%struct.bee_subtree = type { i32 }
define i8* @bee_tree_delete(%struct.bee_tree* %0, i8* %1) {
%3 = alloca %struct.bee_tree*
%4 = alloca i8*
%5 = alloca %struct.bee_subtree*
store %struct.bee_tree* %0, %struct.bee_tree** %3
store i8* %1, i8** %4
%6 = load %struct.bee_tree*, %struct.bee_tree** %3
%7 = bitcast %struct.bee_tree* %6 to i8*
%8 = call i32 @assert(i8* %7)
%9 = load i8*, i8** %4
%10 = call i32 @assert(i8* %9)
%11 = load %struct.bee_tree*, %struct.bee_tree** %3
%12 = bitcast %struct.bee_tree* %11 to i8*
%13 = load i8*, i8** %4
%14 = call %struct.bee_subtree* @bee_tree_search_node_by_key(i8* %12, i8* %13)
store %struct.bee_subtree* %14, %struct.bee_subtree** %5
%15 = load %struct.bee_subtree*, %struct.bee_subtree** %5
%16 = icmp ne %struct.bee_subtree* %15, null
br i1 %16, label %17, label %22
17: ; preds = %2
%18 = load %struct.bee_tree*, %struct.bee_tree** %3
%19 = bitcast %struct.bee_tree* %18 to i8*
%20 = load %struct.bee_subtree*, %struct.bee_subtree** %5
%21 = call i32 @bee_subtree_delete_node(i8* %19, %struct.bee_subtree* %20)
br label %22
22: ; preds = %17, %2
ret i8* null
}

LLVM IR (-O2):
%struct.bee_tree = type opaque
%struct.bee_subtree = type { i32 }
define noalias i8* @bee_tree_delete(%struct.bee_tree* %0, i8* %1) {
%3 = bitcast %struct.bee_tree* %0 to i8*
%4 = tail call i32 @assert(i8* %3)
%5 = tail call i32 @assert(i8* %1)
%6 = tail call %struct.bee_subtree* @bee_tree_search_node_by_key(i8* %3, i8* %1)
%7 = icmp eq %struct.bee_subtree* %6, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @bee_subtree_delete_node(i8* %3, %struct.bee_subtree* %6)
br label %10
10: ; preds = %8, %2
ret i8* null
}