#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);
int /*<<< orphan*/ putchar(int);
void display(int *base, size_t nmemb, size_t node, size_t indent) {
  if (node < 1 || node >= nmemb)
    return;
  display(base, nmemb, node << 1, indent + 1);
  for (size_t i = 0; i++ < indent; putchar(9))
    ;
  printf("%d", base[node]);
  putchar(10);
  display(base, nmemb, (node << 1) + 1, indent + 1);
}


x86 assembly (clang, -O0):
<display>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x1,-0x18(%rbp)
jb     1161 <display+0x31>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jb     1166 <display+0x36>
jmp    11fa <display+0xca>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
shl    $0x1,%rdx
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
call   1040 <display@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
cmp    -0x20(%rbp),%rax
jae    11b8 <display+0x88>
jmp    11a9 <display+0x79>
mov    $0x9,%edi
call   1030 <putchar@plt>
jmp    118b <display+0x5b>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe36(%rip),%rdi
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
shl    $0x1,%rdx
add    $0x1,%rdx
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
call   1040 <display@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
je     11c2 <display+0x92>
mov    %rdx,%rbx
mov    %rsi,%r14
cmp    %rsi,%rdx
jae    11c2 <display+0x92>
mov    %rcx,%r12
mov    %rdi,%r15
jmp    1186 <display+0x56>
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%esi
lea    0xe95(%rip),%rdi
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
or     $0x1,%rbp
mov    %rbp,%rbx
cmp    %r14,%rbp
jae    11c2 <display+0x92>
mov    %r12,%r13
lea    (%rbx,%rbx,1),%rbp
add    $0x1,%r12
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
mov    %r12,%rcx
call   1040 <display@plt>
test   %r13,%r13
je     1160 <display+0x30>
nopw   0x0(%rax,%rax,1)
mov    $0x9,%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%r13
jne    11b0 <display+0x80>
jmp    1160 <display+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @display(i32* %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i32* %0, i32** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%10 = load i64, i64* %7
%11 = icmp ult i64 %10, 1
br i1 %11, label %16, label %12
12: ; preds = %4
%13 = load i64, i64* %7
%14 = load i64, i64* %6
%15 = icmp uge i64 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %12, %4
br label %46
17: ; preds = %12
%18 = load i32*, i32** %5
%19 = load i64, i64* %6
%20 = load i64, i64* %7
%21 = shl i64 %20, 1
%22 = load i64, i64* %8
%23 = add i64 %22, 1
store i64 0, i64* %9
br label %24
24: ; preds = %30, %17
%25 = load i64, i64* %9
%26 = add i64 %25, 1
store i64 %26, i64* %9
%27 = load i64, i64* %8
%28 = icmp ult i64 %25, %27
br i1 %28, label %29, label %32
29: ; preds = %24
br label %30
30: ; preds = %29
%31 = call i32 @putchar(i32 9)
br label %24
32: ; preds = %24
%33 = load i32*, i32** %5
%34 = load i64, i64* %7
%35 = getelementptr inbounds i32, i32* %33, i64 %34
%36 = load i32, i32* %35
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = call i32 @putchar(i32 10)
%39 = load i32*, i32** %5
%40 = load i64, i64* %6
%41 = load i64, i64* %7
%42 = shl i64 %41, 1
%43 = add i64 %42, 1
%44 = load i64, i64* %8
%45 = add i64 %44, 1
br label %46
46: ; preds = %32, %16
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @display(i32* %0, i64 %1, i64 %2, i64 %3) {
%5 = icmp ne i64 %2, 0
%6 = icmp ult i64 %2, %1
%7 = and i1 %5, %6
br i1 %7, label %8, label %26
8: ; preds = %4, %14
%9 = phi i64 [ %12, %14 ], [ %3, %4 ]
%10 = phi i64 [ %19, %14 ], [ %2, %4 ]
%11 = shl i64 %10, 1
%12 = add i64 %9, 1
tail call void @display(i32* %0, i64 %1, i64 %11, i64 %12)
%13 = icmp eq i64 %9, 0
br i1 %13, label %14, label %21
14: ; preds = %21, %8
%15 = getelementptr inbounds i32, i32* %0, i64 %10
%16 = load i32, i32* %15
%17 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = tail call i32 @putchar(i32 10)
%19 = or i64 %11, 1
%20 = icmp ult i64 %19, %1
br i1 %20, label %8, label %26
21: ; preds = %8, %21
%22 = phi i64 [ %23, %21 ], [ 0, %8 ]
%23 = add nuw i64 %22, 1
%24 = tail call i32 @putchar(i32 9)
%25 = icmp eq i64 %23, %9
br i1 %25, label %14, label %21
26: ; preds = %14, %4
ret void
}