#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*/ buildTree(int *, int *);
int /*<<< orphan*/ printTab(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sort(int *, int *);
int main() {
  int tab[18] = {17, 3, 5, 6, 2, 8, 9, 11, 7, 4, 10, 12, 15, 20, 1, 19, 13, 17};
  int tree[18] = {0};
  buildTree(tab, tree);
  printf("init tab : \n");
  printTab(tab, 18);
  printf("\n");
  printf("heap :\n");
  buildTree(tab, tree);
  printTab(tree, 18);
  printf("\n");
  sort(tree, tab);
  printf("sorted tab : \n");
  printTab(tab, 18);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe83(%rip),%rsi
mov    $0x48,%edx
call   1080 <memcpy@plt>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1060 <memset@plt>
lea    -0x50(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1070 <buildTree@plt>
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    $0x12,%esi
call   1040 <printTab@plt>
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1070 <buildTree@plt>
lea    -0xa0(%rbp),%rdi
mov    $0x12,%esi
call   1040 <printTab@plt>
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
lea    -0xa0(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <sort@plt>
lea    0xe3d(%rip),%rdi
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    $0x12,%esi
call   1040 <printTab@plt>
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x98,%rsp
mov    0xedf(%rip),%rax
mov    %rax,0x90(%rsp)
movaps 0xec0(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xea1(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe85(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe69(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x40(%rsp)
lea    0x50(%rsp),%rbx
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <buildTree@plt>
lea    0xe73(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    $0x12,%esi
call   1050 <printTab@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe5c(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <buildTree@plt>
mov    %r14,%rdi
mov    $0x12,%esi
call   1050 <printTab@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <sort@plt>
lea    0xe2a(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    $0x12,%esi
call   1050 <printTab@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.tab = [18 x i32] [i32 17, i32 3, i32 5, i32 6, i32 2, i32 8, i32 9, i32 11, i32 7, i32 4, i32 10, i32 12, i32 15, i32 20, i32 1, i32 19, i32 13, i32 17]
@.str = [13 x i8] c"init tab : \0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [8 x i8] c"heap :\0A\00"
@.str.3 = [15 x i8] c"sorted tab : \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [18 x i32]
%3 = alloca [18 x i32]
store i32 0, i32* %1
%4 = bitcast [18 x i32]* %2 to i8*
%5 = bitcast [18 x i32]* %3 to i8*
%6 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 0
%7 = getelementptr inbounds [18 x i32], [18 x i32]* %3, i64 0, i64 0
%8 = call i32 @buildTree(i32* %6, i32* %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 0
%11 = call i32 @printTab(i32* %10, i32 18)
%12 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%14 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 0
%15 = getelementptr inbounds [18 x i32], [18 x i32]* %3, i64 0, i64 0
%16 = call i32 @buildTree(i32* %14, i32* %15)
%17 = getelementptr inbounds [18 x i32], [18 x i32]* %3, i64 0, i64 0
%18 = call i32 @printTab(i32* %17, i32 18)
%19 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = getelementptr inbounds [18 x i32], [18 x i32]* %3, i64 0, i64 0
%21 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 0
%22 = call i32 @sort(i32* %20, i32* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%24 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 0
%25 = call i32 @printTab(i32* %24, i32 18)
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.tab = [18 x i32] [i32 17, i32 3, i32 5, i32 6, i32 2, i32 8, i32 9, i32 11, i32 7, i32 4, i32 10, i32 12, i32 15, i32 20, i32 1, i32 19, i32 13, i32 17]
@str = [12 x i8] c"init tab : \00"
@str.4 = [7 x i8] c"heap :\00"
@str.5 = [14 x i8] c"sorted tab : \00"
define i32 @main() {
%1 = alloca [18 x i32]
%2 = alloca [18 x i32]
%3 = bitcast [18 x i32]* %1 to i8*
%4 = bitcast [18 x i32]* %2 to i8*
%5 = getelementptr inbounds [18 x i32], [18 x i32]* %1, i64 0, i64 0
%6 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 0
%7 = call i32 @buildTree(i32* %5, i32* %6)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%9 = call i32 @printTab(i32* %5, i32 18)
%10 = call i32 @putchar(i32 10)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.4, i64 0, i64 0))
%12 = call i32 @buildTree(i32* %5, i32* %6)
%13 = call i32 @printTab(i32* %6, i32 18)
%14 = call i32 @putchar(i32 10)
%15 = call i32 @sort(i32* %6, i32* %5)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.5, i64 0, i64 0))
%17 = call i32 @printTab(i32* %5, i32 18)
%18 = call i32 @putchar(i32 10)
ret i32 0
}