#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*/ inorder(struct node *);
struct node *insert(struct node *, int);
int /*<<< orphan*/ postorder(struct node *);
int /*<<< orphan*/ preorder(struct node *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int i, item;
  struct node *root = NULL;
  long int n;
  scanf("%ld", &n);
  scanf("%d", &item);
  root = insert(root, item);
  for (i = 1; i < n; i++) {
    scanf("%d", &item);
    insert(root, item);
  }
  inorder(root);
  printf("\n");
  preorder(root);
  printf("\n");
  postorder(root);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe82(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xe74(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1080 <insert@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x8(%rbp)
movslq -0x8(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    11ec <main+0x8c>
lea    0xe3d(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1080 <insert@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b2 <main+0x52>
mov    -0x18(%rbp),%rdi
call   1060 <inorder@plt>
lea    0xe0b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <preorder@plt>
lea    0xdf6(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <postorder@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe8e(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xe7f(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0xc(%rsp),%esi
xor    %edi,%edi
call   1080 <insert@plt>
mov    %rax,%r12
cmpq   $0x2,0x10(%rsp)
jl     11e4 <main+0x84>
mov    $0x1,%ebx
lea    0xe51(%rip),%r14
lea    0xc(%rsp),%r15
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %r12,%rdi
call   1080 <insert@plt>
add    $0x1,%rbx
cmp    %rbx,0x10(%rsp)
jg     11c0 <main+0x60>
mov    %r12,%rdi
call   1060 <inorder@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12,%rdi
call   1040 <preorder@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12,%rdi
call   1050 <postorder@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [4 x i8] c"%ld\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.node*
%5 = alloca i64
store i32 0, i32* %1
store %struct.node* null, %struct.node** %4
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %5)
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = load %struct.node*, %struct.node** %4
%9 = load i32, i32* %3
%10 = call %struct.node* @insert(%struct.node* %8, i32 %9)
store %struct.node* %10, %struct.node** %4
store i32 1, i32* %2
br label %11
11: ; preds = %21, %0
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = load i64, i64* %5
%15 = icmp slt i64 %13, %14
br i1 %15, label %16, label %24
16: ; preds = %11
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%18 = load %struct.node*, %struct.node** %4
%19 = load i32, i32* %3
%20 = call %struct.node* @insert(%struct.node* %18, i32 %19)
br label %21
21: ; preds = %16
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
store i32 %23, i32* %2
br label %11
24: ; preds = %11
%25 = load %struct.node*, %struct.node** %4
%26 = call i32 @inorder(%struct.node* %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%28 = load %struct.node*, %struct.node** %4
%29 = call i32 @preorder(%struct.node* %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%31 = load %struct.node*, %struct.node** %4
%32 = call i32 @postorder(%struct.node* %31)
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str = [4 x i8] c"%ld\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = bitcast i32* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = call %struct.node* @insert(%struct.node* null, i32 %7)
%9 = load i64, i64* %2
%10 = icmp sgt i64 %9, 1
br i1 %10, label %11, label %19
11: ; preds = %0, %11
%12 = phi i64 [ %16, %11 ], [ 1, %0 ]
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
%15 = call %struct.node* @insert(%struct.node* %8, i32 %14)
%16 = add nuw nsw i64 %12, 1
%17 = load i64, i64* %2
%18 = icmp sgt i64 %17, %16
br i1 %18, label %11, label %19
19: ; preds = %11, %0
%20 = call i32 @inorder(%struct.node* %8)
%21 = call i32 @putchar(i32 10)
%22 = call i32 @preorder(%struct.node* %8)
%23 = call i32 @putchar(i32 10)
%24 = call i32 @postorder(%struct.node* %8)
ret i32 0
}