#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 *);
void _check_max_heap(int *arr, int size) {
  int i = 0, res = 1;
  for (i = 0; (2 * i + 1 < size) && (2 * i + 2 < size); i++) {
    if ((arr[i] < arr[2 * i + 1]) || (arr[i] < arr[2 * i + 2])) {
      res = 0;
      break;
    }
  }
  if (!res) {
    printf("\n Arr not a binary heap");
  } else {
    printf("\n Arr is a binary heap");
  }
}


x86 assembly (clang, -O0):
<_check_max_heap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x15(%rbp)
jge    115d <_check_max_heap+0x4d>
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
add    $0x2,%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    116d <_check_max_heap+0x5d>
jmp    11d4 <_check_max_heap+0xc4>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%edx
shl    $0x1,%edx
add    $0x1,%edx
movslq %edx,%rdx
cmp    (%rcx,%rdx,4),%eax
jl     11b5 <_check_max_heap+0xa5>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%edx
shl    $0x1,%edx
add    $0x2,%edx
movslq %edx,%rdx
cmp    (%rcx,%rdx,4),%eax
jge    11c1 <_check_max_heap+0xb1>
movl   $0x0,-0x14(%rbp)
jmp    11d4 <_check_max_heap+0xc4>
jmp    11c6 <_check_max_heap+0xb6>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <_check_max_heap+0x24>
cmpl   $0x0,-0x14(%rbp)
jne    11ef <_check_max_heap+0xdf>
lea    0xe1b(%rip),%rdi
call   1030 <printf@plt>
jmp    11fb <_check_max_heap+0xeb>
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_check_max_heap>:
mov    %rdi,%r9
lea    0xefe(%rip),%rdi
cmp    $0x2,%esi
jl     115a <_check_max_heap+0x4a>
xor    %edx,%edx
lea    0xed8(%rip),%r8
nopl   0x0(%rax,%rax,1)
lea    0x2(%rdx),%rcx
cmp    %esi,%ecx
jge    115a <_check_max_heap+0x4a>
mov    (%r9,%rdx,2),%eax
add    $0x1,%rdx
mov    %edx,%edx
cmp    (%r9,%rdx,4),%eax
jl     115f <_check_max_heap+0x4f>
mov    %ecx,%edx
cmp    (%r9,%rdx,4),%eax
jl     115f <_check_max_heap+0x4f>
lea    0x1(%rcx),%eax
mov    %rcx,%rdx
cmp    %esi,%eax
jl     1130 <_check_max_heap+0x20>
jmp    1030 <printf@plt>
mov    %r8,%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"\0A Arr not a binary heap\00"
@.str.1 = [23 x i8] c"\0A Arr is a binary heap\00"
define void @_check_max_heap(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 1, i32* %6
store i32 0, i32* %5
br label %7
7: ; preds = %51, %2
%8 = load i32, i32* %5
%9 = mul nsw i32 2, %8
%10 = add nsw i32 %9, 1
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %19
13: ; preds = %7
%14 = load i32, i32* %5
%15 = mul nsw i32 2, %14
%16 = add nsw i32 %15, 2
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br label %19
19: ; preds = %13, %7
%20 = phi i1 [ false, %7 ], [ %18, %13 ]
br i1 %20, label %21, label %54
21: ; preds = %19
%22 = load i32*, i32** %3
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
%27 = load i32*, i32** %3
%28 = load i32, i32* %5
%29 = mul nsw i32 2, %28
%30 = add nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %27, i64 %31
%33 = load i32, i32* %32
%34 = icmp slt i32 %26, %33
br i1 %34, label %49, label %35
35: ; preds = %21
%36 = load i32*, i32** %3
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = load i32*, i32** %3
%42 = load i32, i32* %5
%43 = mul nsw i32 2, %42
%44 = add nsw i32 %43, 2
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %41, i64 %45
%47 = load i32, i32* %46
%48 = icmp slt i32 %40, %47
br i1 %48, label %49, label %50
49: ; preds = %35, %21
store i32 0, i32* %6
br label %54
50: ; preds = %35
br label %51
51: ; preds = %50
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 1
store i32 %53, i32* %5
br label %7
54: ; preds = %49, %19
%55 = load i32, i32* %6
%56 = icmp ne i32 %55, 0
br i1 %56, label %59, label %57
57: ; preds = %54
%58 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %61
59: ; preds = %54
%60 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %61
61: ; preds = %59, %57
ret void
}

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