#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 pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int bst[100], levels, n, i;
  printf("Enter the number of levels in your BST: ");
  scanf("%d", &levels);
  for (i = 0; i < levels; i++)
    n = n + pow(2, i);
  printf("Enter the elements for your BST: ");
  for (i = 0; i < n; i++) {
    scanf("%d", &bst[i]);
  }
  for (i = 0; i < n; i++) {
    printf("%d ", bst[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed9(%rip),%rdi
lea    -0x194(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x19c(%rbp)
mov    -0x19c(%rbp),%eax
cmp    -0x194(%rbp),%eax
jge    11b8 <main+0x88>
mov    -0x198(%rbp),%eax
mov    %eax,-0x1a0(%rbp)
mov    -0x19c(%rbp),%esi
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x1a0(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x198(%rbp)
mov    -0x19c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x19c(%rbp)
jmp    1166 <main+0x36>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x19c(%rbp)
mov    -0x19c(%rbp),%eax
cmp    -0x198(%rbp),%eax
jge    1217 <main+0xe7>
movslq -0x19c(%rbp),%rax
lea    -0x190(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe2b(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x19c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x19c(%rbp)
jmp    11d0 <main+0xa0>
movl   $0x0,-0x19c(%rbp)
mov    -0x19c(%rbp),%eax
cmp    -0x198(%rbp),%eax
jge    1263 <main+0x133>
movslq -0x19c(%rbp),%rax
mov    -0x190(%rbp,%rax,4),%esi
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x19c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x19c(%rbp)
jmp    1221 <main+0xf1>
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1a0,%rsp
lea    0xeba(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11f9 <main+0xc9>
nopl   0x0(%rax,%rax,1)
mov    $0x2,%edi
mov    %ebx,%esi
call   1050 <pow@plt>
add    %eax,%r12d
add    $0x1,%ebx
cmp    0xc(%rsp),%ebx
jl     1170 <main+0x40>
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r12d,%r12d
jle    1207 <main+0xd7>
mov    %r12d,%r15d
lea    0x10(%rsp),%rbx
lea    0xe7f(%rip),%r14
mov    %r15,%rbp
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    $0x4,%rbx
add    $0xffffffffffffffff,%rbp
jne    11b0 <main+0x80>
test   %r12d,%r12d
jle    1207 <main+0xd7>
lea    0xe7d(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x10(%rsp,%rbp,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    11e0 <main+0xb0>
jmp    1207 <main+0xd7>
lea    0xe2c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1a0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Enter the number of levels in your BST: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"Enter the elements for your BST: \00"
@.str.3 = [4 x i8] c"%d \00"
define void @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 0, i32* %4
br label %7
7: ; preds = %16, %0
%8 = load i32, i32* %4
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %19
11: ; preds = %7
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = call i32 @pow(i32 2, i32 %13)
%15 = add nsw i32 %12, %14
store i32 %15, i32* %3
br label %16
16: ; preds = %11
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %7
19: ; preds = %7
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %21
21: ; preds = %30, %19
%22 = load i32, i32* %4
%23 = load i32, i32* %3
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %33
25: ; preds = %21
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %27
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %28)
br label %30
30: ; preds = %25
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %21
33: ; preds = %21
store i32 0, i32* %4
br label %34
34: ; preds = %44, %33
%35 = load i32, i32* %4
%36 = load i32, i32* %3
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %47
38: ; preds = %34
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %38
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %34
47: ; preds = %34
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c"Enter the number of levels in your BST: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"Enter the elements for your BST: \00"
@.str.3 = [4 x i8] c"%d \00"
define void @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = bitcast [100 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %40
11: ; preds = %0, %11
%12 = phi i32 [ %16, %11 ], [ 0, %0 ]
%13 = phi i32 [ %15, %11 ], [ undef, %0 ]
%14 = call i32 @pow(i32 2, i32 %12)
%15 = add nsw i32 %14, %13
%16 = add nuw nsw i32 %12, 1
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %11, label %19
19: ; preds = %11
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp sgt i32 %15, 0
br i1 %21, label %22, label %40
22: ; preds = %19
%23 = zext i32 %15 to i64
br label %27
24: ; preds = %27
br i1 %21, label %25, label %40
25: ; preds = %24
%26 = zext i32 %15 to i64
br label %33
27: ; preds = %22, %27
%28 = phi i64 [ 0, %22 ], [ %31, %27 ]
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %28
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %29)
%31 = add nuw nsw i64 %28, 1
%32 = icmp eq i64 %31, %23
br i1 %32, label %24, label %27
33: ; preds = %25, %33
%34 = phi i64 [ 0, %25 ], [ %38, %33 ]
%35 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = add nuw nsw i64 %34, 1
%39 = icmp eq i64 %38, %26
br i1 %39, label %40, label %33
40: ; preds = %33, %19, %9, %24
ret void
}