#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*/ heap_sort(int *, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char const *argv[]) {
  int array[] = {3, 2, 5, 1, 6};
  heap_sort(array, 5);
  int k = 0;
  for (; k < 5; k++) {
    printf("%d\n", array[k]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xebe(%rip),%eax
mov    %eax,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   1030 <heap_sort@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x5,-0x34(%rbp)
jge    1196 <main+0x76>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    116a <main+0x4a>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    0xee5(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xeca(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x5,%esi
call   1030 <heap_sort@plt>
mov    (%rsp),%esi
lea    0xec3(%rip),%rbx
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.array = [5 x i32] [i32 3, i32 2, i32 5, i32 1, i32 6]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5 x i32]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [5 x i32]* %6 to i8*
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%10 = call i32 @heap_sort(i32* %9, i32 5)
store i32 0, i32* %7
br label %11
11: ; preds = %20, %2
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 5
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %14
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
br label %11
23: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@__const.main.array = [5 x i32] [i32 3, i32 2, i32 5, i32 1, i32 6]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [5 x i32]
%4 = bitcast [5 x i32]* %3 to i8*
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%6 = call i32 @heap_sort(i32* %5, i32 5)
%7 = load i32, i32* %5
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 1
%10 = load i32, i32* %9
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 2
%13 = load i32, i32* %12
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 3
%16 = load i32, i32* %15
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 4
%19 = load i32, i32* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
ret i32 0
}