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

/* Variables and functions */
int /*<<< orphan*/ avl_destroy(struct node *);
struct node *avl_insert_node(struct node **, struct node *, int);
int /*<<< orphan*/ print_tree(struct node *);
int /*<<< orphan*/ printf(char *);
int main() {
  int array[10] = {2, 4, 23, 15, 98, 34, 66, 75, 41, 17};
  int temp = 0;
  struct node *root;
  root = NULL;
  for (temp = 0; temp < 10; temp++) {
    root = avl_insert_node(&root, root, array[temp]);
  }
  if (root == NULL) {
    printf("insert failed!\nProcess end!\n");
  }
  print_tree(root);
  avl_destroy(root);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe96(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x34(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    11bb <main+0x6b>
mov    -0x40(%rbp),%rsi
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    -0x40(%rbp),%rdi
call   1030 <avl_insert_node@plt>
mov    %rax,-0x40(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    118a <main+0x3a>
cmpq   $0x0,-0x40(%rbp)
jne    11d2 <main+0x82>
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1070 <print_tree@plt>
mov    -0x40(%rbp),%rdi
call   1060 <avl_destroy@plt>
xor    %eax,%eax
add    $0x40,%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
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <avl_insert_node@plt>
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x4,%edx
call   1040 <avl_insert_node@plt>
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x17,%edx
call   1040 <avl_insert_node@plt>
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0xf,%edx
call   1040 <avl_insert_node@plt>
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x62,%edx
call   1040 <avl_insert_node@plt>
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x22,%edx
call   1040 <avl_insert_node@plt>
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x42,%edx
call   1040 <avl_insert_node@plt>
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x4b,%edx
call   1040 <avl_insert_node@plt>
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x29,%edx
call   1040 <avl_insert_node@plt>
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x11,%edx
call   1040 <avl_insert_node@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
jne    123a <main+0xfa>
lea    0xdd0(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%rax
mov    %rax,%rdi
call   1060 <print_tree@plt>
mov    0x8(%rsp),%rdi
call   1050 <avl_destroy@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@__const.main.array = [10 x i32] [i32 2, i32 4, i32 23, i32 15, i32 98, i32 34, i32 66, i32 75, i32 41, i32 17]
@.str = [29 x i8] c"insert failed!\0AProcess end!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = alloca %struct.node*
store i32 0, i32* %1
%5 = bitcast [10 x i32]* %2 to i8*
store i32 0, i32* %3
store %struct.node* null, %struct.node** %4
store i32 0, i32* %3
br label %6
6: ; preds = %16, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = load %struct.node*, %struct.node** %4
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = call %struct.node* @avl_insert_node(%struct.node** %4, %struct.node* %10, i32 %14)
store %struct.node* %15, %struct.node** %4
br label %16
16: ; preds = %9
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %6
19: ; preds = %6
%20 = load %struct.node*, %struct.node** %4
%21 = icmp eq %struct.node* %20, null
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
%25 = load %struct.node*, %struct.node** %4
%26 = call i32 @print_tree(%struct.node* %25)
%27 = load %struct.node*, %struct.node** %4
%28 = call i32 @avl_destroy(%struct.node* %27)
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
@str = [28 x i8] c"insert failed!\0AProcess end!\00"
define i32 @main() {
%1 = alloca %struct.node*
%2 = bitcast %struct.node** %1 to i8*
store %struct.node* null, %struct.node** %1
%3 = call %struct.node* @avl_insert_node(%struct.node** %1, %struct.node* null, i32 2)
store %struct.node* %3, %struct.node** %1
%4 = call %struct.node* @avl_insert_node(%struct.node** %1, %struct.node* %3, i32 4)
store %struct.node* %4, %struct.node** %1
%5 = call %struct.node* @avl_insert_node(%struct.node** %1, %struct.node* %4, i32 23)
store %struct.node* %5, %struct.node** %1
%6 = call %struct.node* @avl_insert_node(%struct.node** %1, %struct.node* %5, i32 15)
store %struct.node* %6, %struct.node** %1
%7 = call %struct.node* @avl_insert_node(%struct.node** %1, %struct.node* %6, i32 98)
store %struct.node* %7, %struct.node** %1
%8 = call %struct.node* @avl_insert_node(%struct.node** %1, %struct.node* %7, i32 34)
store %struct.node* %8, %struct.node** %1
%9 = call %struct.node* @avl_insert_node(%struct.node** %1, %struct.node* %8, i32 66)
store %struct.node* %9, %struct.node** %1
%10 = call %struct.node* @avl_insert_node(%struct.node** %1, %struct.node* %9, i32 75)
store %struct.node* %10, %struct.node** %1
%11 = call %struct.node* @avl_insert_node(%struct.node** %1, %struct.node* %10, i32 41)
store %struct.node* %11, %struct.node** %1
%12 = call %struct.node* @avl_insert_node(%struct.node** %1, %struct.node* %11, i32 17)
store %struct.node* %12, %struct.node** %1
%13 = icmp eq %struct.node* %12, null
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%16 = load %struct.node*, %struct.node** %1
br label %17
17: ; preds = %14, %0
%18 = phi %struct.node* [ %16, %14 ], [ %12, %0 ]
%19 = call i32 @print_tree(%struct.node* %18)
%20 = load %struct.node*, %struct.node** %1
%21 = call i32 @avl_destroy(%struct.node* %20)
ret i32 0
}