#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_avltree(struct avl_node *, int /*<<< orphan*/ *);
int store_named_node_avltree(struct avl_tree *t, char *key, void *data) {
  struct avl_node *n;
  n = create_node_avltree(key, data);
  if (n == NULL)
    return -1;
  if (add_node_avltree(t, n) < 0) {
    free_node_avltree(n, NULL);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<store_named_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    116c <store_named_node_avltree+0x3c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a3 <store_named_node_avltree+0x73>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <add_node_avltree@plt>
cmp    $0x0,%rax
jge    119c <store_named_node_avltree+0x6c>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <free_node_avltree@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a3 <store_named_node_avltree+0x73>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<store_named_node_avltree>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1050 <create_node_avltree@plt>
mov    %rax,%rbx
mov    $0xffffffff,%eax
test   %rbx,%rbx
je     1173 <store_named_node_avltree+0x43>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <add_node_avltree@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jns    1173 <store_named_node_avltree+0x43>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <free_node_avltree@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.avl_tree = type { i32 }
%struct.avl_node = type { i32 }
define i32 @store_named_node_avltree(%struct.avl_tree* %0, i8* %1, i8* %2) {
%4 = alloca i32
%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 i32 -1, i32* %4
br label %24
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_avltree(%struct.avl_node* %21, i32* null)
store i32 -1, i32* %4
br label %24
23: ; preds = %15
store i32 0, i32* %4
br label %24
24: ; preds = %23, %20, %14
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
%struct.avl_tree = type { i32 }
%struct.avl_node = type { i32 }
define i32 @store_named_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_avltree(%struct.avl_node* %4, i32* null)
br label %11
11: ; preds = %6, %3, %9
%12 = phi i32 [ -1, %9 ], [ -1, %3 ], [ 0, %6 ]
ret i32 %12
}