#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*/ __CrestApply2(int, int, long long);
int /*<<< orphan*/ __CrestBranch(int, int, int);
int /*<<< orphan*/ __CrestCall(int, int);
int /*<<< orphan*/ __CrestClearStack(int);
int /*<<< orphan*/ __CrestInt(int *);
int /*<<< orphan*/ __CrestLoad(int, unsigned long, long long);
int /*<<< orphan*/ __CrestReturn(int);
int /*<<< orphan*/ __CrestStore(int, unsigned long);
int /*<<< orphan*/ adjust(int *, int);
int /*<<< orphan*/ heapify(int *, int);
void heapSort(int *a, int n) {
  int i;
  int t;
  int *mem_5;
  int *mem_6;
  int *mem_7;
  int *mem_8;
  int *mem_9;
  int *mem_10;
  int *mem_11;
  int *mem_12;
  {
    __CrestCall(59, 2);
    __CrestStore(58, (unsigned long)(&n));
    __CrestInt((int *)(&a));
    __CrestInt(&n);
    __CrestLoad(60, (unsigned long)(&n), (long long)n);
    heapify(a, n);
    __CrestClearStack(61);
    __CrestLoad(64, (unsigned long)(&n), (long long)n);
    __CrestLoad(63, (unsigned long)0, (long long)1);
    __CrestApply2(62, 1, (long long)(n - 1));
    __CrestStore(65, (unsigned long)(&i));
    i = n - 1;
    {{__CrestLoad(68, (unsigned long)(&i), (long long)i);
    __CrestLoad(67, (unsigned long)0, (long long)0);
    __CrestApply2(66, 14, (long long)(i > 0));
    if (i > 0) {
      __CrestBranch(69, 23, 1);
      mem_5 = a + 0;
      __CrestLoad(71, (unsigned long)mem_5, (long long)*mem_5);
      __CrestStore(72, (unsigned long)(&t));
      t = *mem_5;
      mem_6 = a + 0;
      mem_7 = a + i;
      __CrestLoad(73, (unsigned long)mem_7, (long long)*mem_7);
      __CrestStore(74, (unsigned long)mem_6);
      *mem_6 = *mem_7;
      mem_8 = a + i;
      __CrestLoad(75, (unsigned long)(&t), (long long)t);
      __CrestStore(76, (unsigned long)mem_8);
      *mem_8 = t;
      __CrestLoad(77, (unsigned long)(&i), (long long)i);
      adjust(a, i);
      __CrestClearStack(78);
      __CrestLoad(81, (unsigned long)(&i), (long long)i);
      __CrestLoad(80, (unsigned long)0, (long long)1);
      __CrestApply2(79, 1, (long long)(i - 1));
      __CrestStore(82, (unsigned long)(&i));
      i--;
    } else {
      __CrestBranch(70, 24, 0);
    }
  }
  {
    __CrestLoad(85, (unsigned long)(&i), (long long)i);
    __CrestLoad(84, (unsigned long)0, (long long)0);
    __CrestApply2(83, 14, (long long)(i > 0));
    if (i > 0) {
      __CrestBranch(86, 26, 1);
      mem_9 = a + 0;
      __CrestLoad(88, (unsigned long)mem_9, (long long)*mem_9);
      __CrestStore(89, (unsigned long)(&t));
      t = *mem_9;
      mem_10 = a + 0;
      mem_11 = a + i;
      __CrestLoad(90, (unsigned long)mem_11, (long long)*mem_11);
      __CrestStore(91, (unsigned long)mem_10);
      *mem_10 = *mem_11;
      mem_12 = a + i;
      __CrestLoad(92, (unsigned long)(&t), (long long)t);
      __CrestStore(93, (unsigned long)mem_12);
      *mem_12 = t;
      __CrestLoad(94, (unsigned long)(&i), (long long)i);
      adjust(a, i);
      __CrestClearStack(95);
      __CrestLoad(98, (unsigned long)(&i), (long long)i);
      __CrestLoad(97, (unsigned long)0, (long long)1);
      __CrestApply2(96, 1, (long long)(i - 1));
      __CrestStore(99, (unsigned long)(&i));
      i--;
    } else {
      __CrestBranch(87, 27, 0);
    }
  }
}
{
  __CrestReturn(100);
  return;
}
}
}


