#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[10], n, val, min;
  printf("Enter the how mny nos......\n");
  scanf("%d", &n);
  printf("Enter the element .......\n");
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (a[i] > a[j]) {
        val = a[i];
        a[i] = a[j];
        a[j] = val;
      }
    }
  }
  printf("sorted elements are.......\n");
  for (i = 0; i < n; i++)
    printf("%d ", a[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1190 <main+0x70>
movslq -0x4(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xea0(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    115b <main+0x3b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    121a <main+0xfa>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1207 <main+0xe7>
movslq -0x4(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x8(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jle    11f4 <main+0xd4>
movslq -0x4(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x38(%rbp)
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x4(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x38(%rbp),%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
jmp    11f9 <main+0xd9>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ac <main+0x8c>
jmp    120c <main+0xec>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1197 <main+0x77>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    125f <main+0x13f>
movslq -0x4(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    122f <main+0x10f>
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
lea    0xeb7(%rip),%rdi
call   1040 <puts@plt>
lea    0xea4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xeb6(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    120d <main+0xcd>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe75(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     1190 <main+0x50>
mov    %eax,%r8d
test   %r8d,%r8d
jle    120d <main+0xcd>
lea    0x10(%rsp),%rcx
xor    %r9d,%r9d
mov    %r8,%rdx
jmp    11dd <main+0x9d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x4,%rcx
add    $0xffffffffffffffff,%rdx
cmp    %r8,%r9
je     120d <main+0xcd>
mov    %r9,%rdi
add    $0x1,%r9
cmp    %r8,%r9
jae    11d0 <main+0x90>
mov    $0x1,%ebx
jmp    11f9 <main+0xb9>
add    $0x1,%rbx
cmp    %rbx,%rdx
je     11d0 <main+0x90>
mov    0x10(%rsp,%rdi,4),%eax
mov    (%rcx,%rbx,4),%esi
cmp    %esi,%eax
jle    11f0 <main+0xb0>
mov    %esi,0x10(%rsp,%rdi,4)
mov    %eax,(%rcx,%rbx,4)
jmp    11f0 <main+0xb0>
lea    0xe29(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    124c <main+0x10c>
lea    0xddc(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1230 <main+0xf0>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"%d \00"
@str = [28 x i8] c"Enter the how mny nos......\00"
@str.6 = [26 x i8] c"Enter the element .......\00"
@str.7 = [27 x i8] c"sorted elements are.......\00"
define void @main() {
%1 = alloca [10 x i32]
%2 = alloca i32
%3 = bitcast [10 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 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 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.6, i64 0, i64 0))
%8 = load i32, i32* %2
%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 [10 x i32], [10 x i32]* %1, 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* %2
%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 [10 x i32], [10 x i32]* %1, 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 [10 x i32], [10 x i32]* %1, 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 ([27 x i8], [27 x i8]* @str.7, i64 0, i64 0))
%45 = load i32, i32* %2
%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 [10 x i32], [10 x i32]* %1, 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* %2
%54 = sext i32 %53 to i64
%55 = icmp slt i64 %52, %54
br i1 %55, label %47, label %56
56: ; preds = %47, %43
%57 = call i32 @putchar(i32 10)
ret void
}