#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 */
size_t parent(int, int);
int check_MAX_heap(int arr[], int n, int k) {
  int i;
  for (i = n - 1; i > 0; i--) {
    if (arr[parent(i, k)] < arr[i])
      return 0;
  }
}


x86 assembly (clang, -O0):
<check_MAX_heap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1182 <check_MAX_heap+0x72>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <parent@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    (%rax,%rcx,4),%eax
mov    -0x10(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    116f <check_MAX_heap+0x5f>
movl   $0x0,-0x4(%rbp)
jmp    1182 <check_MAX_heap+0x72>
jmp    1174 <check_MAX_heap+0x64>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <check_MAX_heap+0x1b>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_MAX_heap>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rdi,%rbx
mov    %esi,%ebp
nopl   0x0(%rax)
cmp    $0x2,%ebp
jl     113d <check_MAX_heap+0x2d>
add    $0xffffffffffffffff,%rbp
mov    %ebp,%edi
mov    %r14d,%esi
call   1030 <parent@plt>
mov    (%rbx,%rax,4),%eax
mov    %ebp,%ecx
cmp    (%rbx,%rcx,4),%eax
jge    1120 <check_MAX_heap+0x10>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @check_MAX_heap(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** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load i32, i32* %6
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %8
br label %11
11: ; preds = %29, %3
%12 = load i32, i32* %8
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %32
14: ; preds = %11
%15 = load i32*, i32** %5
%16 = load i32, i32* %8
%17 = load i32, i32* %7
%18 = call i64 @parent(i32 %16, i32 %17)
%19 = getelementptr inbounds i32, i32* %15, i64 %18
%20 = load i32, i32* %19
%21 = load i32*, i32** %5
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = icmp slt i32 %20, %25
br i1 %26, label %27, label %28
27: ; preds = %14
store i32 0, i32* %4
br label %32
28: ; preds = %14
br label %29
29: ; preds = %28
%30 = load i32, i32* %8
%31 = add nsw i32 %30, -1
store i32 %31, i32* %8
br label %11
32: ; preds = %27, %11
%33 = load i32, i32* %4
ret i32 %33
}

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