#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*/ maxheap_insert(int);
int /*<<< orphan*/ maxheap_print();
int /*<<< orphan*/ maxheap_remove(int);
int /*<<< orphan*/ printf(char *, ...);
void main() {
  int a[] = {10, 40, 30, 60, 90, 70, 20, 50, 80};
  int i, len = ((sizeof(a)) / (sizeof(a[0])));
  printf("== 依次添加: ");
  for (i = 0; i < len; i++) {
    printf("%d ", a[i]);
    maxheap_insert(a[i]);
  }
  printf("\n== 最 大 堆: ");
  maxheap_print();
  i = 85;
  maxheap_insert(i);
  printf("\n== 添加元素: %d", i);
  printf("\n== 最 大 堆: ");
  maxheap_print();
  i = 90;
  maxheap_remove(i);
  printf("\n== 删除元素: %d", i);
  printf("\n== 最 大 堆: ");
  maxheap_print();
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x30(%rbp),%rdi
lea    0xe9d(%rip),%rsi
mov    $0x24,%edx
call   1070 <memcpy@plt>
movl   $0x9,-0x38(%rbp)
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    11c6 <main+0x76>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edi
call   1030 <maxheap_insert@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1189 <main+0x39>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <maxheap_print@plt>
movl   $0x55,-0x34(%rbp)
mov    -0x34(%rbp),%edi
call   1030 <maxheap_insert@plt>
mov    -0x34(%rbp),%esi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <maxheap_print@plt>
movl   $0x5a,-0x34(%rbp)
mov    -0x34(%rbp),%edi
call   1060 <maxheap_remove@plt>
mov    -0x34(%rbp),%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <maxheap_print@plt>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xeac(%rip),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <maxheap_insert@plt>
mov    %rbx,%rdi
mov    $0x28,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x28,%edi
call   1030 <maxheap_insert@plt>
mov    %rbx,%rdi
mov    $0x1e,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1e,%edi
call   1030 <maxheap_insert@plt>
mov    %rbx,%rdi
mov    $0x3c,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x3c,%edi
call   1030 <maxheap_insert@plt>
mov    %rbx,%rdi
mov    $0x5a,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x5a,%edi
call   1030 <maxheap_insert@plt>
mov    %rbx,%rdi
mov    $0x46,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x46,%edi
call   1030 <maxheap_insert@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x14,%edi
call   1030 <maxheap_insert@plt>
mov    %rbx,%rdi
mov    $0x32,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x32,%edi
call   1030 <maxheap_insert@plt>
mov    %rbx,%rdi
mov    $0x50,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x50,%edi
call   1030 <maxheap_insert@plt>
lea    0xdc8(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <maxheap_print@plt>
mov    $0x55,%edi
call   1030 <maxheap_insert@plt>
lea    0xdb8(%rip),%rdi
mov    $0x55,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <maxheap_print@plt>
mov    $0x5a,%edi
call   1070 <maxheap_remove@plt>
lea    0xd9f(%rip),%rdi
mov    $0x5a,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <maxheap_print@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1040 <putchar@plt>

LLVM IR (-O0):
@__const.main.a = [9 x i32] [i32 10, i32 40, i32 30, i32 60, i32 90, i32 70, i32 20, i32 50, i32 80]
@.str = [18 x i8] c"== \E4\BE\9D\E6\AC\A1\E6\B7\BB\E5\8A\A0: \00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [18 x i8] c"\0A== \E6\9C\80 \E5\A4\A7 \E5\A0\86: \00"
@.str.3 = [21 x i8] c"\0A== \E6\B7\BB\E5\8A\A0\E5\85\83\E7\B4\A0: %d\00"
@.str.4 = [21 x i8] c"\0A== \E5\88\A0\E9\99\A4\E5\85\83\E7\B4\A0: %d\00"
@.str.5 = [2 x i8] c"\0A\00"
define void @main() {
%1 = alloca [9 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [9 x i32]* %1 to i8*
store i32 9, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %6
6: ; preds = %21, %0
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %24
10: ; preds = %6
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = call i32 @maxheap_insert(i32 %19)
br label %21
21: ; preds = %10
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
store i32 %23, i32* %2
br label %6
24: ; preds = %6
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 (...) @maxheap_print()
store i32 85, i32* %2
%27 = load i32, i32* %2
%28 = call i32 @maxheap_insert(i32 %27)
%29 = load i32, i32* %2
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 (...) @maxheap_print()
store i32 90, i32* %2
%33 = load i32, i32* %2
%34 = call i32 @maxheap_remove(i32 %33)
%35 = load i32, i32* %2
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 (...) @maxheap_print()
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"== \E4\BE\9D\E6\AC\A1\E6\B7\BB\E5\8A\A0: \00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [18 x i8] c"\0A== \E6\9C\80 \E5\A4\A7 \E5\A0\86: \00"
@.str.3 = [21 x i8] c"\0A== \E6\B7\BB\E5\8A\A0\E5\85\83\E7\B4\A0: %d\00"
@.str.4 = [21 x i8] c"\0A== \E5\88\A0\E9\99\A4\E5\85\83\E7\B4\A0: %d\00"
define void @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 10)
%3 = tail call i32 @maxheap_insert(i32 10)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 40)
%5 = tail call i32 @maxheap_insert(i32 40)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 30)
%7 = tail call i32 @maxheap_insert(i32 30)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 60)
%9 = tail call i32 @maxheap_insert(i32 60)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 90)
%11 = tail call i32 @maxheap_insert(i32 90)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 70)
%13 = tail call i32 @maxheap_insert(i32 70)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 20)
%15 = tail call i32 @maxheap_insert(i32 20)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 50)
%17 = tail call i32 @maxheap_insert(i32 50)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 80)
%19 = tail call i32 @maxheap_insert(i32 80)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 (...) @maxheap_print()
%22 = tail call i32 @maxheap_insert(i32 85)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 85)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%25 = tail call i32 (...) @maxheap_print()
%26 = tail call i32 @maxheap_remove(i32 90)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 90)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%29 = tail call i32 (...) @maxheap_print()
%30 = tail call i32 @putchar(i32 10)
ret void
}