#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*/ FILE;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(int *);
int get_a_num(int /*<<< orphan*/ *);
int /*<<< orphan*/ init_heap(int *, int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sink_heap(int *, int);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("please use topk file num\n");
    return 0;
  }
  int k = atoi(argv[2]);
  char *path = argv[1];
  int i = 0;
  int *num = (int *)malloc(sizeof(int) * (k + 2));
  FILE *fp;
  if ((fp = fopen(path, "r")) == NULL) {
    printf("read error \n");
    return 0;
  }
  for (i = 1; i <= k; i++) {
    num[i] = get_a_num(fp);
  }
  printf("读取后的数据：\n");
  for (i = 1; i <= k; i++) {
    printf("%d\t", num[i]);
  }
  printf("\n");
  printf("\n");
  printf("\n");
  printf("\n");
  printf("\n");
  for (i = k / 2; i >= 1; i--) {
    init_heap(num, i, k);
  }
  printf("初始化堆后的数据：\n");
  for (i = 1; i <= k; i++) {
    printf("%d\t", num[i]);
  }
  printf("\n");
  printf("\n");
  printf("\n");
  printf("\n");
  printf("\n");
  int n;
  while (1) {
    n = get_a_num(fp);
    if (n == -1)
      break;
    if (n <= num[1])
      continue;
    num[k + 1] = n;
    sink_heap(num, k + 1);
  }
  printf("最终数据：\n");
  for (i = 1; i <= k; i++) {
    printf("%d\t", num[i]);
  }
  printf("\n");
  fclose(fp);
  free(num);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11ca <main+0x3a>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1483 <main+0x2f3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe0b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    123c <main+0xac>
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1483 <main+0x2f3>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1273 <main+0xe3>
mov    -0x38(%rbp),%rdi
call   1070 <get_a_num@plt>
mov    %eax,%edx
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1243 <main+0xb3>
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     12bb <main+0x12b>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1288 <main+0xf8>
lea    0xd65(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd49(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd3b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd2d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jl     1336 <main+0x1a6>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1090 <init_heap@plt>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    130f <main+0x17f>
lea    0xd07(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     137e <main+0x1ee>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xcd7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    134b <main+0x1bb>
lea    0xca2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xc94(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xc86(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xc78(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xc6a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1070 <get_a_num@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    13df <main+0x24f>
jmp    141b <main+0x28b>
mov    -0x3c(%rbp),%eax
mov    -0x30(%rbp),%rcx
cmp    0x4(%rcx),%eax
jg     13f4 <main+0x264>
jmp    13c4 <main+0x234>
mov    -0x3c(%rbp),%edx
mov    -0x30(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
call   1030 <sink_heap@plt>
jmp    13c4 <main+0x234>
lea    0xc3f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1463 <main+0x2d3>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xbf2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1430 <main+0x2a0>
lea    0xbbd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     11d1 <main+0x21>
lea    0xe8d(%rip),%rdi
call   1060 <puts@plt>
jmp    1402 <main+0x252>
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
call   10d0 <atoi@plt>
mov    %eax,%r14d
mov    0x8(%rbx),%rbx
lea    0x8(,%r14,4),%edi
call   10a0 <malloc@plt>
mov    %rax,%r13
lea    0xe05(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     127a <main+0xca>
mov    %rax,%r15
test   %r14d,%r14d
jle    128b <main+0xdb>
lea    0x1(%r14),%ebx
mov    $0x1,%ebp
nopl   0x0(%rax)
mov    %r15,%rdi
call   1090 <get_a_num@plt>
mov    %eax,0x0(%r13,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1220 <main+0x70>
lea    0xdc9(%rip),%rdi
call   1060 <puts@plt>
test   %r14d,%r14d
jle    1297 <main+0xe7>
mov    $0x1,%ebp
lea    0xdaf(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbp,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1260 <main+0xb0>
jmp    1297 <main+0xe7>
lea    0xdc7(%rip),%rdi
call   1060 <puts@plt>
jmp    1402 <main+0x252>
lea    0xd74(%rip),%rdi
call   1060 <puts@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
cmp    $0x2,%r14d
jl     12f7 <main+0x147>
mov    %r14d,%ebx
shr    %ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
mov    %ebx,%esi
mov    %r14d,%edx
call   10b0 <init_heap@plt>
lea    -0x1(%rbx),%eax
cmp    $0x1,%ebx
mov    %eax,%ebx
ja     12e0 <main+0x130>
lea    0xd1e(%rip),%rdi
call   1060 <puts@plt>
test   %r14d,%r14d
jle    1338 <main+0x188>
lea    0x1(%r14),%ebx
mov    $0x1,%ebp
lea    0xcea(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13,%rbp,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1320 <main+0x170>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    %r15,%rdi
call   1090 <get_a_num@plt>
cmp    $0xffffffff,%eax
je     13a5 <main+0x1f5>
lea    0x1(%r14),%ecx
movslq %ecx,%r12
jmp    138d <main+0x1dd>
mov    %r15,%rdi
call   1090 <get_a_num@plt>
cmp    $0xffffffff,%eax
je     13a5 <main+0x1f5>
cmp    0x4(%r13),%eax
jle    1380 <main+0x1d0>
mov    %eax,0x0(%r13,%r12,4)
mov    %r13,%rdi
mov    %r12d,%esi
call   1030 <sink_heap@plt>
jmp    1380 <main+0x1d0>
lea    0xc8c(%rip),%rdi
call   1060 <puts@plt>
test   %r14d,%r14d
jle    13e8 <main+0x238>
add    $0x1,%r14d
mov    $0x1,%ebx
lea    0xc3c(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%r13,%rbx,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    13d0 <main+0x220>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    %r13,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"please use topk file num\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [13 x i8] c"read error \0A\00"
@.str.3 = [23 x i8] c"\E8\AF\BB\E5\8F\96\E5\90\8E\E7\9A\84\E6\95\B0\E6\8D\AE\EF\BC\9A\0A\00"
@.str.4 = [4 x i8] c"%d\09\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [29 x i8] c"\E5\88\9D\E5\A7\8B\E5\8C\96\E5\A0\86\E5\90\8E\E7\9A\84\E6\95\B0\E6\8D\AE\EF\BC\9A\0A\00"
@.str.7 = [17 x i8] c"\E6\9C\80\E7\BB\88\E6\95\B0\E6\8D\AE\EF\BC\9A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %154
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %6
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
store i8* %23, i8** %7
store i32 0, i32* %8
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 2
%26 = sext i32 %25 to i64
%27 = mul i64 4, %26
%28 = trunc i64 %27 to i32
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to i32*
store i32* %30, i32** %9
%31 = load i8*, i8** %7
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %32, i32** %10
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %36
34: ; preds = %16
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %154
36: ; preds = %16
store i32 1, i32* %8
br label %37
37: ; preds = %48, %36
%38 = load i32, i32* %8
%39 = load i32, i32* %6
%40 = icmp sle i32 %38, %39
br i1 %40, label %41, label %51
41: ; preds = %37
%42 = load i32*, i32** %10
%43 = call i32 @get_a_num(i32* %42)
%44 = load i32*, i32** %9
%45 = load i32, i32* %8
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %44, i64 %46
store i32 %43, i32* %47
br label %48
48: ; preds = %41
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
br label %37
51: ; preds = %37
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %8
br label %53
53: ; preds = %64, %51
%54 = load i32, i32* %8
%55 = load i32, i32* %6
%56 = icmp sle i32 %54, %55
br i1 %56, label %57, label %67
57: ; preds = %53
%58 = load i32*, i32** %9
%59 = load i32, i32* %8
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32, i32* %58, i64 %60
%62 = load i32, i32* %61
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %57
%65 = load i32, i32* %8
%66 = add nsw i32 %65, 1
store i32 %66, i32* %8
br label %53
67: ; preds = %53
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%73 = load i32, i32* %6
%74 = sdiv i32 %73, 2
store i32 %74, i32* %8
br label %75
75: ; preds = %83, %67
%76 = load i32, i32* %8
%77 = icmp sge i32 %76, 1
br i1 %77, label %78, label %86
78: ; preds = %75
%79 = load i32*, i32** %9
%80 = load i32, i32* %8
%81 = load i32, i32* %6
%82 = call i32 @init_heap(i32* %79, i32 %80, i32 %81)
br label %83
83: ; preds = %78
%84 = load i32, i32* %8
%85 = add nsw i32 %84, -1
store i32 %85, i32* %8
br label %75
86: ; preds = %75
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %8
br label %88
88: ; preds = %99, %86
%89 = load i32, i32* %8
%90 = load i32, i32* %6
%91 = icmp sle i32 %89, %90
br i1 %91, label %92, label %102
92: ; preds = %88
%93 = load i32*, i32** %9
%94 = load i32, i32* %8
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i32, i32* %93, i64 %95
%97 = load i32, i32* %96
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %97)
br label %99
99: ; preds = %92
%100 = load i32, i32* %8
%101 = add nsw i32 %100, 1
store i32 %101, i32* %8
br label %88
102: ; preds = %88
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %108
108: ; preds = %102, %120, %121
%109 = load i32*, i32** %10
%110 = call i32 @get_a_num(i32* %109)
store i32 %110, i32* %11
%111 = load i32, i32* %11
%112 = icmp eq i32 %111, -1
br i1 %112, label %113, label %114
113: ; preds = %108
br label %132
114: ; preds = %108
%115 = load i32, i32* %11
%116 = load i32*, i32** %9
%117 = getelementptr inbounds i32, i32* %116, i64 1
%118 = load i32, i32* %117
%119 = icmp sle i32 %115, %118
br i1 %119, label %120, label %121
120: ; preds = %114
br label %108
121: ; preds = %114
%122 = load i32, i32* %11
%123 = load i32*, i32** %9
%124 = load i32, i32* %6
%125 = add nsw i32 %124, 1
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds i32, i32* %123, i64 %126
store i32 %122, i32* %127
%128 = load i32*, i32** %9
%129 = load i32, i32* %6
%130 = add nsw i32 %129, 1
%131 = call i32 @sink_heap(i32* %128, i32 %130)
br label %108
132: ; preds = %113
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %8
br label %134
134: ; preds = %145, %132
%135 = load i32, i32* %8
%136 = load i32, i32* %6
%137 = icmp sle i32 %135, %136
br i1 %137, label %138, label %148
138: ; preds = %134
%139 = load i32*, i32** %9
%140 = load i32, i32* %8
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds i32, i32* %139, i64 %141
%143 = load i32, i32* %142
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %143)
br label %145
145: ; preds = %138
%146 = load i32, i32* %8
%147 = add nsw i32 %146, 1
store i32 %147, i32* %8
br label %134
148: ; preds = %134
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%150 = load i32*, i32** %10
%151 = call i32 @fclose(i32* %150)
%152 = load i32*, i32** %9
%153 = call i32 @free(i32* %152)
br label %154
154: ; preds = %148, %34, %14
%155 = load i32, i32* %3
ret i32 %155
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.4 = [4 x i8] c"%d\09\00"
@str = [22 x i8] c"\E8\AF\BB\E5\8F\96\E5\90\8E\E7\9A\84\E6\95\B0\E6\8D\AE\EF\BC\9A\00"
@str.8 = [28 x i8] c"\E5\88\9D\E5\A7\8B\E5\8C\96\E5\A0\86\E5\90\8E\E7\9A\84\E6\95\B0\E6\8D\AE\EF\BC\9A\00"
@str.9 = [16 x i8] c"\E6\9C\80\E7\BB\88\E6\95\B0\E6\8D\AE\EF\BC\9A\00"
@str.10 = [12 x i8] c"read error \00"
@str.11 = [25 x i8] c"please use topk file num\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.11, i64 0, i64 0))
br label %109
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = shl i32 %9, 2
%13 = add i32 %12, 8
%14 = tail call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
%16 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %25, label %18
18: ; preds = %6
%19 = icmp slt i32 %9, 1
br i1 %19, label %20, label %22
20: ; preds = %18
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %45
22: ; preds = %18
%23 = add nuw i32 %9, 1
%24 = zext i32 %23 to i64
br label %27
25: ; preds = %6
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.10, i64 0, i64 0))
br label %109
27: ; preds = %22, %27
%28 = phi i64 [ 1, %22 ], [ %31, %27 ]
%29 = tail call i32 @get_a_num(i32* %16)
%30 = getelementptr inbounds i32, i32* %15, i64 %28
store i32 %29, i32* %30
%31 = add nuw nsw i64 %28, 1
%32 = icmp eq i64 %31, %24
br i1 %32, label %33, label %27
33: ; preds = %27
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br i1 %19, label %45, label %35
35: ; preds = %33
%36 = add nuw i32 %9, 1
%37 = zext i32 %36 to i64
br label %38
38: ; preds = %35, %38
%39 = phi i64 [ 1, %35 ], [ %43, %38 ]
%40 = getelementptr inbounds i32, i32* %15, i64 %39
%41 = load i32, i32* %40
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = add nuw nsw i64 %39, 1
%44 = icmp eq i64 %43, %37
br i1 %44, label %45, label %38
45: ; preds = %38, %20, %33
%46 = tail call i32 @putchar(i32 10)
%47 = tail call i32 @putchar(i32 10)
%48 = tail call i32 @putchar(i32 10)
%49 = tail call i32 @putchar(i32 10)
%50 = tail call i32 @putchar(i32 10)
%51 = icmp sgt i32 %9, 1
br i1 %51, label %52, label %59
52: ; preds = %45
%53 = lshr i32 %9, 1
br label %54
54: ; preds = %52, %54
%55 = phi i32 [ %57, %54 ], [ %53, %52 ]
%56 = tail call i32 @init_heap(i32* %15, i32 %55, i32 %9)
%57 = add nsw i32 %55, -1
%58 = icmp ugt i32 %55, 1
br i1 %58, label %54, label %59
59: ; preds = %54, %45
%60 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.8, i64 0, i64 0))
br i1 %19, label %71, label %61
61: ; preds = %59
%62 = add nuw i32 %9, 1
%63 = zext i32 %62 to i64
br label %64
64: ; preds = %61, %64
%65 = phi i64 [ 1, %61 ], [ %69, %64 ]
%66 = getelementptr inbounds i32, i32* %15, i64 %65
%67 = load i32, i32* %66
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %67)
%69 = add nuw nsw i64 %65, 1
%70 = icmp eq i64 %69, %63
br i1 %70, label %71, label %64
71: ; preds = %64, %59
%72 = tail call i32 @putchar(i32 10)
%73 = tail call i32 @putchar(i32 10)
%74 = tail call i32 @putchar(i32 10)
%75 = tail call i32 @putchar(i32 10)
%76 = tail call i32 @putchar(i32 10)
%77 = tail call i32 @get_a_num(i32* %16)
%78 = icmp eq i32 %77, -1
br i1 %78, label %93, label %79
79: ; preds = %71
%80 = getelementptr inbounds i32, i32* %15, i64 1
%81 = add nsw i32 %9, 1
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i32, i32* %15, i64 %82
br label %84
84: ; preds = %79, %90
%85 = phi i32 [ %77, %79 ], [ %91, %90 ]
%86 = load i32, i32* %80
%87 = icmp sgt i32 %85, %86
br i1 %87, label %88, label %90
88: ; preds = %84
store i32 %85, i32* %83
%89 = tail call i32 @sink_heap(i32* %15, i32 %81)
br label %90
90: ; preds = %88, %84
%91 = tail call i32 @get_a_num(i32* %16)
%92 = icmp eq i32 %91, -1
br i1 %92, label %93, label %84
93: ; preds = %90, %71
%94 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.9, i64 0, i64 0))
br i1 %19, label %105, label %95
95: ; preds = %93
%96 = add nuw i32 %9, 1
%97 = zext i32 %96 to i64
br label %98
98: ; preds = %95, %98
%99 = phi i64 [ 1, %95 ], [ %103, %98 ]
%100 = getelementptr inbounds i32, i32* %15, i64 %99
%101 = load i32, i32* %100
%102 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %101)
%103 = add nuw nsw i64 %99, 1
%104 = icmp eq i64 %103, %97
br i1 %104, label %105, label %98
105: ; preds = %98, %93
%106 = tail call i32 @putchar(i32 10)
%107 = tail call i32 @fclose(i32* %16)
%108 = tail call i32 @free(i32* %15)
br label %109
109: ; preds = %25, %105, %4
ret i32 0
}