#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*/ BubbleSort(int *, int);
scalar_t__ EOF;
int /*<<< orphan*/ HeapSort(int *, int);
int /*<<< orphan*/ InsertSort(int *, int);
int /*<<< orphan*/ QuickSort(int *, int, int);
int /*<<< orphan*/ SelectSort(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
scalar_t__ scanf(char *, int *);
int main(int argc, char *argv[]) {
  int len, i, sort;
  int R[100010];
  puts("欢迎来到排序算法演示程序");
  while (1) {
    printf("请输入需要排序的值的数量：");
    if (scanf("%d", &len) == EOF) {
      break;
    }
    printf("请输入需要排序的%d个数字：", len);
    for (i = 1; i <= len; i++) {
      scanf("%d", &R[i]);
    }
    printf("请输入想使用的算法：");
    scanf("%d", &sort);
    switch (sort) {
    case 1:
      InsertSort(R, len);
      break;
    case 2:
      SelectSort(R, len);
      break;
    case 3:
      BubbleSort(R, len);
      break;
    case 4:
      QuickSort(R, 1, len);
      break;
    case 5:
      HeapSort(R, len);
      break;
    default:
      puts("程序错误！");
      return 0;
      break;
    }
    printf("排序结果为：");
    for (i = 1; i <= len; i++) {
      printf("%d ", R[i]);
    }
    puts("");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61ae0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea7(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1090 <scanf@plt>
mov    0x2e1e(%rip),%rcx
cmp    (%rcx),%rax
jne    11d8 <main+0x58>
jmp    134a <main+0x1ca>
mov    -0x14(%rbp),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1228 <main+0xa8>
movslq -0x18(%rbp),%rax
lea    -0x61ad0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe4c(%rip),%rdi
call   1090 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11f0 <main+0x70>
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe24(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x61ad8(%rbp)
sub    $0x4,%eax
ja     12de <main+0x15e>
mov    -0x61ad8(%rbp),%rax
lea    0xd94(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x61ad0(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1080 <InsertSort@plt>
jmp    12f6 <main+0x176>
lea    -0x61ad0(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <SelectSort@plt>
jmp    12f6 <main+0x176>
lea    -0x61ad0(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10a0 <BubbleSort@plt>
jmp    12f6 <main+0x176>
lea    -0x61ad0(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    $0x1,%esi
call   1070 <QuickSort@plt>
jmp    12f6 <main+0x176>
lea    -0x61ad0(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <HeapSort@plt>
jmp    12f6 <main+0x176>
lea    0xdc5(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1351 <main+0x1d1>
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     133e <main+0x1be>
movslq -0x18(%rbp),%rax
mov    -0x61ad0(%rbp,%rax,4),%esi
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    130b <main+0x18b>
lea    0xd8b(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x61ae0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x61ac0,%rsp
lea    0xe71(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea4(%rip),%rdi
lea    0x8(%rsp),%rsi
call   10a0 <scanf@plt>
mov    0x2e1a(%rip),%rcx
cmp    (%rcx),%rax
je     1306 <main+0x176>
mov    0x8(%rsp),%esi
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x8(%rsp)
jle    121d <main+0x8d>
lea    0x14(%rsp),%r15
xor    %ebx,%ebx
lea    0xe63(%rip),%r14
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <scanf@plt>
movslq 0x8(%rsp),%rax
add    $0x1,%rbx
add    $0x4,%r15
cmp    %rax,%rbx
jl     1200 <main+0x70>
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe2f(%rip),%rdi
lea    0xc(%rsp),%rsi
call   10a0 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     1268 <main+0xd8>
lea    0xdb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x8(%rsp),%esi
lea    0x10(%rsp),%rdi
call   1090 <InsertSort@plt>
jmp    12bc <main+0x12c>
lea    0xe3b(%rip),%rdi
call   1040 <puts@plt>
jmp    1306 <main+0x176>
mov    0x8(%rsp),%esi
lea    0x10(%rsp),%rdi
call   1070 <SelectSort@plt>
jmp    12bc <main+0x12c>
mov    0x8(%rsp),%esi
lea    0x10(%rsp),%rdi
call   10b0 <BubbleSort@plt>
jmp    12bc <main+0x12c>
mov    0x8(%rsp),%edx
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
call   1080 <QuickSort@plt>
jmp    12bc <main+0x12c>
mov    0x8(%rsp),%esi
lea    0x10(%rsp),%rdi
call   1060 <HeapSort@plt>
lea    0xdf7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x8(%rsp)
jle    12fc <main+0x16c>
lea    0xdf5(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    0x14(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movslq 0x8(%rsp),%rax
add    $0x1,%rbx
cmp    %rax,%rbx
jl     12e0 <main+0x150>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x61ac0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [37 x i8] c"\E6\AC\A2\E8\BF\8E\E6\9D\A5\E5\88\B0\E6\8E\92\E5\BA\8F\E7\AE\97\E6\B3\95\E6\BC\94\E7\A4\BA\E7\A8\8B\E5\BA\8F\00"
@.str.1 = [40 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E9\9C\80\E8\A6\81\E6\8E\92\E5\BA\8F\E7\9A\84\E5\80\BC\E7\9A\84\E6\95\B0\E9\87\8F\EF\BC\9A\00"
@.str.2 = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.3 = [39 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E9\9C\80\E8\A6\81\E6\8E\92\E5\BA\8F\E7\9A\84%d\E4\B8\AA\E6\95\B0\E5\AD\97\EF\BC\9A\00"
@.str.4 = [31 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E6\83\B3\E4\BD\BF\E7\94\A8\E7\9A\84\E7\AE\97\E6\B3\95\EF\BC\9A\00"
@.str.5 = [16 x i8] c"\E7\A8\8B\E5\BA\8F\E9\94\99\E8\AF\AF\EF\BC\81\00"
@.str.6 = [19 x i8] c"\E6\8E\92\E5\BA\8F\E7\BB\93\E6\9E\9C\E4\B8\BA\EF\BC\9A\00"
@.str.7 = [4 x i8] c"%d \00"
@.str.8 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [100010 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @puts(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%13 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %11
br label %75
17: ; preds = %11
%18 = load i32, i32* %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %18)
store i32 1, i32* %7
br label %20
20: ; preds = %29, %17
%21 = load i32, i32* %7
%22 = load i32, i32* %6
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %32
24: ; preds = %20
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [100010 x i32], [100010 x i32]* %9, i64 0, i64 %26
%28 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %27)
br label %29
29: ; preds = %24
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %20
32: ; preds = %20
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%34 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%35 = load i32, i32* %8
switch i32 %35, label %56 [
i32 1, label %36
i32 2, label %40
i32 3, label %44
i32 4, label %48
i32 5, label %52
]
36: ; preds = %32
%37 = getelementptr inbounds [100010 x i32], [100010 x i32]* %9, i64 0, i64 0
%38 = load i32, i32* %6
%39 = call i32 @InsertSort(i32* %37, i32 %38)
br label %58
40: ; preds = %32
%41 = getelementptr inbounds [100010 x i32], [100010 x i32]* %9, i64 0, i64 0
%42 = load i32, i32* %6
%43 = call i32 @SelectSort(i32* %41, i32 %42)
br label %58
44: ; preds = %32
%45 = getelementptr inbounds [100010 x i32], [100010 x i32]* %9, i64 0, i64 0
%46 = load i32, i32* %6
%47 = call i32 @BubbleSort(i32* %45, i32 %46)
br label %58
48: ; preds = %32
%49 = getelementptr inbounds [100010 x i32], [100010 x i32]* %9, i64 0, i64 0
%50 = load i32, i32* %6
%51 = call i32 @QuickSort(i32* %49, i32 1, i32 %50)
br label %58
52: ; preds = %32
%53 = getelementptr inbounds [100010 x i32], [100010 x i32]* %9, i64 0, i64 0
%54 = load i32, i32* %6
%55 = call i32 @HeapSort(i32* %53, i32 %54)
br label %58
56: ; preds = %32
%57 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
br label %76
58: ; preds = %52, %48, %44, %40, %36
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %7
br label %60
60: ; preds = %70, %58
%61 = load i32, i32* %7
%62 = load i32, i32* %6
%63 = icmp sle i32 %61, %62
br i1 %63, label %64, label %73
64: ; preds = %60
%65 = load i32, i32* %7
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [100010 x i32], [100010 x i32]* %9, i64 0, i64 %66
%68 = load i32, i32* %67
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %68)
br label %70
70: ; preds = %64
%71 = load i32, i32* %7
%72 = add nsw i32 %71, 1
store i32 %72, i32* %7
br label %60
73: ; preds = %60
%74 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0))
br label %75
75: ; preds = %73, %16
store i32 0, i32* %3
br label %76
76: ; preds = %75, %56
%77 = load i32, i32* %3
ret i32 %77
}

LLVM IR (-O2):
@.str = [37 x i8] c"\E6\AC\A2\E8\BF\8E\E6\9D\A5\E5\88\B0\E6\8E\92\E5\BA\8F\E7\AE\97\E6\B3\95\E6\BC\94\E7\A4\BA\E7\A8\8B\E5\BA\8F\00"
@.str.1 = [40 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E9\9C\80\E8\A6\81\E6\8E\92\E5\BA\8F\E7\9A\84\E5\80\BC\E7\9A\84\E6\95\B0\E9\87\8F\EF\BC\9A\00"
@.str.2 = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.3 = [39 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E9\9C\80\E8\A6\81\E6\8E\92\E5\BA\8F\E7\9A\84%d\E4\B8\AA\E6\95\B0\E5\AD\97\EF\BC\9A\00"
@.str.4 = [31 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E6\83\B3\E4\BD\BF\E7\94\A8\E7\9A\84\E7\AE\97\E6\B3\95\EF\BC\9A\00"
@.str.5 = [16 x i8] c"\E7\A8\8B\E5\BA\8F\E9\94\99\E8\AF\AF\EF\BC\81\00"
@.str.6 = [19 x i8] c"\E6\8E\92\E5\BA\8F\E7\BB\93\E6\9E\9C\E4\B8\BA\EF\BC\9A\00"
@.str.7 = [4 x i8] c"%d \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100010 x i32]
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast [100010 x i32]* %5 to i8*
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%11 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%12 = load i64, i64* @EOF
%13 = icmp eq i64 %11, %12
br i1 %13, label %68, label %14
14: ; preds = %2
%15 = load i32, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 1
br i1 %18, label %27, label %19
19: ; preds = %14, %19
%20 = phi i64 [ %23, %19 ], [ 1, %14 ]
%21 = getelementptr inbounds [100010 x i32], [100010 x i32]* %5, i64 0, i64 %20
%22 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %21)
%23 = add nuw nsw i64 %20, 1
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %20, %25
br i1 %26, label %19, label %27
27: ; preds = %19, %14
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%29 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%30 = load i32, i32* %4
switch i32 %30, label %51 [
i32 1, label %31
i32 2, label %35
i32 3, label %39
i32 4, label %43
i32 5, label %47
]
31: ; preds = %27
%32 = getelementptr inbounds [100010 x i32], [100010 x i32]* %5, i64 0, i64 0
%33 = load i32, i32* %3
%34 = call i32 @InsertSort(i32* %32, i32 %33)
br label %53
35: ; preds = %27
%36 = getelementptr inbounds [100010 x i32], [100010 x i32]* %5, i64 0, i64 0
%37 = load i32, i32* %3
%38 = call i32 @SelectSort(i32* %36, i32 %37)
br label %53
39: ; preds = %27
%40 = getelementptr inbounds [100010 x i32], [100010 x i32]* %5, i64 0, i64 0
%41 = load i32, i32* %3
%42 = call i32 @BubbleSort(i32* %40, i32 %41)
br label %53
43: ; preds = %27
%44 = getelementptr inbounds [100010 x i32], [100010 x i32]* %5, i64 0, i64 0
%45 = load i32, i32* %3
%46 = call i32 @QuickSort(i32* %44, i32 1, i32 %45)
br label %53
47: ; preds = %27
%48 = getelementptr inbounds [100010 x i32], [100010 x i32]* %5, i64 0, i64 0
%49 = load i32, i32* %3
%50 = call i32 @HeapSort(i32* %48, i32 %49)
br label %53
51: ; preds = %27
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %68
53: ; preds = %47, %43, %39, %35, %31
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%55 = load i32, i32* %3
%56 = icmp slt i32 %55, 1
br i1 %56, label %66, label %57
57: ; preds = %53, %57
%58 = phi i64 [ %62, %57 ], [ 1, %53 ]
%59 = getelementptr inbounds [100010 x i32], [100010 x i32]* %5, i64 0, i64 %58
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %60)
%62 = add nuw nsw i64 %58, 1
%63 = load i32, i32* %3
%64 = sext i32 %63 to i64
%65 = icmp slt i64 %58, %64
br i1 %65, label %57, label %66
66: ; preds = %57, %53
%67 = call i32 @putchar(i32 10)
br label %68
68: ; preds = %66, %2, %51
ret i32 0
}