#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 */

/* Variables and functions */
int /*<<< orphan*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ inOrder(int *, int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ postOrder(int *, int, int);
int /*<<< orphan*/ preOrder(int *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  int n;
  scanf("%d", &n);
  int *a = (int *)malloc(sizeof(int) * n + 5);
  int i;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  printf("prorder : ");
  preOrder(a, 1, n);
  printf("\ninorder : ");
  inOrder(a, 1, n);
  printf("\npostorder : ");
  postOrder(a, 1, n);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%edx
lea    0xe71(%rip),%rdi
lea    0xe74(%rip),%rsi
call   1050 <freopen@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edx
lea    0xe61(%rip),%rdi
lea    0xe65(%rip),%rsi
call   1050 <freopen@plt>
lea    0xe5b(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
add    $0x5,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     121a <main+0xaa>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe12(%rip),%rdi
call   1080 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e5 <main+0x75>
lea    0xdfb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0x1,%esi
call   1090 <preOrder@plt>
lea    0xde9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0x1,%esi
call   1070 <inOrder@plt>
lea    0xdd8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0x1,%esi
call   1040 <postOrder@plt>
lea    0xdc9(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2e59(%rip),%rax
mov    (%rax),%edx
lea    0xe68(%rip),%rdi
lea    0xe6b(%rip),%rsi
call   1060 <freopen@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edx
lea    0xe58(%rip),%rdi
lea    0xe5c(%rip),%rsi
call   1060 <freopen@plt>
lea    0xe52(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1090 <scanf@plt>
mov    0x4(%rsp),%eax
lea    0x5(,%rax,4),%edi
call   1070 <malloc@plt>
mov    %rax,%r14
cmpl   $0x0,0x4(%rsp)
jle    121d <main+0x9d>
mov    %r14,%r12
add    $0x4,%r12
xor    %ebx,%ebx
lea    0xe1e(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
call   1090 <scanf@plt>
movslq 0x4(%rsp),%rax
add    $0x1,%rbx
add    $0x4,%r12
cmp    %rax,%rbx
jl     1200 <main+0x80>
lea    0xdf8(%rip),%rdi
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    $0x1,%esi
call   10a0 <preOrder@plt>
lea    0xde6(%rip),%rdi
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    $0x1,%esi
call   1080 <inOrder@plt>
lea    0xdd5(%rip),%rdi
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    $0x1,%esi
call   1050 <postOrder@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [11 x i8] c"output.txt\00"
@.str.3 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [11 x i8] c"prorder : \00"
@.str.6 = [12 x i8] c"\0Ainorder : \00"
@.str.7 = [14 x i8] c"\0Apostorder : \00"
@.str.8 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
%5 = load i32, i32* @stdin
%6 = call i32 @freopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @stdout
%8 = call i32 @freopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = mul i64 4, %11
%13 = add i64 %12, 5
%14 = trunc i64 %13 to i32
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i32*
store i32* %16, i32** %3
store i32 1, i32* %4
br label %17
17: ; preds = %27, %0
%18 = load i32, i32* %4
%19 = load i32, i32* %2
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load i32*, i32** %3
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %25)
br label %27
27: ; preds = %21
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %17
30: ; preds = %17
%31 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%32 = load i32*, i32** %3
%33 = load i32, i32* %2
%34 = call i32 @preOrder(i32* %32, i32 1, i32 %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%36 = load i32*, i32** %3
%37 = load i32, i32* %2
%38 = call i32 @inOrder(i32* %36, i32 1, i32 %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%40 = load i32*, i32** %3
%41 = load i32, i32* %2
%42 = call i32 @postOrder(i32* %40, i32 1, i32 %41)
%43 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [11 x i8] c"output.txt\00"
@.str.3 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [11 x i8] c"prorder : \00"
@.str.6 = [12 x i8] c"\0Ainorder : \00"
@.str.7 = [14 x i8] c"\0Apostorder : \00"
define i32 @main() {
%1 = alloca i32
%2 = load i32, i32* @stdin
%3 = tail call i32 @freopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%4 = load i32, i32* @stdout
%5 = tail call i32 @freopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %4)
%6 = bitcast i32* %1 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = shl i32 %8, 2
%10 = add i32 %9, 5
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i32*
%13 = load i32, i32* %1
%14 = icmp slt i32 %13, 1
br i1 %14, label %23, label %15
15: ; preds = %0, %15
%16 = phi i64 [ %19, %15 ], [ 1, %0 ]
%17 = getelementptr inbounds i32, i32* %12, i64 %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %17)
%19 = add nuw nsw i64 %16, 1
%20 = load i32, i32* %1
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %16, %21
br i1 %22, label %15, label %23
23: ; preds = %15, %0
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%25 = load i32, i32* %1
%26 = call i32 @preOrder(i32* %12, i32 1, i32 %25)
%27 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%28 = load i32, i32* %1
%29 = call i32 @inOrder(i32* %12, i32 1, i32 %28)
%30 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%31 = load i32, i32* %1
%32 = call i32 @postOrder(i32* %12, i32 1, i32 %31)
%33 = call i32 @putchar(i32 10)
ret i32 0
}