#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) {
  int iNum, i, j, iaArr[10], iTemp;
  printf("\n*************************************************");
  printf("\n*\tPROGRAM TO IMPLEMENT BUBBLE SORT\t*\n");
  printf("*************************************************");
  printf("\nEnter no of elements\n");
  scanf("%d", &iNum);
  printf("\nEnter the elements\n");
  for (i = 0; i < iNum; i++)
    scanf("%d", &iaArr[i]);
  for (i = 0; i < iNum; i++) {
    for (j = i + 1; j < iNum; j++) {
      if (iaArr[i] > iaArr[j]) {
        iTemp = iaArr[i];
        iaArr[i] = iaArr[j];
        iaArr[j] = iTemp;
      }
    }
  }
  printf("\nThe Sorted array is \n");
  for (i = 0; i < iNum; i++)
    printf("%d\t", iaArr[i]);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf03(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xef6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c1 <main+0xa1>
movslq -0xc(%rbp),%rax
lea    -0x40(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xec3(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118c <main+0x6c>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    124b <main+0x12b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1238 <main+0x118>
movslq -0xc(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
movslq -0x10(%rbp),%rcx
cmp    -0x40(%rbp,%rcx,4),%eax
jle    1225 <main+0x105>
movslq -0xc(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
mov    %eax,-0x44(%rbp)
movslq -0x10(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%ecx
movslq -0xc(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x44(%rbp),%ecx
movslq -0x10(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
jmp    122a <main+0x10a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11dd <main+0xbd>
jmp    123d <main+0x11d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c8 <main+0xa8>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1290 <main+0x170>
movslq -0xc(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1260 <main+0x140>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xedc(%rip),%rdi
call   1040 <puts@plt>
lea    0xe97(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xee8(%rip),%rdi
call   1040 <puts@plt>
lea    0xeaf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xee1(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    123d <main+0xfd>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe80(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     11c0 <main+0x80>
mov    %eax,%r8d
test   %r8d,%r8d
jle    123d <main+0xfd>
lea    0x10(%rsp),%rcx
xor    %r9d,%r9d
mov    %r8,%rdx
jmp    120d <main+0xcd>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x4,%rcx
add    $0xffffffffffffffff,%rdx
cmp    %r8,%r9
je     123d <main+0xfd>
mov    %r9,%rdi
add    $0x1,%r9
cmp    %r8,%r9
jae    1200 <main+0xc0>
mov    $0x1,%ebx
jmp    1229 <main+0xe9>
add    $0x1,%rbx
cmp    %rbx,%rdx
je     1200 <main+0xc0>
mov    0x10(%rsp,%rdi,4),%eax
mov    (%rcx,%rbx,4),%esi
cmp    %esi,%eax
jle    1220 <main+0xe0>
mov    %esi,0x10(%rsp,%rdi,4)
mov    %eax,(%rcx,%rbx,4)
jmp    1220 <main+0xe0>
lea    0xe46(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    127c <main+0x13c>
lea    0xddf(%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     1260 <main+0x120>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [51 x i8] c"\0A*************************************************\00"
@.str.2 = [50 x i8] c"*************************************************\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.7 = [4 x i8] c"%d\09\00"
@str = [38 x i8] c"\0A*\09PROGRAM TO IMPLEMENT BUBBLE SORT\09*\00"
@str.9 = [22 x i8] c"\0AEnter no of elements\00"
@str.10 = [20 x i8] c"\0AEnter the elements\00"
@str.11 = [22 x i8] c"\0AThe Sorted array is \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [10 x i32]* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %18, label %46
13: ; preds = %18
%14 = icmp sgt i32 %23, 0
br i1 %14, label %15, label %46
15: ; preds = %13
%16 = zext i32 %23 to i64
%17 = zext i32 %23 to i64
br label %29
18: ; preds = %0, %18
%19 = phi i64 [ %22, %18 ], [ 0, %0 ]
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %19
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %20)
%22 = add nuw nsw i64 %19, 1
%23 = load i32, i32* %1
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %22, %24
br i1 %25, label %18, label %13
26: ; preds = %43, %29
%27 = add nuw nsw i64 %31, 1
%28 = icmp eq i64 %32, %17
br i1 %28, label %46, label %29
29: ; preds = %15, %26
%30 = phi i64 [ 0, %15 ], [ %32, %26 ]
%31 = phi i64 [ 1, %15 ], [ %27, %26 ]
%32 = add nuw nsw i64 %30, 1
%33 = icmp ult i64 %32, %16
br i1 %33, label %34, label %26
34: ; preds = %29
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %30
br label %36
36: ; preds = %34, %43
%37 = phi i64 [ %31, %34 ], [ %44, %43 ]
%38 = load i32, i32* %35
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %37
%40 = load i32, i32* %39
%41 = icmp sgt i32 %38, %40
br i1 %41, label %42, label %43
42: ; preds = %36
store i32 %40, i32* %35
store i32 %38, i32* %39
br label %43
43: ; preds = %36, %42
%44 = add nuw nsw i64 %37, 1
%45 = icmp eq i64 %44, %17
br i1 %45, label %26, label %36
46: ; preds = %26, %0, %13
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.11, i64 0, i64 0))
%48 = load i32, i32* %1
%49 = icmp sgt i32 %48, 0
br i1 %49, label %50, label %59
50: ; preds = %46, %50
%51 = phi i64 [ %55, %50 ], [ 0, %46 ]
%52 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %53)
%55 = add nuw nsw i64 %51, 1
%56 = load i32, i32* %1
%57 = sext i32 %56 to i64
%58 = icmp slt i64 %55, %57
br i1 %58, label %50, label %59
59: ; preds = %50, %46
%60 = call i32 @putchar(i32 10)
ret i32 0
}