#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() {
  int a[100], i, j, t, n, xchange;
  printf("Enter the number of element : ");
  scanf("%d", &n);
  printf("Enter the elements of the array ");
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);
  for (i = 0; i < n - 1; i++) {
    xchange = 0;
    for (j = 0; j < n - 1 - i; j++) {
      if (a[j] > a[j + 1]) {
        t = a[j];
        a[j] = a[j + 1];
        a[j + 1] = t;
        xchange++;
      }
    }
    if (xchange == 0)
      break;
  }
  printf("Sorted list is : \n");
  for (i = 0; i < n; i++)
    printf("%d ", a[i]);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x1b0(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x1b0(%rbp),%eax
jge    11b2 <main+0x92>
movslq -0x1a4(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe86(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    116b <main+0x4b>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
mov    -0x1b0(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12ca <main+0x1aa>
movl   $0x0,-0x1b4(%rbp)
movl   $0x0,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
mov    -0x1b0(%rbp),%ecx
sub    $0x1,%ecx
sub    -0x1a4(%rbp),%ecx
cmp    %ecx,%eax
jge    129f <main+0x17f>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    -0x1a8(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    -0x1a0(%rbp,%rcx,4),%eax
jle    1286 <main+0x166>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    %eax,-0x1ac(%rbp)
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x1a0(%rbp,%rax,4),%ecx
movslq -0x1a8(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1ac(%rbp),%ecx
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
jmp    128b <main+0x16b>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    11e7 <main+0xc7>
cmpl   $0x0,-0x1b4(%rbp)
jne    12b1 <main+0x191>
jmp    12ca <main+0x1aa>
jmp    12b6 <main+0x196>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    11bc <main+0x9c>
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x1b0(%rbp),%eax
jge    1324 <main+0x204>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xd4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    12e2 <main+0x1c2>
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1a0,%rsp
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xebe(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1230 <main+0xf0>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe8d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%r10
add    $0x4,%r15
cmp    %r10,%rbx
jl     11a0 <main+0x60>
cmp    $0x2,%r10d
jl     1230 <main+0xf0>
lea    -0x1(%r10),%r8d
xor    %r9d,%r9d
mov    %r8d,%esi
nopl   (%rax)
mov    %r9d,%eax
not    %eax
add    %r10d,%eax
test   %eax,%eax
jle    1230 <main+0xf0>
mov    %esi,%esi
xor    %ecx,%ecx
mov    0x10(%rsp),%eax
xor    %ebx,%ebx
jmp    1203 <main+0xc3>
nopl   0x0(%rax,%rax,1)
mov    %edi,0x10(%rsp,%rcx,4)
mov    %eax,0x14(%rsp,%rcx,4)
add    $0x1,%ebx
mov    %rdx,%rcx
cmp    %rdx,%rsi
je     1220 <main+0xe0>
lea    0x1(%rcx),%rdx
mov    0x14(%rsp,%rcx,4),%edi
cmp    %edi,%eax
jg     11f0 <main+0xb0>
mov    %edi,%eax
jmp    11fb <main+0xbb>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
test   %ebx,%ebx
je     1230 <main+0xf0>
add    $0x1,%r9d
add    $0xffffffff,%esi
cmp    %r8d,%r9d
jl     11d0 <main+0x90>
lea    0xe10(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    126c <main+0x12c>
lea    0xdf9(%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     1250 <main+0x110>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Enter the number of element : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"Enter the elements of the array \00"
@.str.3 = [19 x i8] c"Sorted list is : \0A\00"
@.str.4 = [4 x i8] c"%d \00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %11
11: ; preds = %20, %0
%12 = load i32, i32* %3
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %17
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
br label %20
20: ; preds = %15
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %11
23: ; preds = %11
store i32 0, i32* %3
br label %24
24: ; preds = %77, %23
%25 = load i32, i32* %3
%26 = load i32, i32* %6
%27 = sub nsw i32 %26, 1
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %80
29: ; preds = %24
store i32 0, i32* %7
store i32 0, i32* %4
br label %30
30: ; preds = %69, %29
%31 = load i32, i32* %4
%32 = load i32, i32* %6
%33 = sub nsw i32 %32, 1
%34 = load i32, i32* %3
%35 = sub nsw i32 %33, %34
%36 = icmp slt i32 %31, %35
br i1 %36, label %37, label %72
37: ; preds = %30
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = icmp sgt i32 %41, %46
br i1 %47, label %48, label %68
48: ; preds = %37
%49 = load i32, i32* %4
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %50
%52 = load i32, i32* %51
store i32 %52, i32* %5
%53 = load i32, i32* %4
%54 = add nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = load i32, i32* %4
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %59
store i32 %57, i32* %60
%61 = load i32, i32* %5
%62 = load i32, i32* %4
%63 = add nsw i32 %62, 1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %64
store i32 %61, i32* %65
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
store i32 %67, i32* %7
br label %68
68: ; preds = %48, %37
br label %69
69: ; preds = %68
%70 = load i32, i32* %4
%71 = add nsw i32 %70, 1
store i32 %71, i32* %4
br label %30
72: ; preds = %30
%73 = load i32, i32* %7
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %76
75: ; preds = %72
br label %80
76: ; preds = %72
br label %77
77: ; preds = %76
%78 = load i32, i32* %3
%79 = add nsw i32 %78, 1
store i32 %79, i32* %3
br label %24
80: ; preds = %75, %24
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %82
82: ; preds = %92, %80
%83 = load i32, i32* %3
%84 = load i32, i32* %6
%85 = icmp slt i32 %83, %84
br i1 %85, label %86, label %95
86: ; preds = %82
%87 = load i32, i32* %3
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %88
%90 = load i32, i32* %89
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %90)
br label %92
92: ; preds = %86
%93 = load i32, i32* %3
%94 = add nsw i32 %93, 1
store i32 %94, i32* %3
br label %82
95: ; preds = %82
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"Enter the number of element : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"Enter the elements of the array \00"
@.str.4 = [4 x i8] c"%d \00"
@str = [18 x i8] c"Sorted list is : \00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = bitcast [100 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %15, label %53
10: ; preds = %15
%11 = add i32 %20, -1
%12 = icmp sgt i32 %20, 1
br i1 %12, label %13, label %53
13: ; preds = %10
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
br label %23
15: ; preds = %0, %15
%16 = phi i64 [ %19, %15 ], [ 0, %0 ]
%17 = getelementptr inbounds [100 x i32], [100 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 = %47, %13
%24 = phi i32 [ %52, %47 ], [ %11, %13 ]
%25 = phi i32 [ %49, %47 ], [ 0, %13 ]
%26 = xor i32 %25, -1
%27 = add i32 %20, %26
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %53
29: ; preds = %23
%30 = zext i32 %24 to i64
%31 = load i32, i32* %14
br label %32
32: ; preds = %29, %43
%33 = phi i32 [ %31, %29 ], [ %44, %43 ]
%34 = phi i64 [ 0, %29 ], [ %36, %43 ]
%35 = phi i32 [ 0, %29 ], [ %45, %43 ]
%36 = add nuw nsw i64 %34, 1
%37 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = icmp sgt i32 %33, %38
br i1 %39, label %40, label %43
40: ; preds = %32
%41 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %34
store i32 %38, i32* %41
store i32 %33, i32* %37
%42 = add nsw i32 %35, 1
br label %43
43: ; preds = %32, %40
%44 = phi i32 [ %33, %40 ], [ %38, %32 ]
%45 = phi i32 [ %42, %40 ], [ %35, %32 ]
%46 = icmp eq i64 %36, %30
br i1 %46, label %47, label %32
47: ; preds = %43
%48 = icmp ne i32 %45, 0
%49 = add nuw nsw i32 %25, 1
%50 = icmp slt i32 %49, %11
%51 = select i1 %48, i1 %50, i1 false
%52 = add i32 %24, -1
br i1 %51, label %23, label %53
53: ; preds = %23, %47, %0, %10
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%55 = load i32, i32* %2
%56 = icmp sgt i32 %55, 0
br i1 %56, label %57, label %66
57: ; preds = %53, %57
%58 = phi i64 [ %62, %57 ], [ 0, %53 ]
%59 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %58
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %60)
%62 = add nuw nsw i64 %58, 1
%63 = load i32, i32* %2
%64 = sext i32 %63 to i64
%65 = icmp slt i64 %62, %64
br i1 %65, label %57, label %66
66: ; preds = %57, %53
%67 = call i32 @putchar(i32 10)
ret i32 0
}