#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*/ insert(int, struct Node **);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ search_tree(int, struct Node *);
int size(struct Node *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  struct Node *wordTree = NULL;
  int i;
  srand(time(NULL));
  for (i = 0; i < 2000000; i++) {
    insert(rand() % 30000000, &wordTree);
  }
  printf("Size of tree: %d\n", size(wordTree));
  int in = 0;
  while (in != -1) {
    printf("\nSearch: ");
    scanf("%d", &in);
    search_tree(in, wordTree);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1e8480,-0x14(%rbp)
jge    11e3 <main+0x63>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x1c9c380,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
lea    -0x10(%rbp),%rsi
call   1090 <insert@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ae <main+0x2e>
mov    -0x10(%rbp),%rdi
call   1030 <size@plt>
mov    %eax,%esi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
je     123c <main+0xbc>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdfa(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <search_tree@plt>
jmp    1203 <main+0x83>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x1e8480,%ebp
lea    0x10(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rdi
imul   $0x4795319d,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x37,%rax
add    %ecx,%eax
imul   $0x1c9c380,%eax,%eax
sub    %eax,%edi
mov    %rbx,%rsi
call   1090 <insert@plt>
add    $0xffffffff,%ebp
jne    11b0 <main+0x30>
mov    0x10(%rsp),%rdi
call   1030 <size@plt>
lea    0xe0c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x0,0xc(%rsp)
lea    0xe06(%rip),%r14
lea    0xe09(%rip),%r15
lea    0xc(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    0xc(%rsp),%edi
mov    0x10(%rsp),%rsi
call   1070 <search_tree@plt>
cmpl   $0xffffffff,0xc(%rsp)
jne    1220 <main+0xa0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.Node = type { i32 }
@.str = [18 x i8] c"Size of tree: %d\0A\00"
@.str.1 = [10 x i8] c"\0ASearch: \00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.Node*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store %struct.Node* null, %struct.Node** %2
%5 = call i32 @time(i32* null)
%6 = call i32 @srand(i32 %5)
store i32 0, i32* %3
br label %7
7: ; preds = %14, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 2000000
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = call i32 (...) @rand()
%12 = srem i32 %11, 30000000
%13 = call i32 @insert(i32 %12, %struct.Node** %2)
br label %14
14: ; preds = %10
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %7
17: ; preds = %7
%18 = load %struct.Node*, %struct.Node** %2
%19 = call i32 @size(%struct.Node* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %19)
store i32 0, i32* %4
br label %21
21: ; preds = %24, %17
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%27 = load i32, i32* %4
%28 = load %struct.Node*, %struct.Node** %2
%29 = call i32 @search_tree(i32 %27, %struct.Node* %28)
br label %21
30: ; preds = %21
ret i32 0
}

LLVM IR (-O2):
%struct.Node = type { i32 }
@.str = [18 x i8] c"Size of tree: %d\0A\00"
@.str.1 = [10 x i8] c"\0ASearch: \00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca %struct.Node*
%2 = alloca i32
%3 = bitcast %struct.Node** %1 to i8*
store %struct.Node* null, %struct.Node** %1
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @srand(i32 %4)
br label %6
6: ; preds = %0, %6
%7 = phi i32 [ 0, %0 ], [ %11, %6 ]
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 30000000
%10 = call i32 @insert(i32 %9, %struct.Node** %1)
%11 = add nuw nsw i32 %7, 1
%12 = icmp eq i32 %11, 2000000
br i1 %12, label %13, label %6
13: ; preds = %6
%14 = load %struct.Node*, %struct.Node** %1
%15 = call i32 @size(%struct.Node* %14)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = bitcast i32* %2 to i8*
store i32 0, i32* %2
br label %18
18: ; preds = %13, %18
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%21 = load i32, i32* %2
%22 = load %struct.Node*, %struct.Node** %1
%23 = call i32 @search_tree(i32 %21, %struct.Node* %22)
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %18
26: ; preds = %18
ret i32 0
}