#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 */
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ heap_sort(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i, r;
  int a[] = {10000, -999, 240, 1111111, 3, 2, 452, -65};
  int size = sizeof(a) / sizeof(a[0]);
  heap_sort(a, size);
  printf("After Sorting:\t");
  for (i = 0; i < size; i++) {
    printf("%d ", a[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec1(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x8,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1030 <heap_sort@plt>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11b3 <main+0x93>
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1183 <main+0x63>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movaps 0xee4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x8,%esi
call   1030 <heap_sort@plt>
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%esi
lea    0xecf(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@__const.main.a = [8 x i32] [i32 10000, i32 -999, i32 240, i32 1111111, i32 3, i32 2, i32 452, i32 -65]
@.str = [16 x i8] c"After Sorting:\09\00"
@.str.1 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [8 x i32]
%2 = bitcast [8 x i32]* %1 to i8*
%3 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%4 = call i32 @heap_sort(i32* %3, i32 8)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* %3
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 1
%9 = load i32, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 2
%12 = load i32, i32* %11
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 3
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 4
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 5
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 6
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 7
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %27)
ret i32 0
}