#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*/ printf(char *, int);
void print_tree(int *arr, int level) {
  int i;
  for (i = level - 1; i < (level * 2 - 1); i++) {
    if (i >= 100)
      break;
    printf(" %d", arr[i]);
  }
  printf("\n%d\n", level);
  if (i == (level * 2 - 1))
    print_tree(arr, level * 2);
}


x86 assembly (clang, -O0):
<print_tree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1180 <print_tree+0x60>
cmpl   $0x64,-0x10(%rbp)
jl     115b <print_tree+0x3b>
jmp    1180 <print_tree+0x60>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1138 <print_tree+0x18>
mov    -0xc(%rbp),%esi
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11b2 <print_tree+0x92>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
shl    $0x1,%esi
call   1040 <print_tree@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_tree>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xedb(%rip),%r15
jmp    1148 <print_tree+0x38>
nopw   0x0(%rax,%rax,1)
lea    0xecd(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
cmp    (%rsp),%r12d
mov    0x4(%rsp),%esi
jne    1190 <print_tree+0x80>
mov    %esi,%ebp
lea    -0x1(%rbp),%r12d
lea    0x0(%rbp,%rbp,1),%eax
lea    -0x1(%rbp,%rbp,1),%ecx
cmp    %eax,%esi
mov    %eax,0x4(%rsp)
mov    %ecx,(%rsp)
jge    1130 <print_tree+0x20>
cmp    $0x64,%ebp
jg     1130 <print_tree+0x20>
movslq %r12d,%r14
movslq %ecx,%r13
nopl   0x0(%rax)
mov    (%rbx,%r14,4),%esi
mov    %r15,%rdi
call   1030 <printf@plt>
lea    0x1(%r14),%r12
cmp    %r13,%r12
jge    1130 <print_tree+0x20>
cmp    $0x63,%r14
mov    %r12,%r14
jl     1170 <print_tree+0x60>
jmp    1130 <print_tree+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c" %d\00"
@.str.1 = [5 x i8] c"\0A%d\0A\00"
define void @print_tree(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = sub nsw i32 %6, 1
store i32 %7, i32* %5
br label %8
8: ; preds = %25, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = mul nsw i32 %10, 2
%12 = sub nsw i32 %11, 1
%13 = icmp slt i32 %9, %12
br i1 %13, label %14, label %28
14: ; preds = %8
%15 = load i32, i32* %5
%16 = icmp sge i32 %15, 100
br i1 %16, label %17, label %18
17: ; preds = %14
br label %28
18: ; preds = %14
%19 = load i32*, i32** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %18
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %8
28: ; preds = %17, %8
%29 = load i32, i32* %4
%30 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %5
%32 = load i32, i32* %4
%33 = mul nsw i32 %32, 2
%34 = sub nsw i32 %33, 1
%35 = icmp eq i32 %31, %34
br i1 %35, label %36, label %40
36: ; preds = %28
%37 = load i32*, i32** %3
%38 = load i32, i32* %4
%39 = mul nsw i32 %38, 2
br label %40
40: ; preds = %36, %28
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c" %d\00"
@.str.1 = [5 x i8] c"\0A%d\0A\00"
define void @print_tree(i32* nocapture %0, i32 %1) {
br label %3
3: ; preds = %25, %2
%4 = phi i32 [ %1, %2 ], [ %6, %25 ]
%5 = add i32 %4, -1
%6 = shl nsw i32 %4, 1
%7 = add nsw i32 %6, -1
%8 = icmp sge i32 %4, %6
%9 = icmp sgt i32 %4, 100
%10 = or i1 %8, %9
br i1 %10, label %25, label %11
11: ; preds = %3
%12 = sext i32 %5 to i64
%13 = sext i32 %7 to i64
br label %14
14: ; preds = %11, %14
%15 = phi i64 [ %12, %11 ], [ %19, %14 ]
%16 = getelementptr inbounds i32, i32* %0, i64 %15
%17 = load i32, i32* %16
%18 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = add nsw i64 %15, 1
%20 = icmp sge i64 %19, %13
%21 = icmp sgt i64 %15, 98
%22 = or i1 %20, %21
br i1 %22, label %23, label %14
23: ; preds = %14
%24 = trunc i64 %19 to i32
br label %25
25: ; preds = %23, %3
%26 = phi i32 [ %5, %3 ], [ %24, %23 ]
%27 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%28 = icmp eq i32 %26, %7
br i1 %28, label %3, label %29
29: ; preds = %25
ret void
}