#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 *createTree(int *, int *, int, int);
int /*<<< orphan*/ inorder(struct node *);
int /*<<< orphan*/ levelOrder(struct node *);
int /*<<< orphan*/ nonRecursiveInorder(struct node *);
int /*<<< orphan*/ nonRecursivePreorder(struct node *);
int /*<<< orphan*/ postorder(struct node *);
int /*<<< orphan*/ preorder(struct node *);
int /*<<< orphan*/ printf(char *);
int main() {
  int in[] = {4, 8, 2, 5, 1, 6, 3, 7};
  int post[] = {8, 4, 5, 2, 6, 7, 3, 1};
  int n = 8;
  int t = 1;
  struct node *root = createTree(post, in, n, t);
  printf("\nPREOREDER TRAVERSAL--------------\n\n\n\n");
  preorder(root);
  printf("\nNON recursive preorder\n");
  nonRecursivePreorder(root);
  printf("\n\nINOREDER TRAVERSAL--------------\n\n\n\n");
  inorder(root);
  printf("\nNON recursive inorder\n");
  nonRecursiveInorder(root);
  printf("\n\nPOSTOREDER TRAVERSAL--------------\n\n\n\n");
  postorder(root);
  printf("\nLEVEL ORDER TRAVERSAL--------------\n");
  levelOrder(root);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0xe71(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe6e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe6b(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xe68(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    0xe65(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe62(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe5f(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe5c(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x8,-0x44(%rbp)
movl   $0x1,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    -0x44(%rbp),%edx
mov    -0x48(%rbp),%ecx
call   1030 <createTree@plt>
mov    %rax,-0x50(%rbp)
lea    0xe34(%rip),%rdi
call   1070 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1060 <preorder@plt>
lea    0xe46(%rip),%rdi
call   1070 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1040 <nonRecursivePreorder@plt>
lea    0xe4a(%rip),%rdi
call   1070 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1090 <inorder@plt>
lea    0xe5c(%rip),%rdi
call   1070 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1050 <nonRecursiveInorder@plt>
lea    0xe5f(%rip),%rdi
call   1070 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1080 <postorder@plt>
lea    0xe73(%rip),%rdi
call   1070 <printf@plt>
mov    -0x50(%rbp),%rdi
call   10a0 <levelOrder@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movaps 0xe84(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe68(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe8c(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe70(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
lea    0x20(%rsp),%rsi
mov    $0x8,%edx
mov    $0x1,%ecx
call   1030 <createTree@plt>
mov    %rax,%rbx
lea    0xe6b(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1070 <preorder@plt>
lea    0xe7d(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1040 <nonRecursivePreorder@plt>
lea    0xe81(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1090 <inorder@plt>
lea    0xe93(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1060 <nonRecursiveInorder@plt>
lea    0xe96(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1080 <postorder@plt>
lea    0xeaa(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   10a0 <levelOrder@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@__const.main.in = [8 x i32] [i32 4, i32 8, i32 2, i32 5, i32 1, i32 6, i32 3, i32 7]
@__const.main.post = [8 x i32] [i32 8, i32 4, i32 5, i32 2, i32 6, i32 7, i32 3, i32 1]
@.str = [39 x i8] c"\0APREOREDER TRAVERSAL--------------\0A\0A\0A\0A\00"
@.str.1 = [25 x i8] c"\0ANON recursive preorder\0A\00"
@.str.2 = [39 x i8] c"\0A\0AINOREDER TRAVERSAL--------------\0A\0A\0A\0A\00"
@.str.3 = [24 x i8] c"\0ANON recursive inorder\0A\00"
@.str.4 = [41 x i8] c"\0A\0APOSTOREDER TRAVERSAL--------------\0A\0A\0A\0A\00"
@.str.5 = [38 x i8] c"\0ALEVEL ORDER TRAVERSAL--------------\0A\00"
define i32 @main() {
%1 = alloca [8 x i32]
%2 = alloca [8 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.node*
%6 = bitcast [8 x i32]* %1 to i8*
%7 = bitcast [8 x i32]* %2 to i8*
store i32 8, i32* %3
store i32 1, i32* %4
%8 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%9 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = call %struct.node* @createTree(i32* %8, i32* %9, i32 %10, i32 %11)
store %struct.node* %12, %struct.node** %5
%13 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%14 = load %struct.node*, %struct.node** %5
%15 = call i32 @preorder(%struct.node* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%17 = load %struct.node*, %struct.node** %5
%18 = call i32 @nonRecursivePreorder(%struct.node* %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%20 = load %struct.node*, %struct.node** %5
%21 = call i32 @inorder(%struct.node* %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%23 = load %struct.node*, %struct.node** %5
%24 = call i32 @nonRecursiveInorder(%struct.node* %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%26 = load %struct.node*, %struct.node** %5
%27 = call i32 @postorder(%struct.node* %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%29 = load %struct.node*, %struct.node** %5
%30 = call i32 @levelOrder(%struct.node* %29)
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
@__const.main.in = [8 x i32] [i32 4, i32 8, i32 2, i32 5, i32 1, i32 6, i32 3, i32 7]
@__const.main.post = [8 x i32] [i32 8, i32 4, i32 5, i32 2, i32 6, i32 7, i32 3, i32 1]
@str = [38 x i8] c"\0APREOREDER TRAVERSAL--------------\0A\0A\0A\00"
@str.6 = [24 x i8] c"\0ANON recursive preorder\00"
@str.7 = [38 x i8] c"\0A\0AINOREDER TRAVERSAL--------------\0A\0A\0A\00"
@str.8 = [23 x i8] c"\0ANON recursive inorder\00"
@str.9 = [40 x i8] c"\0A\0APOSTOREDER TRAVERSAL--------------\0A\0A\0A\00"
@str.10 = [37 x i8] c"\0ALEVEL ORDER TRAVERSAL--------------\00"
define i32 @main() {
%1 = alloca [8 x i32]
%2 = alloca [8 x i32]
%3 = bitcast [8 x i32]* %1 to i8*
%4 = bitcast [8 x i32]* %2 to i8*
%5 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%6 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%7 = call %struct.node* @createTree(i32* %5, i32* %6, i32 8, i32 1)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%9 = call i32 @preorder(%struct.node* %7)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0))
%11 = call i32 @nonRecursivePreorder(%struct.node* %7)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.7, i64 0, i64 0))
%13 = call i32 @inorder(%struct.node* %7)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0))
%15 = call i32 @nonRecursiveInorder(%struct.node* %7)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.9, i64 0, i64 0))
%17 = call i32 @postorder(%struct.node* %7)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.10, i64 0, i64 0))
%19 = call i32 @levelOrder(%struct.node* %7)
ret i32 0
}