#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*/ minheap_insert(int);
int /*<<< orphan*/ minheap_print();
int /*<<< orphan*/ minheap_remove(int);
int /*<<< orphan*/ printf(char *, ...);
void main() {
  int a[] = {80, 40, 30, 60, 90, 70, 10, 50, 20};
  int i, len = ((sizeof(a)) / (sizeof(a[0])));
  printf("== 依次添加: ");
  for (i = 0; i < len; i++) {
    printf("%d ", a[i]);
    minheap_insert(a[i]);
  }
  printf("\n== 最 小 堆: ");
  minheap_print();
  i = 15;
  minheap_insert(i);
  printf("\n== 添加元素: %d", i);
  printf("\n== 最 小 堆: ");
  minheap_print();
  i = 10;
  minheap_remove(i);
  printf("\n== 删除元素: %d", i);
  printf("\n== 最 小 堆: ");
  minheap_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   1050 <memcpy@plt>
movl   $0x9,-0x38(%rbp)
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <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   1030 <printf@plt>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edi
call   1040 <minheap_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   1030 <printf@plt>
mov    $0x0,%al
call   1060 <minheap_print@plt>
movl   $0xf,-0x34(%rbp)
mov    -0x34(%rbp),%edi
call   1040 <minheap_insert@plt>
mov    -0x34(%rbp),%esi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <minheap_print@plt>
movl   $0xa,-0x34(%rbp)
mov    -0x34(%rbp),%edi
call   1070 <minheap_remove@plt>
mov    -0x34(%rbp),%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <minheap_print@plt>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@__const.main.a = [9 x i32] [i32 80, i32 40, i32 30, i32 60, i32 90, i32 70, i32 10, i32 50, i32 20]
@.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\B0\8F \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 @minheap_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 (...) @minheap_print()
store i32 15, i32* %2
%27 = load i32, i32* %2
%28 = call i32 @minheap_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 (...) @minheap_print()
store i32 10, i32* %2
%33 = load i32, i32* %2
%34 = call i32 @minheap_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 (...) @minheap_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\B0\8F \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 80)
%3 = tail call i32 @minheap_insert(i32 80)
%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 @minheap_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 @minheap_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 @minheap_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 @minheap_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 @minheap_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 10)
%15 = tail call i32 @minheap_insert(i32 10)
%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 @minheap_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 20)
%19 = tail call i32 @minheap_insert(i32 20)
%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 (...) @minheap_print()
%22 = tail call i32 @minheap_insert(i32 15)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 15)
%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 (...) @minheap_print()
%26 = tail call i32 @minheap_remove(i32 10)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 10)
%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 (...) @minheap_print()
%30 = tail call i32 @putchar(i32 10)
ret void
}