#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 */
struct node *create_tree();
struct node *tree_add_left(struct node *);
struct node *tree_add_right(struct node *);
int /*<<< orphan*/ tree_dispose(struct node *);
struct node *tree_get_parent(struct node *);
int main() {
  struct node *root = create_tree();
  struct node *left = tree_add_left(root);
  struct node *leftRight = tree_add_right(left);
  struct node *leftRightParent = tree_get_parent(leftRight);
  struct node *leftLeft = tree_add_left(left);
  struct node *leftRightRight = tree_add_right(leftRight);
  tree_dispose(root);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <create_tree@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <tree_add_left@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <tree_add_right@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <tree_get_parent@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <tree_add_left@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <tree_add_right@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <tree_dispose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <create_tree@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <tree_add_left@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1070 <tree_add_right@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <tree_get_parent@plt>
mov    %r15,%rdi
call   1030 <tree_add_left@plt>
mov    %rbx,%rdi
call   1070 <tree_add_right@plt>
mov    %r14,%rdi
call   1060 <tree_dispose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.node = type { i32 }
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.node*
%3 = alloca %struct.node*
%4 = alloca %struct.node*
%5 = alloca %struct.node*
%6 = alloca %struct.node*
%7 = alloca %struct.node*
store i32 0, i32* %1
%8 = call %struct.node* (...) @create_tree()
store %struct.node* %8, %struct.node** %2
%9 = load %struct.node*, %struct.node** %2
%10 = call %struct.node* @tree_add_left(%struct.node* %9)
store %struct.node* %10, %struct.node** %3
%11 = load %struct.node*, %struct.node** %3
%12 = call %struct.node* @tree_add_right(%struct.node* %11)
store %struct.node* %12, %struct.node** %4
%13 = load %struct.node*, %struct.node** %4
%14 = call %struct.node* @tree_get_parent(%struct.node* %13)
store %struct.node* %14, %struct.node** %5
%15 = load %struct.node*, %struct.node** %3
%16 = call %struct.node* @tree_add_left(%struct.node* %15)
store %struct.node* %16, %struct.node** %6
%17 = load %struct.node*, %struct.node** %4
%18 = call %struct.node* @tree_add_right(%struct.node* %17)
store %struct.node* %18, %struct.node** %7
%19 = load %struct.node*, %struct.node** %2
%20 = call i32 @tree_dispose(%struct.node* %19)
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
define i32 @main() {
%1 = tail call %struct.node* (...) @create_tree()
%2 = tail call %struct.node* @tree_add_left(%struct.node* %1)
%3 = tail call %struct.node* @tree_add_right(%struct.node* %2)
%4 = tail call %struct.node* @tree_get_parent(%struct.node* %3)
%5 = tail call %struct.node* @tree_add_left(%struct.node* %2)
%6 = tail call %struct.node* @tree_add_right(%struct.node* %3)
%7 = tail call i32 @tree_dispose(%struct.node* %1)
ret i32 0
}