#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*/ heapify(int *, int, int);
int /*<<< orphan*/ swap(int /*<<< orphan*/, int, int *);
void heapSort(int *numbers, int size) {
  int i, tmp;
  for (i = size / 2 - 1; i >= 0; i--) {
    heapify(numbers, size, i);
  }
  for (i = size - 1; i >= 0; i--) {
    swap(0, i, numbers);
    heapify(numbers, i, 0);
  }
}


x86 assembly (clang, -O0):
<heapSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     1167 <heapSort+0x47>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <heapify@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1140 <heapSort+0x20>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     11a4 <heapSort+0x84>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rdx
xor    %edi,%edi
call   1040 <swap@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
xor    %edx,%edx
call   1030 <heapify@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1170 <heapSort+0x50>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<heapSort>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
cmp    $0x2,%esi
jl     1155 <heapSort+0x35>
mov    %ebp,%ebx
shr    %ebx
add    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x2(%rbx),%edx
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <heapify@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1140 <heapSort+0x20>
test   %ebp,%ebp
jle    1183 <heapSort+0x63>
add    $0x1,%ebp
nopl   0x0(%rax)
lea    -0x2(%rbp),%ebx
xor    %edi,%edi
mov    %ebx,%esi
mov    %r14,%rdx
call   1040 <swap@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %edx,%edx
call   1030 <heapify@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1160 <heapSort+0x40>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
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 = load i32, i32* %4
%8 = sdiv i32 %7, 2
%9 = sub nsw i32 %8, 1
store i32 %9, i32* %5
br label %10
10: ; preds = %18, %2
%11 = load i32, i32* %5
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = load i32*, i32** %3
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = call i32 @heapify(i32* %14, i32 %15, i32 %16)
br label %18
18: ; preds = %13
%19 = load i32, i32* %5
%20 = add nsw i32 %19, -1
store i32 %20, i32* %5
br label %10
21: ; preds = %10
%22 = load i32, i32* %4
%23 = sub nsw i32 %22, 1
store i32 %23, i32* %5
br label %24
24: ; preds = %34, %21
%25 = load i32, i32* %5
%26 = icmp sge i32 %25, 0
br i1 %26, label %27, label %37
27: ; preds = %24
%28 = load i32, i32* %5
%29 = load i32*, i32** %3
%30 = call i32 @swap(i32 0, i32 %28, i32* %29)
%31 = load i32*, i32** %3
%32 = load i32, i32* %5
%33 = call i32 @heapify(i32* %31, i32 %32, i32 0)
br label %34
34: ; preds = %27
%35 = load i32, i32* %5
%36 = add nsw i32 %35, -1
store i32 %36, i32* %5
br label %24
37: ; preds = %24
ret void
}

LLVM IR (-O2):
define void @heapSort(i32* %0, i32 %1) {
%3 = icmp sgt i32 %1, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = lshr i32 %1, 1
br label %8
6: ; preds = %8, %2
%7 = icmp sgt i32 %1, 0
br i1 %7, label %13, label %19
8: ; preds = %4, %8
%9 = phi i32 [ %10, %8 ], [ %5, %4 ]
%10 = add nsw i32 %9, -1
%11 = tail call i32 @heapify(i32* %0, i32 %1, i32 %10)
%12 = icmp ugt i32 %9, 1
br i1 %12, label %8, label %6
13: ; preds = %6, %13
%14 = phi i32 [ %15, %13 ], [ %1, %6 ]
%15 = add nsw i32 %14, -1
%16 = tail call i32 @swap(i32 0, i32 %15, i32* %0)
%17 = tail call i32 @heapify(i32* %0, i32 %15, i32 0)
%18 = icmp ugt i32 %14, 1
br i1 %18, label %13, label %19
19: ; preds = %13, %6
ret void
}