#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*/ update(int *, int, int, int);
void constructBITtree(int arr[], int bit_tree[], int n) {
  for (int i = 1; i <= n; i++)
    bit_tree[i] = 0;
  for (int i = 0; i < n; i++)
    update(bit_tree, n, i, arr[i]);
  return;
}


x86 assembly (clang, -O0):
<constructBITtree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1153 <constructBITtree+0x43>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <constructBITtree+0x1a>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    118e <constructBITtree+0x7e>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
call   1030 <update@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115a <constructBITtree+0x4a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<constructBITtree>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    116a <constructBITtree+0x4a>
mov    %rsi,%r15
mov    %rdi,%r14
mov    %edx,%r12d
lea    0x4(%rsi),%rdi
lea    0x0(,%r12,4),%rdx
xor    %ebx,%ebx
xor    %esi,%esi
call   1040 <memset@plt>
nopw   0x0(%rax,%rax,1)
mov    (%r14,%rbx,4),%ecx
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
call   1030 <update@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <constructBITtree+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @constructBITtree(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 1, i32* %7
br label %9
9: ; preds = %18, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %21
13: ; preds = %9
%14 = load i32*, i32** %5
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
store i32 0, i32* %17
br label %18
18: ; preds = %13
%19 = load i32, i32* %7
%20 = add nsw i32 %19, 1
store i32 %20, i32* %7
br label %9
21: ; preds = %9
store i32 0, i32* %8
br label %22
22: ; preds = %36, %21
%23 = load i32, i32* %8
%24 = load i32, i32* %6
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %39
26: ; preds = %22
%27 = load i32*, i32** %5
%28 = load i32, i32* %6
%29 = load i32, i32* %8
%30 = load i32*, i32** %4
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = call i32 @update(i32* %27, i32 %28, i32 %29, i32 %34)
br label %36
36: ; preds = %26
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %22
39: ; preds = %22
ret void
}

LLVM IR (-O2):
define void @constructBITtree(i32* nocapture %0, i32* %1, i32 %2) {
%4 = icmp slt i32 %2, 1
br i1 %4, label %11, label %5
5: ; preds = %3
%6 = getelementptr i32, i32* %1, i64 1
%7 = bitcast i32* %6 to i8*
%8 = zext i32 %2 to i64
%9 = shl nuw nsw i64 %8, 2
%10 = zext i32 %2 to i64
br label %12
11: ; preds = %12, %3
ret void
12: ; preds = %5, %12
%13 = phi i64 [ 0, %5 ], [ %18, %12 ]
%14 = getelementptr inbounds i32, i32* %0, i64 %13
%15 = load i32, i32* %14
%16 = trunc i64 %13 to i32
%17 = tail call i32 @update(i32* %1, i32 %2, i32 %16, i32 %15)
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, %10
br i1 %19, label %11, label %12
}