#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*/ heapSort(int *, int);
int /*<<< orphan*/ printArray(int *, int);
int /*<<< orphan*/ printf(char *);
void test_heapSort() {
  printf("TEST: heapSort\n");
  int test[] = {31, 41, 59, 26, 53, 58, 97};
  printf("Before heapSort: ");
  printArray(test, 7);
  heapSort(test, 7);
  printf("After heapSort: ");
  printArray(test, 7);
}


x86 assembly (clang, -O0):
<test_heapSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
mov    0xef5(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xef2(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeef(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xeed(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x7,%esi
call   1050 <printArray@plt>
lea    -0x20(%rbp),%rdi
mov    $0x7,%esi
call   1030 <heapSort@plt>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x7,%esi
call   1050 <printArray@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_heapSort>:
push   %rbx
sub    $0x20,%rsp
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
movups 0xeb4(%rip),%xmm0
movups %xmm0,0xc(%rsp)
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xead(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x7,%esi
call   1060 <printArray@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1040 <heapSort@plt>
lea    0xe96(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1060 <printArray@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"TEST: heapSort\0A\00"
@__const.test_heapSort.test = [7 x i32] [i32 31, i32 41, i32 59, i32 26, i32 53, i32 58, i32 97]
@.str.1 = [18 x i8] c"Before heapSort: \00"
@.str.2 = [17 x i8] c"After heapSort: \00"
define void @test_heapSort() {
%1 = alloca [7 x i32]
%2 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%3 = bitcast [7 x i32]* %1 to i8*
%4 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%5 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%6 = call i32 @printArray(i32* %5, i32 7)
%7 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%8 = call i32 @heapSort(i32* %7, i32 7)
%9 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%11 = call i32 @printArray(i32* %10, i32 7)
ret void
}

LLVM IR (-O2):
@__const.test_heapSort.test = [7 x i32] [i32 31, i32 41, i32 59, i32 26, i32 53, i32 58, i32 97]
@.str.1 = [18 x i8] c"Before heapSort: \00"
@.str.2 = [17 x i8] c"After heapSort: \00"
@str = [15 x i8] c"TEST: heapSort\00"
define void @test_heapSort() {
%1 = alloca [7 x i32]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%3 = bitcast [7 x i32]* %1 to i8*
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%5 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%6 = call i32 @printArray(i32* %5, i32 7)
%7 = call i32 @heapSort(i32* %5, i32 7)
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @printArray(i32* %5, i32 7)
ret void
}