#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 avl_tree {
  int dummy;
};
struct avl_node {
  int dummy;
};

/* Variables and functions */
scalar_t__ add_node_avltree(struct avl_tree *, struct avl_node *);
struct avl_node *create_node_avltree(char *, void *);
int /*<<< orphan*/ free_node_complex_avltree(struct avl_node *,
                                             int /*<<< orphan*/ *,
                                             int /*<<< orphan*/ *);
struct avl_node *store_exposed_node_avltree(struct avl_tree *t, char *key,
                                            void *data) {
  struct avl_node *n;
  n = create_node_avltree(key, data);
  if (n == NULL) {
    return NULL;
  }
  if (add_node_avltree(t, n) < 0) {
    free_node_complex_avltree(n, NULL, NULL);
    return NULL;
  }
  return n;
}


x86 assembly (clang, -O0):
<store_exposed_node_avltree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <create_node_avltree@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    116d <store_exposed_node_avltree+0x3d>
movq   $0x0,-0x8(%rbp)
jmp    11a9 <store_exposed_node_avltree+0x79>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <add_node_avltree@plt>
cmp    $0x0,%rax
jge    11a1 <store_exposed_node_avltree+0x71>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1030 <free_node_complex_avltree@plt>
movq   $0x0,-0x8(%rbp)
jmp    11a9 <store_exposed_node_avltree+0x79>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<store_exposed_node_avltree>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1050 <create_node_avltree@plt>
test   %rax,%rax
je     1166 <store_exposed_node_avltree+0x36>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <add_node_avltree@plt>
test   %rax,%rax
jns    1168 <store_exposed_node_avltree+0x38>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <free_node_complex_avltree@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.avl_node = type { i32 }
%struct.avl_tree = type { i32 }
define %struct.avl_node* @store_exposed_node_avltree(%struct.avl_tree* %0, i8* %1, i8* %2) {
%4 = alloca %struct.avl_node*
%5 = alloca %struct.avl_tree*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.avl_node*
store %struct.avl_tree* %0, %struct.avl_tree** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%9 = load i8*, i8** %6
%10 = load i8*, i8** %7
%11 = call %struct.avl_node* @create_node_avltree(i8* %9, i8* %10)
store %struct.avl_node* %11, %struct.avl_node** %8
%12 = load %struct.avl_node*, %struct.avl_node** %8
%13 = icmp eq %struct.avl_node* %12, null
br i1 %13, label %14, label %15
14: ; preds = %3
store %struct.avl_node* null, %struct.avl_node** %4
br label %25
15: ; preds = %3
%16 = load %struct.avl_tree*, %struct.avl_tree** %5
%17 = load %struct.avl_node*, %struct.avl_node** %8
%18 = call i64 @add_node_avltree(%struct.avl_tree* %16, %struct.avl_node* %17)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load %struct.avl_node*, %struct.avl_node** %8
%22 = call i32 @free_node_complex_avltree(%struct.avl_node* %21, i32* null, i32* null)
store %struct.avl_node* null, %struct.avl_node** %4
br label %25
23: ; preds = %15
%24 = load %struct.avl_node*, %struct.avl_node** %8
store %struct.avl_node* %24, %struct.avl_node** %4
br label %25
25: ; preds = %23, %20, %14
%26 = load %struct.avl_node*, %struct.avl_node** %4
ret %struct.avl_node* %26
}

LLVM IR (-O2):
%struct.avl_node = type { i32 }
%struct.avl_tree = type { i32 }
define %struct.avl_node* @store_exposed_node_avltree(%struct.avl_tree* %0, i8* %1, i8* %2) {
%4 = tail call %struct.avl_node* @create_node_avltree(i8* %1, i8* %2)
%5 = icmp eq %struct.avl_node* %4, null
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i64 @add_node_avltree(%struct.avl_tree* %0, %struct.avl_node* %4)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @free_node_complex_avltree(%struct.avl_node* %4, i32* null, i32* null)
br label %11
11: ; preds = %6, %3, %9
%12 = phi %struct.avl_node* [ null, %9 ], [ null, %3 ], [ %4, %6 ]
ret %struct.avl_node* %12
}