#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 *);
int main() {
  void sort(int **p, int n);
  int i, n = 0, digit[20];
  int **p, *pstr[20];
  printf("please input n:\n");
  scanf("%d", &n);
  while (n <= 0 || n > 20) {
    printf("n is elligal,please input another:\n");
    scanf("%d", &n);
  }
  printf("input %d integer numners:\n", n);
  for (i = 0; i < n; i++) {
    pstr[i] = &digit[i];
    scanf("%d", pstr[i]);
  }
  p = pstr;
  sort(p, n);
  printf("Now,the sequence is:\n");
  for (i = 0; i < n; i++) {
    printf("%d ", *pstr[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x111(%rbp)
jle    1186 <main+0x56>
cmpl   $0x14,-0xc(%rbp)
setg   %al
mov    %al,-0x111(%rbp)
mov    -0x111(%rbp),%al
test   $0x1,%al
jne    1199 <main+0x69>
jmp    11bc <main+0x8c>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe63(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
jmp    1167 <main+0x37>
mov    -0xc(%rbp),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1221 <main+0xf1>
movslq -0x8(%rbp),%rax
lea    -0x60(%rbp),%rcx
shl    $0x2,%rax
add    %rax,%rcx
movslq -0x8(%rbp),%rax
mov    %rcx,-0x110(%rbp,%rax,8)
ff
movslq -0x8(%rbp),%rax
mov    -0x110(%rbp,%rax,8),%rsi
ff
lea    0xe03(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d4 <main+0xa4>
lea    -0x110(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <sort@plt>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1283 <main+0x153>
movslq -0x8(%rbp),%rax
mov    -0x110(%rbp,%rax,8),%rax
ff
mov    (%rax),%esi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    124d <main+0x11d>
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
movl   $0x0,0xc(%rsp)
lea    0xeb7(%rip),%rdi
call   1040 <puts@plt>
lea    0xe89(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%esi
lea    -0x15(%rsi),%eax
cmp    $0xffffffeb,%eax
ja     11bf <main+0x6f>
lea    0xeb3(%rip),%r14
lea    0xe65(%rip),%r15
lea    0xc(%rsp),%rbx
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%esi
lea    -0x15(%rsi),%eax
cmp    $0xffffffec,%eax
jb     11a0 <main+0x50>
lea    0xe3d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    1212 <main+0xc2>
lea    0xb0(%rsp),%r15
xor    %ebx,%ebx
lea    0xe1a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r15,0x10(%rsp,%rbx,8)
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rsi
add    $0x4,%r15
cmp    %rsi,%rbx
jl     11f0 <main+0xa0>
lea    0x10(%rsp),%rdi
call   1060 <sort@plt>
lea    0xe0f(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    125f <main+0x10f>
lea    0xde8(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbx,8),%rax
mov    (%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1240 <main+0xf0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"please input n:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"n is elligal,please input another:\0A\00"
@.str.3 = [27 x i8] c"input %d integer numners:\0A\00"
@.str.4 = [22 x i8] c"Now,the sequence is:\0A\00"
@.str.5 = [4 x i8] c"%d \00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20 x i32]
%5 = alloca i32**
%6 = alloca [20 x i32*]
store i32 0, i32* %1
store i32 0, i32* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %9
9: ; preds = %17, %0
%10 = load i32, i32* %3
%11 = icmp sle i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* %3
%14 = icmp sgt i32 %13, 20
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ true, %9 ], [ %14, %12 ]
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %9
20: ; preds = %15
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %21)
store i32 0, i32* %2
br label %23
23: ; preds = %39, %20
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %42
27: ; preds = %23
%28 = load i32, i32* %2
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 %29
%31 = load i32, i32* %2
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [20 x i32*], [20 x i32*]* %6, i64 0, i64 %32
store i32* %30, i32** %33
%34 = load i32, i32* %2
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [20 x i32*], [20 x i32*]* %6, i64 0, i64 %35
%37 = load i32*, i32** %36
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %37)
br label %39
39: ; preds = %27
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
store i32 %41, i32* %2
br label %23
42: ; preds = %23
%43 = getelementptr inbounds [20 x i32*], [20 x i32*]* %6, i64 0, i64 0
store i32** %43, i32*** %5
%44 = load i32**, i32*** %5
%45 = load i32, i32* %3
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %2
br label %47
47: ; preds = %58, %42
%48 = load i32, i32* %2
%49 = load i32, i32* %3
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %61
51: ; preds = %47
%52 = load i32, i32* %2
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [20 x i32*], [20 x i32*]* %6, i64 0, i64 %53
%55 = load i32*, i32** %54
%56 = load i32, i32* %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %56)
br label %58
58: ; preds = %51
%59 = load i32, i32* %2
%60 = add nsw i32 %59, 1
store i32 %60, i32* %2
br label %47
61: ; preds = %47
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [27 x i8] c"input %d integer numners:\0A\00"
@.str.5 = [4 x i8] c"%d \00"
@str = [16 x i8] c"please input n:\00"
@str.7 = [21 x i8] c"Now,the sequence is:\00"
@str.8 = [35 x i8] c"n is elligal,please input another:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i32]
%3 = alloca [20 x i32*]
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%5 = bitcast [20 x i32]* %2 to i8*
%6 = bitcast [20 x i32*]* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = add i32 %9, -21
%11 = icmp ult i32 %10, -20
br i1 %11, label %12, label %18
12: ; preds = %0, %12
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.8, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = add i32 %15, -21
%17 = icmp ult i32 %16, -20
br i1 %17, label %12, label %18
18: ; preds = %12, %0
%19 = phi i32 [ %9, %0 ], [ %15, %12 ]
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %1
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %18, %23
%24 = phi i64 [ %28, %23 ], [ 0, %18 ]
%25 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %24
%26 = getelementptr inbounds [20 x i32*], [20 x i32*]* %3, i64 0, i64 %24
store i32* %25, i32** %26
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %25)
%28 = add nuw nsw i64 %24, 1
%29 = load i32, i32* %1
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %28, %30
br i1 %31, label %23, label %32
32: ; preds = %23, %18
%33 = phi i32 [ %21, %18 ], [ %29, %23 ]
%34 = getelementptr inbounds [20 x i32*], [20 x i32*]* %3, i64 0, i64 0
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0))
%36 = load i32, i32* %1
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %48
38: ; preds = %32, %38
%39 = phi i64 [ %44, %38 ], [ 0, %32 ]
%40 = getelementptr inbounds [20 x i32*], [20 x i32*]* %3, i64 0, i64 %39
%41 = load i32*, i32** %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %42)
%44 = add nuw nsw i64 %39, 1
%45 = load i32, i32* %1
%46 = sext i32 %45 to i64
%47 = icmp slt i64 %44, %46
br i1 %47, label %38, label %48
48: ; preds = %38, %32
%49 = call i32 @putchar(i32 10)
ret i32 0
}