#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 *);
void main() {
  int i, j, a, n, number[30];
  printf("Enter the value of N \n");
  scanf("%d", &n);
  printf("Enter the numbers \n");
  for (i = 0; i < n; ++i)
    scanf("%d", &number[i]);
  for (i = 0; i < n; ++i) {
    for (j = i + 1; j < n; ++j) {
      if (number[i] > number[j]) {
        a = number[i];
        number[i] = number[j];
        number[j] = a;
      }
    }
  }
  printf("The numbers arranged in ascending order are given below \n");
  for (i = 0; i < n; ++i)
    printf("%d\n", number[i]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1196 <main+0x76>
movslq -0x4(%rbp),%rax
lea    -0x90(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe94(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    115e <main+0x3e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1232 <main+0x112>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    121f <main+0xff>
movslq -0x4(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%eax
movslq -0x8(%rbp),%rcx
cmp    -0x90(%rbp,%rcx,4),%eax
jle    120c <main+0xec>
movslq -0x4(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%eax
mov    %eax,-0xc(%rbp)
movslq -0x8(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%ecx
movslq -0x4(%rbp),%rax
mov    %ecx,-0x90(%rbp,%rax,4)
mov    -0xc(%rbp),%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x90(%rbp,%rax,4)
jmp    1211 <main+0xf1>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b2 <main+0x92>
jmp    1224 <main+0x104>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    119d <main+0x7d>
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    127a <main+0x15a>
movslq -0x4(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%esi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1247 <main+0x127>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x90,%rsp
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    11fd <main+0xcd>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe82(%rip),%r14
xchg   %ax,%ax
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>
mov    %eax,%r8d
test   %r8d,%r8d
jle    11fd <main+0xcd>
lea    0x10(%rsp),%rcx
xor    %r9d,%r9d
mov    %r8,%rdx
jmp    11cd <main+0x9d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x4,%rcx
add    $0xffffffffffffffff,%rdx
cmp    %r8,%r9
je     11fd <main+0xcd>
mov    %r9,%rdi
add    $0x1,%r9
cmp    %r8,%r9
jae    11c0 <main+0x90>
mov    $0x1,%ebx
jmp    11e9 <main+0xb9>
add    $0x1,%rbx
cmp    %rbx,%rdx
je     11c0 <main+0x90>
mov    0x10(%rsp,%rdi,4),%eax
mov    (%rcx,%rbx,4),%esi
cmp    %esi,%eax
jle    11e0 <main+0xb0>
mov    %esi,0x10(%rsp,%rdi,4)
mov    %eax,(%rcx,%rbx,4)
jmp    11e0 <main+0xb0>
lea    0xe2c(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    123c <main+0x10c>
lea    0xdec(%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),%rax
cmp    %rax,%rbx
jl     1220 <main+0xf0>
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Enter the value of N \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Enter the numbers \0A\00"
@.str.3 = [58 x i8] c"The numbers arranged in ascending order are given below \0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [30 x i32]
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %9
9: ; preds = %18, %0
%10 = load i32, i32* %1
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %21
13: ; preds = %9
%14 = load i32, i32* %1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
br label %18
18: ; preds = %13
%19 = load i32, i32* %1
%20 = add nsw i32 %19, 1
store i32 %20, i32* %1
br label %9
21: ; preds = %9
store i32 0, i32* %1
br label %22
22: ; preds = %64, %21
%23 = load i32, i32* %1
%24 = load i32, i32* %4
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %67
26: ; preds = %22
%27 = load i32, i32* %1
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
br label %29
29: ; preds = %60, %26
%30 = load i32, i32* %2
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %63
33: ; preds = %29
%34 = load i32, i32* %1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = load i32, i32* %2
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = icmp sgt i32 %37, %41
br i1 %42, label %43, label %59
43: ; preds = %33
%44 = load i32, i32* %1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 %45
%47 = load i32, i32* %46
store i32 %47, i32* %3
%48 = load i32, i32* %2
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = load i32, i32* %1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 %53
store i32 %51, i32* %54
%55 = load i32, i32* %3
%56 = load i32, i32* %2
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 %57
store i32 %55, i32* %58
br label %59
59: ; preds = %43, %33
br label %60
60: ; preds = %59
%61 = load i32, i32* %2
%62 = add nsw i32 %61, 1
store i32 %62, i32* %2
br label %29
63: ; preds = %29
br label %64
64: ; preds = %63
%65 = load i32, i32* %1
%66 = add nsw i32 %65, 1
store i32 %66, i32* %1
br label %22
67: ; preds = %22
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %69
69: ; preds = %79, %67
%70 = load i32, i32* %1
%71 = load i32, i32* %4
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %82
73: ; preds = %69
%74 = load i32, i32* %1
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 %75
%77 = load i32, i32* %76
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %77)
br label %79
79: ; preds = %73
%80 = load i32, i32* %1
%81 = add nsw i32 %80, 1
store i32 %81, i32* %1
br label %69
82: ; preds = %69
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@str = [22 x i8] c"Enter the value of N \00"
@str.5 = [19 x i8] c"Enter the numbers \00"
@str.6 = [57 x i8] c"The numbers arranged in ascending order are given below \00"
define void @main() {
%1 = alloca i32
%2 = alloca [30 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [30 x i32]* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 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* %1)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %15, label %43
10: ; preds = %15
%11 = icmp sgt i32 %20, 0
br i1 %11, label %12, label %43
12: ; preds = %10
%13 = zext i32 %20 to i64
%14 = zext i32 %20 to i64
br label %26
15: ; preds = %0, %15
%16 = phi i64 [ %19, %15 ], [ 0, %0 ]
%17 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = add nuw nsw i64 %16, 1
%20 = load i32, i32* %1
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %15, label %10
23: ; preds = %40, %26
%24 = add nuw nsw i64 %28, 1
%25 = icmp eq i64 %29, %14
br i1 %25, label %43, label %26
26: ; preds = %12, %23
%27 = phi i64 [ 0, %12 ], [ %29, %23 ]
%28 = phi i64 [ 1, %12 ], [ %24, %23 ]
%29 = add nuw nsw i64 %27, 1
%30 = icmp ult i64 %29, %13
br i1 %30, label %31, label %23
31: ; preds = %26
%32 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %27
br label %33
33: ; preds = %31, %40
%34 = phi i64 [ %28, %31 ], [ %41, %40 ]
%35 = load i32, i32* %32
%36 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %34
%37 = load i32, i32* %36
%38 = icmp sgt i32 %35, %37
br i1 %38, label %39, label %40
39: ; preds = %33
store i32 %37, i32* %32
store i32 %35, i32* %36
br label %40
40: ; preds = %33, %39
%41 = add nuw nsw i64 %34, 1
%42 = icmp eq i64 %41, %14
br i1 %42, label %23, label %33
43: ; preds = %23, %0, %10
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.6, i64 0, i64 0))
%45 = load i32, i32* %1
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %56
47: ; preds = %43, %47
%48 = phi i64 [ %52, %47 ], [ 0, %43 ]
%49 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %50)
%52 = add nuw nsw i64 %48, 1
%53 = load i32, i32* %1
%54 = sext i32 %53 to i64
%55 = icmp slt i64 %52, %54
br i1 %55, label %47, label %56
56: ; preds = %47, %43
ret void
}