#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 *node = create_tree();
  node = tree_add_left(node);
  node = tree_add_right(node);
  node = tree_get_parent(node);
  node = tree_add_left(node);
  node = tree_get_parent(node);
  node = tree_get_parent(node);
  tree_dispose(node);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%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,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <tree_add_right@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <tree_get_parent@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <tree_add_left@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <tree_get_parent@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <tree_get_parent@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <tree_dispose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

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