#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  int dog[50];
  int i, c, k, l, pig, j, cat;
  printf("几个数参与排序?\n");
  scanf("%d", &cat);
  printf("请输入%d个整数。\n", cat);
  i = 0;
  c = 0;
  k, l, pig, j = 0;
  while (i <= (cat - 1)) {
    scanf("%d", dog + i);
    i++;
  }
  printf("输入的数为：\n");
  while (c <= (cat - 1)) {
    printf("%d ", dog[c]);
    c++;
  }
  while (j <= (cat - 2)) {
    k = 0;
    while (k <= (cat - 2 - j)) {
      if (dog[cat - 1 - k] < dog[cat - 2 - k]) {
        pig = dog[cat - 2 - k];
        dog[cat - 2 - k] = dog[cat - 1 - k];
        dog[cat - 1 - k] = pig;
      } else
        ;
      k++;
    }
    j++;
  }
  printf("\n排序结果为：\n");
  while (l <= cat - 1) {
    printf("%d ", dog[l]);
    l++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0xec(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xec(%rbp),%esi
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xd4(%rbp)
movl   $0x0,-0xd8(%rbp)
movl   $0x0,-0xe8(%rbp)
mov    -0xd4(%rbp),%eax
mov    -0xec(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     11d1 <main+0xb1>
lea    -0xd0(%rbp),%rsi
movslq -0xd4(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe60(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    1185 <main+0x65>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xd8(%rbp),%eax
mov    -0xec(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1226 <main+0x106>
movslq -0xd8(%rbp),%rax
mov    -0xd0(%rbp,%rax,4),%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    11df <main+0xbf>
jmp    122b <main+0x10b>
mov    -0xe8(%rbp),%eax
mov    -0xec(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jg     133e <main+0x21e>
movl   $0x0,-0xdc(%rbp)
mov    -0xdc(%rbp),%eax
mov    -0xec(%rbp),%ecx
sub    $0x2,%ecx
sub    -0xe8(%rbp),%ecx
cmp    %ecx,%eax
jg     132a <main+0x20a>
mov    -0xec(%rbp),%eax
sub    $0x1,%eax
sub    -0xdc(%rbp),%eax
cltq
mov    -0xd0(%rbp,%rax,4),%eax
mov    -0xec(%rbp),%ecx
sub    $0x2,%ecx
sub    -0xdc(%rbp),%ecx
movslq %ecx,%rcx
cmp    -0xd0(%rbp,%rcx,4),%eax
jge    1311 <main+0x1f1>
mov    -0xec(%rbp),%eax
sub    $0x2,%eax
sub    -0xdc(%rbp),%eax
cltq
mov    -0xd0(%rbp,%rax,4),%eax
mov    %eax,-0xe4(%rbp)
mov    -0xec(%rbp),%eax
sub    $0x1,%eax
sub    -0xdc(%rbp),%eax
cltq
mov    -0xd0(%rbp,%rax,4),%ecx
mov    -0xec(%rbp),%eax
sub    $0x2,%eax
sub    -0xdc(%rbp),%eax
cltq
mov    %ecx,-0xd0(%rbp,%rax,4)
mov    -0xe4(%rbp),%ecx
mov    -0xec(%rbp),%eax
sub    $0x1,%eax
sub    -0xdc(%rbp),%eax
cltq
mov    %ecx,-0xd0(%rbp,%rax,4)
jmp    1316 <main+0x1f6>
jmp    1316 <main+0x1f6>
mov    -0xdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xdc(%rbp)
jmp    124c <main+0x12c>
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    122b <main+0x10b>
lea    0xd07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xe0(%rbp),%eax
mov    -0xec(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1393 <main+0x273>
movslq -0xe0(%rbp),%rax
mov    -0xd0(%rbp,%rax,4),%esi
lea    0xcd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xe0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe0(%rbp)
jmp    134c <main+0x22c>
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xe0,%rsp
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    119d <main+0x6d>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe80(%rip),%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     1180 <main+0x50>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    11e2 <main+0xb2>
lea    0xe65(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%r11
cmp    %r11,%rbx
jl     11c0 <main+0x90>
cmp    $0x2,%r11d
jge    11fd <main+0xcd>
lea    0xe61(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    -0x2(%r11),%r8d
mov    %r8d,%eax
add    $0xffffffff,%r11d
lea    (%rsp,%rax,4),%rdx
add    $0x10,%rdx
xor    %r10d,%r10d
mov    %r11d,%r9d
jmp    122d <main+0xfd>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r10d
add    $0xffffffff,%r9d
cmp    %r11d,%r10d
je     11e2 <main+0xb2>
cmp    %r10d,%r8d
jl     1220 <main+0xf0>
mov    %r9d,%ebx
neg    %rbx
xor    %ecx,%ecx
jmp    1249 <main+0x119>
nopl   0x0(%rax)
add    $0xffffffffffffffff,%rcx
cmp    %rcx,%rbx
je     1220 <main+0xf0>
lea    (%r11,%rcx,1),%eax
movslq %eax,%rdi
mov    0x10(%rsp,%rdi,4),%esi
mov    (%rdx,%rcx,4),%eax
cmp    %eax,%esi
jge    1240 <main+0x110>
mov    %esi,(%rdx,%rcx,4)
mov    %eax,0x10(%rsp,%rdi,4)
jmp    1240 <main+0x110>

LLVM IR (-O0):
@.str = [24 x i8] c"\E5\87\A0\E4\B8\AA\E6\95\B0\E5\8F\82\E4\B8\8E\E6\8E\92\E5\BA\8F?\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [25 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5%d\E4\B8\AA\E6\95\B4\E6\95\B0\E3\80\82\0A\00"
@.str.3 = [20 x i8] c"\E8\BE\93\E5\85\A5\E7\9A\84\E6\95\B0\E4\B8\BA\EF\BC\9A\0A\00"
@.str.4 = [4 x i8] c"%d \00"
@.str.5 = [21 x i8] c"\0A\E6\8E\92\E5\BA\8F\E7\BB\93\E6\9E\9C\E4\B8\BA\EF\BC\9A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%12 = load i32, i32* %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %12)
store i32 0, i32* %3
store i32 0, i32* %4
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = load i32, i32* %7
store i32 0, i32* %8
br label %17
17: ; preds = %22, %0
%18 = load i32, i32* %3
%19 = load i32, i32* %9
%20 = sub nsw i32 %19, 1
%21 = icmp sle i32 %18, %20
br i1 %21, label %22, label %30
22: ; preds = %17
%23 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %26)
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %17
30: ; preds = %17
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %37, %30
%33 = load i32, i32* %4
%34 = load i32, i32* %9
%35 = sub nsw i32 %34, 1
%36 = icmp sle i32 %33, %35
br i1 %36, label %37, label %45
37: ; preds = %32
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %32
45: ; preds = %32
br label %46
46: ; preds = %107, %45
%47 = load i32, i32* %8
%48 = load i32, i32* %9
%49 = sub nsw i32 %48, 2
%50 = icmp sle i32 %47, %49
br i1 %50, label %51, label %110
51: ; preds = %46
store i32 0, i32* %5
br label %52
52: ; preds = %104, %51
%53 = load i32, i32* %5
%54 = load i32, i32* %9
%55 = sub nsw i32 %54, 2
%56 = load i32, i32* %8
%57 = sub nsw i32 %55, %56
%58 = icmp sle i32 %53, %57
br i1 %58, label %59, label %107
59: ; preds = %52
%60 = load i32, i32* %9
%61 = sub nsw i32 %60, 1
%62 = load i32, i32* %5
%63 = sub nsw i32 %61, %62
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %64
%66 = load i32, i32* %65
%67 = load i32, i32* %9
%68 = sub nsw i32 %67, 2
%69 = load i32, i32* %5
%70 = sub nsw i32 %68, %69
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %71
%73 = load i32, i32* %72
%74 = icmp slt i32 %66, %73
br i1 %74, label %75, label %103
75: ; preds = %59
%76 = load i32, i32* %9
%77 = sub nsw i32 %76, 2
%78 = load i32, i32* %5
%79 = sub nsw i32 %77, %78
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %80
%82 = load i32, i32* %81
store i32 %82, i32* %7
%83 = load i32, i32* %9
%84 = sub nsw i32 %83, 1
%85 = load i32, i32* %5
%86 = sub nsw i32 %84, %85
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %87
%89 = load i32, i32* %88
%90 = load i32, i32* %9
%91 = sub nsw i32 %90, 2
%92 = load i32, i32* %5
%93 = sub nsw i32 %91, %92
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %94
store i32 %89, i32* %95
%96 = load i32, i32* %7
%97 = load i32, i32* %9
%98 = sub nsw i32 %97, 1
%99 = load i32, i32* %5
%100 = sub nsw i32 %98, %99
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %101
store i32 %96, i32* %102
br label %104
103: ; preds = %59
br label %104
104: ; preds = %103, %75
%105 = load i32, i32* %5
%106 = add nsw i32 %105, 1
store i32 %106, i32* %5
br label %52
107: ; preds = %52
%108 = load i32, i32* %8
%109 = add nsw i32 %108, 1
store i32 %109, i32* %8
br label %46
110: ; preds = %46
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %112
112: ; preds = %117, %110
%113 = load i32, i32* %6
%114 = load i32, i32* %9
%115 = sub nsw i32 %114, 1
%116 = icmp sle i32 %113, %115
br i1 %116, label %117, label %125
117: ; preds = %112
%118 = load i32, i32* %6
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %119
%121 = load i32, i32* %120
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %121)
%123 = load i32, i32* %6
%124 = add nsw i32 %123, 1
store i32 %124, i32* %6
br label %112
125: ; preds = %112
%126 = load i32, i32* %1
ret i32 %126
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [25 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5%d\E4\B8\AA\E6\95\B4\E6\95\B0\E3\80\82\0A\00"
@.str.4 = [4 x i8] c"%d \00"
@str = [23 x i8] c"\E5\87\A0\E4\B8\AA\E6\95\B0\E5\8F\82\E4\B8\8E\E6\8E\92\E5\BA\8F?\00"
@str.6 = [19 x i8] c"\E8\BE\93\E5\85\A5\E7\9A\84\E6\95\B0\E4\B8\BA\EF\BC\9A\00"
@str.7 = [20 x i8] c"\0A\E6\8E\92\E5\BA\8F\E7\BB\93\E6\9E\9C\E4\B8\BA\EF\BC\9A\00"
define i32 @main() {
%1 = alloca [50 x i32]
%2 = alloca i32
%3 = bitcast [50 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %0, %11
%12 = phi i64 [ %15, %11 ], [ 0, %0 ]
%13 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %12
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %13)
%15 = add nuw nsw i64 %12, 1
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %15, %17
br i1 %18, label %11, label %19
19: ; preds = %11, %0
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%21 = load i32, i32* %2
%22 = icmp sgt i32 %21, 0
br i1 %22, label %29, label %64
23: ; preds = %29
%24 = add nsw i32 %35, -2
%25 = icmp slt i32 %35, 2
br i1 %25, label %64, label %26
26: ; preds = %23
%27 = zext i32 %24 to i64
%28 = add nsw i32 %35, -1
br label %38
29: ; preds = %19, %29
%30 = phi i64 [ %34, %29 ], [ 0, %19 ]
%31 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %32)
%34 = add nuw nsw i64 %30, 1
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = icmp slt i64 %34, %36
br i1 %37, label %29, label %23
38: ; preds = %26, %60
%39 = phi i32 [ %28, %26 ], [ %62, %60 ]
%40 = phi i32 [ 0, %26 ], [ %61, %60 ]
%41 = icmp slt i32 %24, %40
br i1 %41, label %60, label %42
42: ; preds = %38
%43 = zext i32 %39 to i64
br label %44
44: ; preds = %42, %57
%45 = phi i64 [ 0, %42 ], [ %58, %57 ]
%46 = trunc i64 %45 to i32
%47 = xor i32 %46, -1
%48 = add i32 %35, %47
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = sub nsw i64 %27, %45
%53 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = icmp slt i32 %51, %54
br i1 %55, label %56, label %57
56: ; preds = %44
store i32 %51, i32* %53
store i32 %54, i32* %50
br label %57
57: ; preds = %44, %56
%58 = add nuw nsw i64 %45, 1
%59 = icmp eq i64 %58, %43
br i1 %59, label %60, label %44
60: ; preds = %57, %38
%61 = add nuw i32 %40, 1
%62 = add i32 %39, -1
%63 = icmp eq i32 %61, %28
br i1 %63, label %64, label %38
64: ; preds = %60, %19, %23
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.7, i64 0, i64 0))
ret i32 0
}