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


x86 assembly (clang, -O0):
<heapSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x3f,%edi
mov    $0x4,%esi
call   1080 <__CrestCall@plt>
lea    -0xc(%rbp),%rsi
mov    $0x3e,%edi
call   1060 <__CrestStore@plt>
lea    -0x10(%rbp),%rdi
call   1090 <__CrestInt@plt>
lea    -0xc(%rbp),%rsi
movslq -0xc(%rbp),%rdx
mov    $0x40,%edi
call   10a0 <__CrestLoad@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   10b0 <heapify@plt>
mov    $0x41,%edi
call   10c0 <__CrestClearStack@plt>
lea    -0xc(%rbp),%rsi
movslq -0xc(%rbp),%rdx
mov    $0x44,%edi
call   10a0 <__CrestLoad@plt>
mov    $0x43,%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    $0x42,%edi
mov    $0x1,%esi
call   1030 <__CrestApply2@plt>
lea    -0x10(%rbp),%rsi
mov    $0x45,%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    $0x48,%edi
call   10a0 <__CrestLoad@plt>
mov    $0x47,%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    $0x46,%edi
mov    $0xe,%esi
call   1030 <__CrestApply2@plt>
cmpl   $0x0,-0x10(%rbp)
jle    13eb <heapSort+0x24b>
mov    $0x49,%edi
mov    $0x19,%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    $0x4b,%edi
call   10a0 <__CrestLoad@plt>
lea    -0x14(%rbp),%rsi
mov    $0x4c,%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    $0x4d,%edi
call   10a0 <__CrestLoad@plt>
mov    -0x28(%rbp),%rsi
mov    $0x4e,%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    $0x4f,%edi
call   10a0 <__CrestLoad@plt>
mov    -0x38(%rbp),%rsi
mov    $0x50,%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    $0x51,%edi
call   10a0 <__CrestLoad@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1040 <adjust@plt>
mov    $0x52,%edi
call   10c0 <__CrestClearStack@plt>
lea    -0x10(%rbp),%rsi
movslq -0x10(%rbp),%rdx
mov    $0x55,%edi
call   10a0 <__CrestLoad@plt>
mov    $0x54,%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    $0x53,%edi
mov    $0x1,%esi
call   1030 <__CrestApply2@plt>
lea    -0x10(%rbp),%rsi
mov    $0x56,%edi
call   1060 <__CrestStore@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    13fc <heapSort+0x25c>
mov    $0x4a,%edi
mov    $0x1a,%esi
xor    %edx,%edx
call   1050 <__CrestBranch@plt>
lea    -0x10(%rbp),%rsi
movslq -0x10(%rbp),%rdx
mov    $0x59,%edi
call   10a0 <__CrestLoad@plt>
mov    $0x58,%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    $0x57,%edi
mov    $0xe,%esi
call   1030 <__CrestApply2@plt>
cmpl   $0x0,-0x10(%rbp)
jle    1596 <heapSort+0x3f6>
mov    $0x5a,%edi
mov    $0x1c,%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    $0x5c,%edi
call   10a0 <__CrestLoad@plt>
lea    -0x14(%rbp),%rsi
mov    $0x5d,%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    $0x5e,%edi
call   10a0 <__CrestLoad@plt>
mov    -0x48(%rbp),%rsi
mov    $0x5f,%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    $0x60,%edi
call   10a0 <__CrestLoad@plt>
mov    -0x58(%rbp),%rsi
mov    $0x61,%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    $0x62,%edi
call   10a0 <__CrestLoad@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1040 <adjust@plt>
mov    $0x63,%edi
call   10c0 <__CrestClearStack@plt>
lea    -0x10(%rbp),%rsi
movslq -0x10(%rbp),%rdx
mov    $0x66,%edi
call   10a0 <__CrestLoad@plt>
mov    $0x65,%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    $0x64,%edi
mov    $0x1,%esi
call   1030 <__CrestApply2@plt>
lea    -0x10(%rbp),%rsi
mov    $0x67,%edi
call   1060 <__CrestStore@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    15a7 <heapSort+0x407>
mov    $0x5b,%edi
mov    $0x1d,%esi
xor    %edx,%edx
call   1050 <__CrestBranch@plt>
mov    $0x68,%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,%r12
mov    %esi,0x14(%rsp)
mov    $0x3f,%edi
mov    $0x4,%esi
call   1080 <__CrestCall@plt>
lea    0x14(%rsp),%r15
mov    $0x3e,%edi
mov    %r15,%rsi
call   1060 <__CrestStore@plt>
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   1090 <__CrestInt@plt>
movslq 0x14(%rsp),%rdx
mov    $0x40,%edi
mov    %r15,%rsi
call   10a0 <__CrestLoad@plt>
mov    0x14(%rsp),%esi
mov    %r12,%rdi
call   10b0 <heapify@plt>
mov    $0x41,%edi
call   10c0 <__CrestClearStack@plt>
movslq 0x14(%rsp),%rdx
mov    $0x44,%edi
mov    %r15,%rsi
call   10a0 <__CrestLoad@plt>
mov    $0x1,%edx
mov    $0x43,%edi
xor    %esi,%esi
call   10a0 <__CrestLoad@plt>
movslq 0x14(%rsp),%rdx
add    $0xffffffffffffffff,%rdx
mov    $0x42,%edi
mov    $0x1,%esi
call   1030 <__CrestApply2@plt>
mov    $0x45,%edi
mov    %r14,%rsi
call   1060 <__CrestStore@plt>
movslq 0x14(%rsp),%rdx
add    $0xffffffffffffffff,%rdx
mov    %edx,0xc(%rsp)
mov    $0x48,%edi
mov    %r14,%rsi
call   10a0 <__CrestLoad@plt>
mov    $0x47,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <__CrestLoad@plt>
xor    %edx,%edx
cmpl   $0x0,0xc(%rsp)
setg   %dl
mov    $0x46,%edi
mov    $0xe,%esi
call   1030 <__CrestApply2@plt>
cmpl   $0x0,0xc(%rsp)
jle    13b9 <heapSort+0x219>
mov    $0x49,%edi
mov    $0x19,%esi
mov    $0x1,%edx
call   1050 <__CrestBranch@plt>
movslq (%r12),%rdx
mov    $0x4b,%edi
mov    %r12,%rsi
call   10a0 <__CrestLoad@plt>
lea    0x10(%rsp),%r14
mov    $0x4c,%edi
mov    %r14,%rsi
call   1060 <__CrestStore@plt>
mov    (%r12),%eax
mov    %eax,0x10(%rsp)
movslq 0xc(%rsp),%rbx
lea    (%r12,%rbx,4),%rsi
movslq (%r12,%rbx,4),%rdx
mov    $0x4d,%edi
call   10a0 <__CrestLoad@plt>
mov    $0x4e,%edi
mov    %r12,%rsi
call   1060 <__CrestStore@plt>
mov    (%r12,%rbx,4),%eax
mov    %eax,(%r12)
movslq 0xc(%rsp),%rbx
lea    (%r12,%rbx,4),%r15
movslq 0x10(%rsp),%rdx
mov    $0x4f,%edi
mov    %r14,%rsi
call   10a0 <__CrestLoad@plt>
mov    $0x50,%edi
mov    %r15,%rsi
call   1060 <__CrestStore@plt>
mov    0x10(%rsp),%eax
mov    %eax,(%r12,%rbx,4)
movslq 0xc(%rsp),%rdx
lea    0xc(%rsp),%r14
mov    $0x51,%edi
mov    %r14,%rsi
call   10a0 <__CrestLoad@plt>
mov    0xc(%rsp),%esi
mov    %r12,%rdi
call   1040 <adjust@plt>
mov    $0x52,%edi
call   10c0 <__CrestClearStack@plt>
movslq 0xc(%rsp),%rdx
mov    $0x55,%edi
mov    %r14,%rsi
call   10a0 <__CrestLoad@plt>
mov    $0x1,%edx
mov    $0x54,%edi
xor    %esi,%esi
call   10a0 <__CrestLoad@plt>
movslq 0xc(%rsp),%rdx
add    $0xffffffffffffffff,%rdx
mov    $0x53,%edi
mov    $0x1,%esi
call   1030 <__CrestApply2@plt>
mov    $0x56,%edi
mov    %r14,%rsi
call   1060 <__CrestStore@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
mov    %eax,0xc(%rsp)
jmp    13ce <heapSort+0x22e>
mov    $0x4a,%edi
mov    $0x1a,%esi
xor    %edx,%edx
call   1050 <__CrestBranch@plt>
mov    0xc(%rsp),%eax
movslq %eax,%rdx
lea    0xc(%rsp),%rsi
mov    $0x59,%edi
call   10a0 <__CrestLoad@plt>
mov    $0x58,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <__CrestLoad@plt>
xor    %edx,%edx
cmpl   $0x0,0xc(%rsp)
setg   %dl
mov    $0x57,%edi
mov    $0xe,%esi
call   1030 <__CrestApply2@plt>
cmpl   $0x0,0xc(%rsp)
jle    1529 <heapSort+0x389>
mov    $0x5a,%edi
mov    $0x1c,%esi
mov    $0x1,%edx
call   1050 <__CrestBranch@plt>
movslq (%r12),%rdx
mov    $0x5c,%edi
mov    %r12,%rsi
call   10a0 <__CrestLoad@plt>
lea    0x10(%rsp),%r14
mov    $0x5d,%edi
mov    %r14,%rsi
call   1060 <__CrestStore@plt>
mov    (%r12),%eax
mov    %eax,0x10(%rsp)
movslq 0xc(%rsp),%rbx
lea    (%r12,%rbx,4),%rsi
movslq (%r12,%rbx,4),%rdx
mov    $0x5e,%edi
call   10a0 <__CrestLoad@plt>
mov    $0x5f,%edi
mov    %r12,%rsi
call   1060 <__CrestStore@plt>
mov    (%r12,%rbx,4),%eax
mov    %eax,(%r12)
movslq 0xc(%rsp),%rbx
lea    (%r12,%rbx,4),%r15
movslq 0x10(%rsp),%rdx
mov    $0x60,%edi
mov    %r14,%rsi
call   10a0 <__CrestLoad@plt>
mov    $0x61,%edi
mov    %r15,%rsi
call   1060 <__CrestStore@plt>
mov    0x10(%rsp),%eax
mov    %eax,(%r12,%rbx,4)
movslq 0xc(%rsp),%rdx
lea    0xc(%rsp),%r14
mov    $0x62,%edi
mov    %r14,%rsi
call   10a0 <__CrestLoad@plt>
mov    0xc(%rsp),%esi
mov    %r12,%rdi
call   1040 <adjust@plt>
mov    $0x63,%edi
call   10c0 <__CrestClearStack@plt>
movslq 0xc(%rsp),%rdx
mov    $0x66,%edi
mov    %r14,%rsi
call   10a0 <__CrestLoad@plt>
mov    $0x1,%edx
mov    $0x65,%edi
xor    %esi,%esi
call   10a0 <__CrestLoad@plt>
movslq 0xc(%rsp),%rdx
add    $0xffffffffffffffff,%rdx
mov    $0x64,%edi
mov    $0x1,%esi
call   1030 <__CrestApply2@plt>
mov    $0x67,%edi
mov    %r14,%rsi
call   1060 <__CrestStore@plt>
addl   $0xffffffff,0xc(%rsp)
jmp    153a <heapSort+0x39a>
mov    $0x5b,%edi
mov    $0x1d,%esi
xor    %edx,%edx
call   1050 <__CrestBranch@plt>
mov    $0x68,%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 63, i32 4)
%16 = ptrtoint i32* %4 to i64
%17 = call i32 @__CrestStore(i32 62, i64 %16)
%18 = call i32 @__CrestInt(i32* %5)
%19 = ptrtoint i32* %4 to i64
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = call i32 @__CrestLoad(i32 64, i64 %19, i64 %21)
%23 = load i32*, i32** %3
%24 = load i32, i32* %4
%25 = call i32 @heapify(i32* %23, i32 %24)
%26 = call i32 @__CrestClearStack(i32 65)
%27 = ptrtoint i32* %4 to i64
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = call i32 @__CrestLoad(i32 68, i64 %27, i64 %29)
%31 = call i32 @__CrestLoad(i32 67, i64 0, i64 1)
%32 = load i32, i32* %4
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = call i32 @__CrestApply2(i32 66, i32 1, i64 %34)
%36 = ptrtoint i32* %5 to i64
%37 = call i32 @__CrestStore(i32 69, i64 %36)
%38 = load i32, i32* %4
%39 = sub nsw i32 %38, 1
store i32 %39, i32* %5
%40 = ptrtoint i32* %5 to i64
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = call i32 @__CrestLoad(i32 72, i64 %40, i64 %42)
%44 = call i32 @__CrestLoad(i32 71, i64 0, i64 0)
%45 = load i32, i32* %5
%46 = icmp sgt i32 %45, 0
%47 = zext i1 %46 to i32
%48 = sext i32 %47 to i64
%49 = call i32 @__CrestApply2(i32 70, i32 14, i64 %48)
%50 = load i32, i32* %5
%51 = icmp sgt i32 %50, 0
br i1 %51, label %52, label %118
52: ; preds = %2
%53 = call i32 @__CrestBranch(i32 73, i32 25, i32 1)
%54 = load i32*, i32** %3
%55 = getelementptr inbounds i32, i32* %54, i64 0
store i32* %55, i32** %7
%56 = load i32*, i32** %7
%57 = ptrtoint i32* %56 to i64
%58 = load i32*, i32** %7
%59 = load i32, i32* %58
%60 = sext i32 %59 to i64
%61 = call i32 @__CrestLoad(i32 75, i64 %57, i64 %60)
%62 = ptrtoint i32* %6 to i64
%63 = call i32 @__CrestStore(i32 76, i64 %62)
%64 = load i32*, i32** %7
%65 = load i32, i32* %64
store i32 %65, i32* %6
%66 = load i32*, i32** %3
%67 = getelementptr inbounds i32, i32* %66, i64 0
store i32* %67, i32** %8
%68 = load i32*, i32** %3
%69 = load i32, i32* %5
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %68, i64 %70
store i32* %71, i32** %9
%72 = load i32*, i32** %9
%73 = ptrtoint i32* %72 to i64
%74 = load i32*, i32** %9
%75 = load i32, i32* %74
%76 = sext i32 %75 to i64
%77 = call i32 @__CrestLoad(i32 77, i64 %73, i64 %76)
%78 = load i32*, i32** %8
%79 = ptrtoint i32* %78 to i64
%80 = call i32 @__CrestStore(i32 78, i64 %79)
%81 = load i32*, i32** %9
%82 = load i32, i32* %81
%83 = load i32*, i32** %8
store i32 %82, i32* %83
%84 = load i32*, i32** %3
%85 = load i32, i32* %5
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i32, i32* %84, i64 %86
store i32* %87, i32** %10
%88 = ptrtoint i32* %6 to i64
%89 = load i32, i32* %6
%90 = sext i32 %89 to i64
%91 = call i32 @__CrestLoad(i32 79, i64 %88, i64 %90)
%92 = load i32*, i32** %10
%93 = ptrtoint i32* %92 to i64
%94 = call i32 @__CrestStore(i32 80, i64 %93)
%95 = load i32, i32* %6
%96 = load i32*, i32** %10
store i32 %95, i32* %96
%97 = ptrtoint i32* %5 to i64
%98 = load i32, i32* %5
%99 = sext i32 %98 to i64
%100 = call i32 @__CrestLoad(i32 81, i64 %97, i64 %99)
%101 = load i32*, i32** %3
%102 = load i32, i32* %5
%103 = call i32 @adjust(i32* %101, i32 %102)
%104 = call i32 @__CrestClearStack(i32 82)
%105 = ptrtoint i32* %5 to i64
%106 = load i32, i32* %5
%107 = sext i32 %106 to i64
%108 = call i32 @__CrestLoad(i32 85, i64 %105, i64 %107)
%109 = call i32 @__CrestLoad(i32 84, i64 0, i64 1)
%110 = load i32, i32* %5
%111 = sub nsw i32 %110, 1
%112 = sext i32 %111 to i64
%113 = call i32 @__CrestApply2(i32 83, i32 1, i64 %112)
%114 = ptrtoint i32* %5 to i64
%115 = call i32 @__CrestStore(i32 86, i64 %114)
%116 = load i32, i32* %5
%117 = add nsw i32 %116, -1
store i32 %117, i32* %5
br label %120
118: ; preds = %2
%119 = call i32 @__CrestBranch(i32 74, i32 26, i32 0)
br label %120
120: ; preds = %118, %52
%121 = ptrtoint i32* %5 to i64
%122 = load i32, i32* %5
%123 = sext i32 %122 to i64
%124 = call i32 @__CrestLoad(i32 89, i64 %121, i64 %123)
%125 = call i32 @__CrestLoad(i32 88, i64 0, i64 0)
%126 = load i32, i32* %5
%127 = icmp sgt i32 %126, 0
%128 = zext i1 %127 to i32
%129 = sext i32 %128 to i64
%130 = call i32 @__CrestApply2(i32 87, i32 14, i64 %129)
%131 = load i32, i32* %5
%132 = icmp sgt i32 %131, 0
br i1 %132, label %133, label %199
133: ; preds = %120
%134 = call i32 @__CrestBranch(i32 90, i32 28, i32 1)
%135 = load i32*, i32** %3
%136 = getelementptr inbounds i32, i32* %135, i64 0
store i32* %136, i32** %11
%137 = load i32*, i32** %11
%138 = ptrtoint i32* %137 to i64
%139 = load i32*, i32** %11
%140 = load i32, i32* %139
%141 = sext i32 %140 to i64
%142 = call i32 @__CrestLoad(i32 92, i64 %138, i64 %141)
%143 = ptrtoint i32* %6 to i64
%144 = call i32 @__CrestStore(i32 93, i64 %143)
%145 = load i32*, i32** %11
%146 = load i32, i32* %145
store i32 %146, i32* %6
%147 = load i32*, i32** %3
%148 = getelementptr inbounds i32, i32* %147, i64 0
store i32* %148, i32** %12
%149 = load i32*, i32** %3
%150 = load i32, i32* %5
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds i32, i32* %149, i64 %151
store i32* %152, i32** %13
%153 = load i32*, i32** %13
%154 = ptrtoint i32* %153 to i64
%155 = load i32*, i32** %13
%156 = load i32, i32* %155
%157 = sext i32 %156 to i64
%158 = call i32 @__CrestLoad(i32 94, i64 %154, i64 %157)
%159 = load i32*, i32** %12
%160 = ptrtoint i32* %159 to i64
%161 = call i32 @__CrestStore(i32 95, i64 %160)
%162 = load i32*, i32** %13
%163 = load i32, i32* %162
%164 = load i32*, i32** %12
store i32 %163, i32* %164
%165 = load i32*, i32** %3
%166 = load i32, i32* %5
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds i32, i32* %165, i64 %167
store i32* %168, i32** %14
%169 = ptrtoint i32* %6 to i64
%170 = load i32, i32* %6
%171 = sext i32 %170 to i64
%172 = call i32 @__CrestLoad(i32 96, i64 %169, i64 %171)
%173 = load i32*, i32** %14
%174 = ptrtoint i32* %173 to i64
%175 = call i32 @__CrestStore(i32 97, i64 %174)
%176 = load i32, i32* %6
%177 = load i32*, i32** %14
store i32 %176, i32* %177
%178 = ptrtoint i32* %5 to i64
%179 = load i32, i32* %5
%180 = sext i32 %179 to i64
%181 = call i32 @__CrestLoad(i32 98, i64 %178, i64 %180)
%182 = load i32*, i32** %3
%183 = load i32, i32* %5
%184 = call i32 @adjust(i32* %182, i32 %183)
%185 = call i32 @__CrestClearStack(i32 99)
%186 = ptrtoint i32* %5 to i64
%187 = load i32, i32* %5
%188 = sext i32 %187 to i64
%189 = call i32 @__CrestLoad(i32 102, i64 %186, i64 %188)
%190 = call i32 @__CrestLoad(i32 101, i64 0, i64 1)
%191 = load i32, i32* %5
%192 = sub nsw i32 %191, 1
%193 = sext i32 %192 to i64
%194 = call i32 @__CrestApply2(i32 100, i32 1, i64 %193)
%195 = ptrtoint i32* %5 to i64
%196 = call i32 @__CrestStore(i32 103, i64 %195)
%197 = load i32, i32* %5
%198 = add nsw i32 %197, -1
store i32 %198, i32* %5
br label %201
199: ; preds = %120
%200 = call i32 @__CrestBranch(i32 91, i32 29, i32 0)
br label %201
201: ; preds = %199, %133
%202 = call i32 @__CrestReturn(i32 104)
ret void
}

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