#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 findMax(struct node *);
int findMin(struct node *);
int /*<<< orphan*/ getch();
int /*<<< orphan*/ inOrderTraverse(struct node *);
struct node *insertN(struct node *, int);
int /*<<< orphan*/ postOrderTraverse(struct node *);
int /*<<< orphan*/ preOrderTraverse(struct node *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
scalar_t__ searchNode(struct node *, int);
int main() {
  int i, toLook, nodes;
  int numbers[100];
  struct node *root = NULL;
  printf("\n----- Creating the BST structure -----\n");
  printf("Number of BST nodes: ");
  scanf("%d", &nodes);
  for (i = 0; i < nodes; i++) {
    printf("Node %d: ", i + 1);
    scanf("%d", &numbers[i]);
    root = insertN(root, numbers[i]);
  }
  printf("\n----- Searching -----\n");
  printf("Lookup: ");
  scanf("%d", &toLook);
  if (searchNode(root, toLook))
    printf("Found!\n");
  else
    printf("Not found!\n");
  printf("\n----- Finding Max and Min -----\n");
  int min = findMin(root);
  int max = findMax(root);
  printf("Min: %d\nMax: %d\n", min, max);
  printf("\n----- PreOrder Traverse -----\n");
  preOrderTraverse(root);
  printf("\n----- InOrder Traverse -----\n");
  inOrderTraverse(root);
  printf("\n----- PostOrder Traverse -----\n");
  postOrderTraverse(root);
  getch();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x1a8(%rbp)
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe5f(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   10a0 <scanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    125a <main+0xba>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movslq -0x8(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe16(%rip),%rdi
call   10a0 <scanf@plt>
mov    -0x1a8(%rbp),%rdi
movslq -0x8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
call   1050 <insertN@plt>
mov    %rax,-0x1a8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11f0 <main+0x50>
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdc2(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0x1a8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <searchNode@plt>
cmp    $0x0,%rax
je     12b2 <main+0x112>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12c0 <main+0x120>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1a8(%rbp),%rdi
call   1080 <findMin@plt>
mov    %eax,-0x1ac(%rbp)
mov    -0x1a8(%rbp),%rdi
call   10c0 <findMax@plt>
mov    %eax,-0x1b0(%rbp)
mov    -0x1ac(%rbp),%esi
mov    -0x1b0(%rbp),%edx
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1a8(%rbp),%rdi
call   1030 <preOrderTraverse@plt>
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1a8(%rbp),%rdi
call   1070 <inOrderTraverse@plt>
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1a8(%rbp),%rdi
call   1090 <postOrderTraverse@plt>
mov    $0x0,%al
call   10b0 <getch@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a0,%rsp
lea    0xe76(%rip),%rdi
call   1050 <puts@plt>
lea    0xe2d(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe32(%rip),%rdi
lea    0x8(%rsp),%rsi
call   10b0 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    1248 <main+0x98>
lea    0x10(%rsp),%r13
lea    0xe18(%rip),%r15
lea    0xe0e(%rip),%r12
xor    %ebx,%ebx
xor    %r14d,%r14d
nopl   (%rax)
add    $0x1,%rbx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   10b0 <scanf@plt>
mov    0x0(%r13),%esi
mov    %r14,%rdi
call   1060 <insertN@plt>
mov    %rax,%r14
movslq 0x8(%rsp),%rax
add    $0x4,%r13
cmp    %rax,%rbx
jl     1210 <main+0x60>
lea    0xe16(%rip),%rdi
call   1050 <puts@plt>
lea    0xdc8(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdad(%rip),%rdi
lea    0xc(%rsp),%rsi
call   10b0 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
call   1040 <searchNode@plt>
test   %rax,%rax
lea    0xdf3(%rip),%rax
lea    0xe75(%rip),%rdi
cmove  %rax,%rdi
call   1050 <puts@plt>
lea    0xde7(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1090 <findMin@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   10d0 <findMax@plt>
lea    0xd6e(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdd8(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1030 <preOrderTraverse@plt>
lea    0xde3(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1080 <inOrderTraverse@plt>
lea    0xded(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   10a0 <postOrderTraverse@plt>
xor    %eax,%eax
call   10c0 <getch@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [41 x i8] c"\0A----- Creating the BST structure -----\0A\00"
@.str.1 = [22 x i8] c"Number of BST nodes: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [10 x i8] c"Node %d: \00"
@.str.4 = [24 x i8] c"\0A----- Searching -----\0A\00"
@.str.5 = [9 x i8] c"Lookup: \00"
@.str.6 = [8 x i8] c"Found!\0A\00"
@.str.7 = [12 x i8] c"Not found!\0A\00"
@.str.8 = [34 x i8] c"\0A----- Finding Max and Min -----\0A\00"
@.str.9 = [17 x i8] c"Min: %d\0AMax: %d\0A\00"
@.str.10 = [32 x i8] c"\0A----- PreOrder Traverse -----\0A\00"
@.str.11 = [31 x i8] c"\0A----- InOrder Traverse -----\0A\00"
@.str.12 = [33 x i8] c"\0A----- PostOrder Traverse -----\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i32]
%6 = alloca %struct.node*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store %struct.node* null, %struct.node** %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
store i32 0, i32* %2
br label %12
12: ; preds = %30, %0
%13 = load i32, i32* %2
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %33
16: ; preds = %12
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %22)
%24 = load %struct.node*, %struct.node** %6
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = call %struct.node* @insertN(%struct.node* %24, i32 %28)
store %struct.node* %29, %struct.node** %6
br label %30
30: ; preds = %16
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %12
33: ; preds = %12
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%37 = load %struct.node*, %struct.node** %6
%38 = load i32, i32* %3
%39 = call i64 @searchNode(%struct.node* %37, i32 %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %33
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %45
43: ; preds = %33
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %45
45: ; preds = %43, %41
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0))
%47 = load %struct.node*, %struct.node** %6
%48 = call i32 @findMin(%struct.node* %47)
store i32 %48, i32* %7
%49 = load %struct.node*, %struct.node** %6
%50 = call i32 @findMax(%struct.node* %49)
store i32 %50, i32* %8
%51 = load i32, i32* %7
%52 = load i32, i32* %8
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %51, i32 %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0))
%55 = load %struct.node*, %struct.node** %6
%56 = call i32 @preOrderTraverse(%struct.node* %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0))
%58 = load %struct.node*, %struct.node** %6
%59 = call i32 @inOrderTraverse(%struct.node* %58)
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0))
%61 = load %struct.node*, %struct.node** %6
%62 = call i32 @postOrderTraverse(%struct.node* %61)
%63 = call i32 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str.1 = [22 x i8] c"Number of BST nodes: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [10 x i8] c"Node %d: \00"
@.str.5 = [9 x i8] c"Lookup: \00"
@.str.9 = [17 x i8] c"Min: %d\0AMax: %d\0A\00"
@str = [40 x i8] c"\0A----- Creating the BST structure -----\00"
@str.13 = [23 x i8] c"\0A----- Searching -----\00"
@str.14 = [11 x i8] c"Not found!\00"
@str.15 = [33 x i8] c"\0A----- Finding Max and Min -----\00"
@str.16 = [31 x i8] c"\0A----- PreOrder Traverse -----\00"
@str.17 = [30 x i8] c"\0A----- InOrder Traverse -----\00"
@str.18 = [32 x i8] c"\0A----- PostOrder Traverse -----\00"
@str.19 = [7 x i8] c"Found!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i32]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast [100 x i32]* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %25
12: ; preds = %0, %12
%13 = phi i64 [ %15, %12 ], [ 0, %0 ]
%14 = phi %struct.node* [ %21, %12 ], [ null, %0 ]
%15 = add nuw nsw i64 %13, 1
%16 = trunc i64 %15 to i32
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %13
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %18)
%20 = load i32, i32* %18
%21 = call %struct.node* @insertN(%struct.node* %14, i32 %20)
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %15, %23
br i1 %24, label %12, label %25
25: ; preds = %12, %0
%26 = phi %struct.node* [ null, %0 ], [ %21, %12 ]
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.13, i64 0, i64 0))
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%30 = load i32, i32* %1
%31 = call i64 @searchNode(%struct.node* %26, i32 %30)
%32 = icmp eq i64 %31, 0
%33 = select i1 %32, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str.14, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.19, i64 0, i64 0)
%34 = call i32 @puts(i8* dereferenceable(1) %33)
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.15, i64 0, i64 0))
%36 = call i32 @findMin(%struct.node* %26)
%37 = call i32 @findMax(%struct.node* %26)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %36, i32 %37)
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.16, i64 0, i64 0))
%40 = call i32 @preOrderTraverse(%struct.node* %26)
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.17, i64 0, i64 0))
%42 = call i32 @inOrderTraverse(%struct.node* %26)
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.18, i64 0, i64 0))
%44 = call i32 @postOrderTraverse(%struct.node* %26)
%45 = call i32 (...) @getch()
ret i32 0
}