#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*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int target[1000], i, j, t, n;
  for (i = 0; i <= 1000; i++)
    target[i] = 0;
  printf("input the item num, then the item\n");
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &t);
    target[t]++;
  }
  printf("\n");
  for (i = 0; i <= 1000; i++)
    for (j = 0; j < target[i]; j++)
      printf("%d ", i);
  getchar();
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xfb4(%rbp)
cmpl   $0x3e8,-0xfb4(%rbp)
jg     1182 <main+0x52>
movslq -0xfb4(%rbp),%rax
movl   $0x0,-0xfb0(%rbp,%rax,4)
mov    -0xfb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb4(%rbp)
jmp    114c <main+0x1c>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8c(%rip),%rdi
lea    -0xfc0(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0xfb4(%rbp)
mov    -0xfb4(%rbp),%eax
cmp    -0xfc0(%rbp),%eax
jge    11fe <main+0xce>
lea    0xe5d(%rip),%rdi
lea    -0xfbc(%rbp),%rsi
call   1050 <scanf@plt>
movslq -0xfbc(%rbp),%rax
mov    -0xfb0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0xfb0(%rbp,%rax,4)
mov    -0xfb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb4(%rbp)
jmp    11ad <main+0x7d>
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xfb4(%rbp)
cmpl   $0x3e8,-0xfb4(%rbp)
jg     128b <main+0x15b>
movl   $0x0,-0xfb8(%rbp)
mov    -0xfb8(%rbp),%eax
movslq -0xfb4(%rbp),%rcx
cmp    -0xfb0(%rbp,%rcx,4),%eax
jge    1272 <main+0x142>
mov    -0xfb4(%rbp),%esi
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xfb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb8(%rbp)
jmp    1230 <main+0x100>
jmp    1277 <main+0x147>
mov    -0xfb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb4(%rbp)
jmp    1216 <main+0xe6>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0xfc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xfb0,%rsp
lea    0xea5(%rip),%rdi
call   1040 <puts@plt>
lea    0xe92(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11ae <main+0x5e>
xor    %ebp,%ebp
lea    0xe78(%rip),%r14
lea    0xc(%rsp),%rbx
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
movslq 0xc(%rsp),%rax
addl   $0x1,0x10(%rsp,%rax,4)
add    $0x1,%ebp
cmp    0x8(%rsp),%ebp
jl     1190 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe44(%rip),%r14
xor    %ebx,%ebx
jmp    11dd <main+0x8d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    $0x3e9,%rbx
je     1203 <main+0xb3>
mov    0x10(%rsp,%rbx,4),%ebp
test   %ebp,%ebp
jle    11d0 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffff,%ebp
jne    11f0 <main+0xa0>
jmp    11d0 <main+0x80>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0xfb0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d \00"
@str = [34 x i8] c"input the item num, then the item\00"
define i32 @main() {
%1 = alloca [1000 x i32]
%2 = bitcast [1000 x i32]* %1 to i8*
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 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* %4)
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %0, %11
%12 = phi i32 [ %19, %11 ], [ 0, %0 ]
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
store i32 %18, i32* %16
%19 = add nuw nsw i32 %12, 1
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %11, label %22
22: ; preds = %11, %0
%23 = call i32 @putchar(i32 10)
br label %24
24: ; preds = %22, %36
%25 = phi i64 [ 0, %22 ], [ %37, %36 ]
%26 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %24
%30 = trunc i64 %25 to i32
br label %31
31: ; preds = %29, %31
%32 = phi i32 [ %34, %31 ], [ 0, %29 ]
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%34 = add nuw nsw i32 %32, 1
%35 = icmp eq i32 %34, %27
br i1 %35, label %36, label %31
36: ; preds = %31, %24
%37 = add nuw nsw i64 %25, 1
%38 = icmp eq i64 %37, 1001
br i1 %38, label %39, label %24
39: ; preds = %36
%40 = call i32 (...) @getchar()
%41 = call i32 (...) @getchar()
ret i32 0
}