x86 assembly (clang, -O0):
<heapSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x3b,%edi
mov    $0x2,%esi
call   1080 <__CrestCall@plt>
lea    -0xc(%rbp),%rsi
mov    $0x3a,%edi
call   1060 <__CrestStore@plt>
lea    -0x8(%rbp),%rdi
call   1090 <__CrestInt@plt>
lea    -0xc(%rbp),%rdi
call   1090 <__CrestInt@plt>
lea    -0xc(%rbp),%rsi
movslq -0xc(%rbp),%rdx
mov    $0x3c,%edi
call   10a0 <__CrestLoad@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   10b0 <heapify@plt>
mov    $0x3d,%edi
call   10c0 <__CrestClearStack@plt>
lea    -0xc(%rbp),%rsi
movslq -0xc(%rbp),%rdx
mov    $0x40,%edi
call   10a0 <__CrestLoad@plt>
mov    $0x3f,%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x1,%edx
call   10a0 <__CrestLoad@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rdx
mov    $0x3e,%edi
mov    $0x1,%esi
call   1030 <__CrestApply2@plt>
lea    -0x10(%rbp),%rsi
mov    $0x41,%edi
call   1060 <__CrestStore@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
lea    -0x10(%rbp),%rsi
movslq -0x10(%rbp),%rdx
mov    $0x44,%edi
call   10a0 <__CrestLoad@plt>
mov    $0x43,%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   10a0 <__CrestLoad@plt>
cmpl   $0x0,-0x10(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
movslq %eax,%rdx
mov    $0x42,%edi
mov    $0xe,%esi
call   1030 <__CrestApply2@plt>
cmpl   $0x0,-0x10(%rbp)
jle    13f4 <heapSort+0x254>
mov    $0x45,%edi
mov    $0x17,%esi
mov    $0x1,%edx
call   1050 <__CrestBranch@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x20(%rbp),%rax
movslq (%rax),%rdx
mov    $0x47,%edi
call   10a0 <__CrestLoad@plt>
lea    -0x14(%rbp),%rsi
mov    $0x48,%edi
call   1060 <__CrestStore@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
mov    -0x30(%rbp),%rax
movslq (%rax),%rdx
mov    $0x49,%edi
call   10a0 <__CrestLoad@plt>
mov    -0x28(%rbp),%rsi
mov    $0x4a,%edi
call   1060 <__CrestStore@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
lea    -0x14(%rbp),%rsi
movslq -0x14(%rbp),%rdx
mov    $0x4b,%edi
call   10a0 <__CrestLoad@plt>
mov    -0x38(%rbp),%rsi
mov    $0x4c,%edi
call   1060 <__CrestStore@plt>
mov    -0x14(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x10(%rbp),%rsi
movslq -0x10(%rbp),%rdx
mov    $0x4d,%edi
call   10a0 <__CrestLoad@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1040 <adjust@plt>
mov    $0x4e,%edi
call   10c0 <__CrestClearStack@plt>
lea    -0x10(%rbp),%rsi
movslq -0x10(%rbp),%rdx
mov    $0x51,%edi
call   10a0 <__CrestLoad@plt>
mov    $0x50,%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x1,%edx
call   10a0 <__CrestLoad@plt>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rdx
mov    $0x4f,%edi
mov    $0x1,%esi
call   1030 <__CrestApply2@plt>
lea    -0x10(%rbp),%rsi
mov    $0x52,%edi
call   1060 <__CrestStore@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1405 <heapSort+0x265>
mov    $0x46,%edi
mov    $0x18,%esi
xor    %edx,%edx
call   1050 <__CrestBranch@plt>
lea    -0x10(%rbp),%rsi
movslq -0x10(%rbp),%rdx
mov    $0x55,%edi
call   10a0 <__CrestLoad@plt>
mov    $0x54,%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   10a0 <__CrestLoad@plt>
cmpl   $0x0,-0x10(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
movslq %eax,%rdx
mov    $0x53,%edi
mov    $0xe,%esi
call   1030 <__CrestApply2@plt>
cmpl   $0x0,-0x10(%rbp)
jle    159f <heapSort+0x3ff>
mov    $0x56,%edi
mov    $0x1a,%esi
mov    $0x1,%edx
call   1050 <__CrestBranch@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0x40(%rbp),%rax
movslq (%rax),%rdx
mov    $0x58,%edi
call   10a0 <__CrestLoad@plt>
lea    -0x14(%rbp),%rsi
mov    $0x59,%edi
call   1060 <__CrestStore@plt>
mov    -0x40(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rsi
mov    -0x50(%rbp),%rax
movslq (%rax),%rdx
mov    $0x5a,%edi
call   10a0 <__CrestLoad@plt>
mov    -0x48(%rbp),%rsi
mov    $0x5b,%edi
call   1060 <__CrestStore@plt>
mov    -0x50(%rbp),%rax
mov    (%rax),%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
lea    -0x14(%rbp),%rsi
movslq -0x14(%rbp),%rdx
mov    $0x5c,%edi
call   10a0 <__CrestLoad@plt>
mov    -0x58(%rbp),%rsi
mov    $0x5d,%edi
call   1060 <__CrestStore@plt>
mov    -0x14(%rbp),%ecx
mov    -0x58(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x10(%rbp),%rsi
movslq -0x10(%rbp),%rdx
mov    $0x5e,%edi
call   10a0 <__CrestLoad@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1040 <adjust@plt>
mov    $0x5f,%edi
call   10c0 <__CrestClearStack@plt>
lea    -0x10(%rbp),%rsi
movslq -0x10(%rbp),%rdx
mov    $0x62,%edi
call   10a0 <__CrestLoad@plt>
mov    $0x61,%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x1,%edx
call   10a0 <__CrestLoad@plt>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rdx
mov    $0x60,%edi
mov    $0x1,%esi
call   1030 <__CrestApply2@plt>
lea    -0x10(%rbp),%rsi
mov    $0x63,%edi
call   1060 <__CrestStore@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    15b0 <heapSort+0x410>
mov    $0x57,%edi
mov    $0x1b,%esi
xor    %edx,%edx
call   1050 <__CrestBranch@plt>
mov    $0x64,%edi
call   1070 <__CrestReturn@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<heapSort>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x10(%rsp)
mov    %esi,0xc(%rsp)
mov    $0x3b,%edi
mov    $0x2,%esi
call   1080 <__CrestCall@plt>
lea    0xc(%rsp),%rbx
mov    $0x3a,%edi
mov    %rbx,%rsi
call   1060 <__CrestStore@plt>
lea    0x10(%rsp),%rdi
call   1090 <__CrestInt@plt>
mov    %rbx,%rdi
call   1090 <__CrestInt@plt>
movslq 0xc(%rsp),%rdx
mov    $0x3c,%edi
mov    %rbx,%rsi
call   10a0 <__CrestLoad@plt>
mov    0x10(%rsp),%rdi
mov    0xc(%rsp),%esi
call   10b0 <heapify@plt>
mov    $0x3d,%edi
call   10c0 <__CrestClearStack@plt>
movslq 0xc(%rsp),%rdx
mov    $0x40,%edi
mov    %rbx,%rsi
call   10a0 <__CrestLoad@plt>
mov    $0x1,%edx
mov    $0x3f,%edi
xor    %esi,%esi
call   10a0 <__CrestLoad@plt>
movslq 0xc(%rsp),%rdx
add    $0xffffffffffffffff,%rdx
mov    $0x3e,%edi
mov    $0x1,%esi
call   1030 <__CrestApply2@plt>
lea    0x4(%rsp),%rbx
mov    $0x41,%edi
mov    %rbx,%rsi
call   1060 <__CrestStore@plt>
movslq 0xc(%rsp),%rdx
add    $0xffffffffffffffff,%rdx
mov    %edx,0x4(%rsp)
mov    $0x44,%edi
mov    %rbx,%rsi
call   10a0 <__CrestLoad@plt>
mov    $0x43,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <__CrestLoad@plt>
xor    %edx,%edx
cmpl   $0x0,0x4(%rsp)
setg   %dl
mov    $0x42,%edi
mov    $0xe,%esi
call   1030 <__CrestApply2@plt>
cmpl   $0x0,0x4(%rsp)
jle    13d3 <heapSort+0x233>
mov    $0x45,%edi
mov    $0x17,%esi
mov    $0x1,%edx
call   1050 <__CrestBranch@plt>
mov    0x10(%rsp),%rbx
movslq (%rbx),%rdx
mov    $0x47,%edi
mov    %rbx,%rsi
call   10a0 <__CrestLoad@plt>
lea    0x8(%rsp),%r14
mov    $0x48,%edi
mov    %r14,%rsi
call   1060 <__CrestStore@plt>
mov    (%rbx),%eax
mov    %eax,0x8(%rsp)
mov    0x10(%rsp),%rbx
movslq 0x4(%rsp),%r15
lea    (%rbx,%r15,4),%rsi
movslq (%rbx,%r15,4),%rdx
mov    $0x49,%edi
call   10a0 <__CrestLoad@plt>
mov    $0x4a,%edi
mov    %rbx,%rsi
call   1060 <__CrestStore@plt>
mov    (%rbx,%r15,4),%eax
mov    %eax,(%rbx)
mov    0x10(%rsp),%r12
movslq 0x4(%rsp),%rbx
lea    (%r12,%rbx,4),%r15
movslq 0x8(%rsp),%rdx
mov    $0x4b,%edi
mov    %r14,%rsi
call   10a0 <__CrestLoad@plt>
mov    $0x4c,%edi
mov    %r15,%rsi
call   1060 <__CrestStore@plt>
mov    0x8(%rsp),%eax
mov    %eax,(%r12,%rbx,4)
movslq 0x4(%rsp),%rdx
lea    0x4(%rsp),%rbx
mov    $0x4d,%edi
mov    %rbx,%rsi
call   10a0 <__CrestLoad@plt>
mov    0x10(%rsp),%rdi
mov    0x4(%rsp),%esi
call   1040 <adjust@plt>
mov    $0x4e,%edi
call   10c0 <__CrestClearStack@plt>
movslq 0x4(%rsp),%rdx
mov    $0x51,%edi
mov    %rbx,%rsi
call   10a0 <__CrestLoad@plt>
mov    $0x1,%edx
mov    $0x50,%edi
xor    %esi,%esi
call   10a0 <__CrestLoad@plt>
movslq 0x4(%rsp),%rdx
add    $0xffffffffffffffff,%rdx
mov    $0x4f,%edi
mov    $0x1,%esi
call   1030 <__CrestApply2@plt>
mov    $0x52,%edi
mov    %rbx,%rsi
call   1060 <__CrestStore@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
mov    %eax,0x4(%rsp)
jmp    13e8 <heapSort+0x248>
mov    $0x46,%edi
mov    $0x18,%esi
xor    %edx,%edx
call   1050 <__CrestBranch@plt>
mov    0x4(%rsp),%eax
movslq %eax,%rdx
lea    0x4(%rsp),%rsi
mov    $0x55,%edi
call   10a0 <__CrestLoad@plt>
mov    $0x54,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <__CrestLoad@plt>
xor    %edx,%edx
cmpl   $0x0,0x4(%rsp)
setg   %dl
mov    $0x53,%edi
mov    $0xe,%esi
call   1030 <__CrestApply2@plt>
cmpl   $0x0,0x4(%rsp)
jle    154f <heapSort+0x3af>
mov    $0x56,%edi
mov    $0x1a,%esi
mov    $0x1,%edx
call   1050 <__CrestBranch@plt>
mov    0x10(%rsp),%rbx
movslq (%rbx),%rdx
mov    $0x58,%edi
mov    %rbx,%rsi
call   10a0 <__CrestLoad@plt>
lea    0x8(%rsp),%r14
mov    $0x59,%edi
mov    %r14,%rsi
call   1060 <__CrestStore@plt>
mov    (%rbx),%eax
mov    %eax,0x8(%rsp)
mov    0x10(%rsp),%rbx
movslq 0x4(%rsp),%r15
lea    (%rbx,%r15,4),%rsi
movslq (%rbx,%r15,4),%rdx
mov    $0x5a,%edi
call   10a0 <__CrestLoad@plt>
mov    $0x5b,%edi
mov    %rbx,%rsi
call   1060 <__CrestStore@plt>
mov    (%rbx,%r15,4),%eax
mov    %eax,(%rbx)
mov    0x10(%rsp),%r12
movslq 0x4(%rsp),%rbx
lea    (%r12,%rbx,4),%r15
movslq 0x8(%rsp),%rdx
mov    $0x5c,%edi
mov    %r14,%rsi
call   10a0 <__CrestLoad@plt>
mov    $0x5d,%edi
mov    %r15,%rsi
call   1060 <__CrestStore@plt>
mov    0x8(%rsp),%eax
mov    %eax,(%r12,%rbx,4)
movslq 0x4(%rsp),%rdx
lea    0x4(%rsp),%rbx
mov    $0x5e,%edi
mov    %rbx,%rsi
call   10a0 <__CrestLoad@plt>
mov    0x10(%rsp),%rdi
mov    0x4(%rsp),%esi
call   1040 <adjust@plt>
mov    $0x5f,%edi
call   10c0 <__CrestClearStack@plt>
movslq 0x4(%rsp),%rdx
mov    $0x62,%edi
mov    %rbx,%rsi
call   10a0 <__CrestLoad@plt>
mov    $0x1,%edx
mov    $0x61,%edi
xor    %esi,%esi
call   10a0 <__CrestLoad@plt>
movslq 0x4(%rsp),%rdx
add    $0xffffffffffffffff,%rdx
mov    $0x60,%edi
mov    $0x1,%esi
call   1030 <__CrestApply2@plt>
mov    $0x63,%edi
mov    %rbx,%rsi
call   1060 <__CrestStore@plt>
addl   $0xffffffff,0x4(%rsp)
jmp    1560 <heapSort+0x3c0>
mov    $0x57,%edi
mov    $0x1b,%esi
xor    %edx,%edx
call   1050 <__CrestBranch@plt>
mov    $0x64,%edi
call   1070 <__CrestReturn@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @heapSort(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
store i32* %0, i32** %3
store i32 %1, i32* %4
%15 = call i32 @__CrestCall(i32 59, i32 2)
%16 = ptrtoint i32* %4 to i64
%17 = call i32 @__CrestStore(i32 58, i64 %16)
%18 = bitcast i32** %3 to i32*
%19 = call i32 @__CrestInt(i32* %18)
%20 = call i32 @__CrestInt(i32* %4)
%21 = ptrtoint i32* %4 to i64
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = call i32 @__CrestLoad(i32 60, i64 %21, i64 %23)
%25 = load i32*, i32** %3
%26 = load i32, i32* %4
%27 = call i32 @heapify(i32* %25, i32 %26)
%28 = call i32 @__CrestClearStack(i32 61)
%29 = ptrtoint i32* %4 to i64
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = call i32 @__CrestLoad(i32 64, i64 %29, i64 %31)
%33 = call i32 @__CrestLoad(i32 63, i64 0, i64 1)
%34 = load i32, i32* %4
%35 = sub nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = call i32 @__CrestApply2(i32 62, i32 1, i64 %36)
%38 = ptrtoint i32* %5 to i64
%39 = call i32 @__CrestStore(i32 65, i64 %38)
%40 = load i32, i32* %4
%41 = sub nsw i32 %40, 1
store i32 %41, i32* %5
%42 = ptrtoint i32* %5 to i64
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = call i32 @__CrestLoad(i32 68, i64 %42, i64 %44)
%46 = call i32 @__CrestLoad(i32 67, i64 0, i64 0)
%47 = load i32, i32* %5
%48 = icmp sgt i32 %47, 0
%49 = zext i1 %48 to i32
%50 = sext i32 %49 to i64
%51 = call i32 @__CrestApply2(i32 66, i32 14, i64 %50)
%52 = load i32, i32* %5
%53 = icmp sgt i32 %52, 0
br i1 %53, label %54, label %120
54: ; preds = %2
%55 = call i32 @__CrestBranch(i32 69, i32 23, i32 1)
%56 = load i32*, i32** %3
%57 = getelementptr inbounds i32, i32* %56, i64 0
store i32* %57, i32** %7
%58 = load i32*, i32** %7
%59 = ptrtoint i32* %58 to i64
%60 = load i32*, i32** %7
%61 = load i32, i32* %60
%62 = sext i32 %61 to i64
%63 = call i32 @__CrestLoad(i32 71, i64 %59, i64 %62)
%64 = ptrtoint i32* %6 to i64
%65 = call i32 @__CrestStore(i32 72, i64 %64)
%66 = load i32*, i32** %7
%67 = load i32, i32* %66
store i32 %67, i32* %6
%68 = load i32*, i32** %3
%69 = getelementptr inbounds i32, i32* %68, i64 0
store i32* %69, i32** %8
%70 = load i32*, i32** %3
%71 = load i32, i32* %5
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i32, i32* %70, i64 %72
store i32* %73, i32** %9
%74 = load i32*, i32** %9
%75 = ptrtoint i32* %74 to i64
%76 = load i32*, i32** %9
%77 = load i32, i32* %76
%78 = sext i32 %77 to i64
%79 = call i32 @__CrestLoad(i32 73, i64 %75, i64 %78)
%80 = load i32*, i32** %8
%81 = ptrtoint i32* %80 to i64
%82 = call i32 @__CrestStore(i32 74, i64 %81)
%83 = load i32*, i32** %9
%84 = load i32, i32* %83
%85 = load i32*, i32** %8
store i32 %84, i32* %85
%86 = load i32*, i32** %3
%87 = load i32, i32* %5
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i32, i32* %86, i64 %88
store i32* %89, i32** %10
%90 = ptrtoint i32* %6 to i64
%91 = load i32, i32* %6
%92 = sext i32 %91 to i64
%93 = call i32 @__CrestLoad(i32 75, i64 %90, i64 %92)
%94 = load i32*, i32** %10
%95 = ptrtoint i32* %94 to i64
%96 = call i32 @__CrestStore(i32 76, i64 %95)
%97 = load i32, i32* %6
%98 = load i32*, i32** %10
store i32 %97, i32* %98
%99 = ptrtoint i32* %5 to i64
%100 = load i32, i32* %5
%101 = sext i32 %100 to i64
%102 = call i32 @__CrestLoad(i32 77, i64 %99, i64 %101)
%103 = load i32*, i32** %3
%104 = load i32, i32* %5
%105 = call i32 @adjust(i32* %103, i32 %104)
%106 = call i32 @__CrestClearStack(i32 78)
%107 = ptrtoint i32* %5 to i64
%108 = load i32, i32* %5
%109 = sext i32 %108 to i64
%110 = call i32 @__CrestLoad(i32 81, i64 %107, i64 %109)
%111 = call i32 @__CrestLoad(i32 80, i64 0, i64 1)
%112 = load i32, i32* %5
%113 = sub nsw i32 %112, 1
%114 = sext i32 %113 to i64
%115 = call i32 @__CrestApply2(i32 79, i32 1, i64 %114)
%116 = ptrtoint i32* %5 to i64
%117 = call i32 @__CrestStore(i32 82, i64 %116)
%118 = load i32, i32* %5
%119 = add nsw i32 %118, -1
store i32 %119, i32* %5
br label %122
120: ; preds = %2
%121 = call i32 @__CrestBranch(i32 70, i32 24, i32 0)
br label %122
122: ; preds = %120, %54
%123 = ptrtoint i32* %5 to i64
%124 = load i32, i32* %5
%125 = sext i32 %124 to i64
%126 = call i32 @__CrestLoad(i32 85, i64 %123, i64 %125)
%127 = call i32 @__CrestLoad(i32 84, i64 0, i64 0)
%128 = load i32, i32* %5
%129 = icmp sgt i32 %128, 0
%130 = zext i1 %129 to i32
%131 = sext i32 %130 to i64
%132 = call i32 @__CrestApply2(i32 83, i32 14, i64 %131)
%133 = load i32, i32* %5
%134 = icmp sgt i32 %133, 0
br i1 %134, label %135, label %201
135: ; preds = %122
%136 = call i32 @__CrestBranch(i32 86, i32 26, i32 1)
%137 = load i32*, i32** %3
%138 = getelementptr inbounds i32, i32* %137, i64 0
store i32* %138, i32** %11
%139 = load i32*, i32** %11
%140 = ptrtoint i32* %139 to i64
%141 = load i32*, i32** %11
%142 = load i32, i32* %141
%143 = sext i32 %142 to i64
%144 = call i32 @__CrestLoad(i32 88, i64 %140, i64 %143)
%145 = ptrtoint i32* %6 to i64
%146 = call i32 @__CrestStore(i32 89, i64 %145)
%147 = load i32*, i32** %11
%148 = load i32, i32* %147
store i32 %148, i32* %6
%149 = load i32*, i32** %3
%150 = getelementptr inbounds i32, i32* %149, i64 0
store i32* %150, i32** %12
%151 = load i32*, i32** %3
%152 = load i32, i32* %5
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds i32, i32* %151, i64 %153
store i32* %154, i32** %13
%155 = load i32*, i32** %13
%156 = ptrtoint i32* %155 to i64
%157 = load i32*, i32** %13
%158 = load i32, i32* %157
%159 = sext i32 %158 to i64
%160 = call i32 @__CrestLoad(i32 90, i64 %156, i64 %159)
%161 = load i32*, i32** %12
%162 = ptrtoint i32* %161 to i64
%163 = call i32 @__CrestStore(i32 91, i64 %162)
%164 = load i32*, i32** %13
%165 = load i32, i32* %164
%166 = load i32*, i32** %12
store i32 %165, i32* %166
%167 = load i32*, i32** %3
%168 = load i32, i32* %5
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds i32, i32* %167, i64 %169
store i32* %170, i32** %14
%171 = ptrtoint i32* %6 to i64
%172 = load i32, i32* %6
%173 = sext i32 %172 to i64
%174 = call i32 @__CrestLoad(i32 92, i64 %171, i64 %173)
%175 = load i32*, i32** %14
%176 = ptrtoint i32* %175 to i64
%177 = call i32 @__CrestStore(i32 93, i64 %176)
%178 = load i32, i32* %6
%179 = load i32*, i32** %14
store i32 %178, i32* %179
%180 = ptrtoint i32* %5 to i64
%181 = load i32, i32* %5
%182 = sext i32 %181 to i64
%183 = call i32 @__CrestLoad(i32 94, i64 %180, i64 %182)
%184 = load i32*, i32** %3
%185 = load i32, i32* %5
%186 = call i32 @adjust(i32* %184, i32 %185)
%187 = call i32 @__CrestClearStack(i32 95)
%188 = ptrtoint i32* %5 to i64
%189 = load i32, i32* %5
%190 = sext i32 %189 to i64
%191 = call i32 @__CrestLoad(i32 98, i64 %188, i64 %190)
%192 = call i32 @__CrestLoad(i32 97, i64 0, i64 1)
%193 = load i32, i32* %5
%194 = sub nsw i32 %193, 1
%195 = sext i32 %194 to i64
%196 = call i32 @__CrestApply2(i32 96, i32 1, i64 %195)
%197 = ptrtoint i32* %5 to i64
%198 = call i32 @__CrestStore(i32 99, i64 %197)
%199 = load i32, i32* %5
%200 = add nsw i32 %199, -1
store i32 %200, i32* %5
br label %203
201: ; preds = %122
%202 = call i32 @__CrestBranch(i32 87, i32 27, i32 0)
br label %203
203: ; preds = %201, %135
%204 = call i32 @__CrestReturn(i32 100)
ret void
}

LLVM IR (-O2):
define void @heapSort(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
%7 = bitcast i32* %5 to i8*
%8 = bitcast i32* %6 to i8*
%9 = tail call i32 @__CrestCall(i32 59, i32 2)
%10 = ptrtoint i32* %4 to i64
%11 = call i32 @__CrestStore(i32 58, i64 %10)
%12 = bitcast i32** %3 to i32*
%13 = call i32 @__CrestInt(i32* %12)
%14 = call i32 @__CrestInt(i32* %4)
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = call i32 @__CrestLoad(i32 60, i64 %10, i64 %16)
%18 = load i32*, i32** %3
%19 = load i32, i32* %4
%20 = call i32 @heapify(i32* %18, i32 %19)
%21 = call i32 @__CrestClearStack(i32 61)
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = call i32 @__CrestLoad(i32 64, i64 %10, i64 %23)
%25 = call i32 @__CrestLoad(i32 63, i64 0, i64 1)
%26 = load i32, i32* %4
%27 = add nsw i32 %26, -1
%28 = sext i32 %27 to i64
%29 = call i32 @__CrestApply2(i32 62, i32 1, i64 %28)
%30 = ptrtoint i32* %5 to i64
%31 = call i32 @__CrestStore(i32 65, i64 %30)
%32 = load i32, i32* %4
%33 = add nsw i32 %32, -1
store i32 %33, i32* %5
%34 = sext i32 %33 to i64
%35 = call i32 @__CrestLoad(i32 68, i64 %30, i64 %34)
%36 = call i32 @__CrestLoad(i32 67, i64 0, i64 0)
%37 = load i32, i32* %5
%38 = icmp sgt i32 %37, 0
%39 = zext i1 %38 to i64
%40 = call i32 @__CrestApply2(i32 66, i32 14, i64 %39)
%41 = load i32, i32* %5
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %92
43: ; preds = %2
%44 = call i32 @__CrestBranch(i32 69, i32 23, i32 1)
%45 = load i32*, i32** %3
%46 = ptrtoint i32* %45 to i64
%47 = load i32, i32* %45
%48 = sext i32 %47 to i64
%49 = call i32 @__CrestLoad(i32 71, i64 %46, i64 %48)
%50 = ptrtoint i32* %6 to i64
%51 = call i32 @__CrestStore(i32 72, i64 %50)
%52 = load i32, i32* %45
store i32 %52, i32* %6
%53 = load i32*, i32** %3
%54 = load i32, i32* %5
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* %53, i64 %55
%57 = ptrtoint i32* %56 to i64
%58 = load i32, i32* %56
%59 = sext i32 %58 to i64
%60 = call i32 @__CrestLoad(i32 73, i64 %57, i64 %59)
%61 = ptrtoint i32* %53 to i64
%62 = call i32 @__CrestStore(i32 74, i64 %61)
%63 = load i32, i32* %56
store i32 %63, i32* %53
%64 = load i32*, i32** %3
%65 = load i32, i32* %5
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %64, i64 %66
%68 = load i32, i32* %6
%69 = sext i32 %68 to i64
%70 = call i32 @__CrestLoad(i32 75, i64 %50, i64 %69)
%71 = ptrtoint i32* %67 to i64
%72 = call i32 @__CrestStore(i32 76, i64 %71)
%73 = load i32, i32* %6
store i32 %73, i32* %67
%74 = load i32, i32* %5
%75 = sext i32 %74 to i64
%76 = call i32 @__CrestLoad(i32 77, i64 %30, i64 %75)
%77 = load i32*, i32** %3
%78 = load i32, i32* %5
%79 = call i32 @adjust(i32* %77, i32 %78)
%80 = call i32 @__CrestClearStack(i32 78)
%81 = load i32, i32* %5
%82 = sext i32 %81 to i64
%83 = call i32 @__CrestLoad(i32 81, i64 %30, i64 %82)
%84 = call i32 @__CrestLoad(i32 80, i64 0, i64 1)
%85 = load i32, i32* %5
%86 = add nsw i32 %85, -1
%87 = sext i32 %86 to i64
%88 = call i32 @__CrestApply2(i32 79, i32 1, i64 %87)
%89 = call i32 @__CrestStore(i32 82, i64 %30)
%90 = load i32, i32* %5
%91 = add nsw i32 %90, -1
store i32 %91, i32* %5
br label %95
92: ; preds = %2
%93 = call i32 @__CrestBranch(i32 70, i32 24, i32 0)
%94 = load i32, i32* %5
br label %95
95: ; preds = %92, %43
%96 = phi i32 [ %94, %92 ], [ %91, %43 ]
%97 = sext i32 %96 to i64
%98 = call i32 @__CrestLoad(i32 85, i64 %30, i64 %97)
%99 = call i32 @__CrestLoad(i32 84, i64 0, i64 0)
%100 = load i32, i32* %5
%101 = icmp sgt i32 %100, 0
%102 = zext i1 %101 to i64
%103 = call i32 @__CrestApply2(i32 83, i32 14, i64 %102)
%104 = load i32, i32* %5
%105 = icmp sgt i32 %104, 0
br i1 %105, label %106, label %155
106: ; preds = %95
%107 = call i32 @__CrestBranch(i32 86, i32 26, i32 1)
%108 = load i32*, i32** %3
%109 = ptrtoint i32* %108 to i64
%110 = load i32, i32* %108
%111 = sext i32 %110 to i64
%112 = call i32 @__CrestLoad(i32 88, i64 %109, i64 %111)
%113 = ptrtoint i32* %6 to i64
%114 = call i32 @__CrestStore(i32 89, i64 %113)
%115 = load i32, i32* %108
store i32 %115, i32* %6
%116 = load i32*, i32** %3
%117 = load i32, i32* %5
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds i32, i32* %116, i64 %118
%120 = ptrtoint i32* %119 to i64
%121 = load i32, i32* %119
%122 = sext i32 %121 to i64
%123 = call i32 @__CrestLoad(i32 90, i64 %120, i64 %122)
%124 = ptrtoint i32* %116 to i64
%125 = call i32 @__CrestStore(i32 91, i64 %124)
%126 = load i32, i32* %119
store i32 %126, i32* %116
%127 = load i32*, i32** %3
%128 = load i32, i32* %5
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i32, i32* %127, i64 %129
%131 = load i32, i32* %6
%132 = sext i32 %131 to i64
%133 = call i32 @__CrestLoad(i32 92, i64 %113, i64 %132)
%134 = ptrtoint i32* %130 to i64
%135 = call i32 @__CrestStore(i32 93, i64 %134)
%136 = load i32, i32* %6
store i32 %136, i32* %130
%137 = load i32, i32* %5
%138 = sext i32 %137 to i64
%139 = call i32 @__CrestLoad(i32 94, i64 %30, i64 %138)
%140 = load i32*, i32** %3
%141 = load i32, i32* %5
%142 = call i32 @adjust(i32* %140, i32 %141)
%143 = call i32 @__CrestClearStack(i32 95)
%144 = load i32, i32* %5
%145 = sext i32 %144 to i64
%146 = call i32 @__CrestLoad(i32 98, i64 %30, i64 %145)
%147 = call i32 @__CrestLoad(i32 97, i64 0, i64 1)
%148 = load i32, i32* %5
%149 = add nsw i32 %148, -1
%150 = sext i32 %149 to i64
%151 = call i32 @__CrestApply2(i32 96, i32 1, i64 %150)
%152 = call i32 @__CrestStore(i32 99, i64 %30)
%153 = load i32, i32* %5
%154 = add nsw i32 %153, -1
store i32 %154, i32* %5
br label %157
155: ; preds = %95
%156 = call i32 @__CrestBranch(i32 87, i32 27, i32 0)
br label %157
157: ; preds = %155, %106
%158 = call i32 @__CrestReturn(i32 100)
ret void
}