#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*/ bubbleSort(int *, int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int rand();
int main() {
  int myarray[50];
  int i, n;
  n = 50;
  for (i = 0; i < 50; i++) {
    myarray[i] = (rand() % (50 * 2)) + 1;
  }
  printf("\nArray is:        ");
  for (i = 0; i < 50; i++) {
    printf("%d ", myarray[i]);
  }
  bubbleSort(myarray, n);
  printf("\n\nSorted Array is: \n");
  for (i = 0; i < 50; i++) {
    printf("%d ", myarray[i]);
  }
  printf("\n\n[Press Enter to close]");
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x32,-0xd8(%rbp)
movl   $0x0,-0xd4(%rbp)
cmpl   $0x32,-0xd4(%rbp)
jge    11a7 <main+0x67>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
movslq -0xd4(%rbp),%rax
mov    %edx,-0xd0(%rbp,%rax,4)
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    1166 <main+0x26>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xd4(%rbp)
cmpl   $0x32,-0xd4(%rbp)
jge    11fc <main+0xbc>
movslq -0xd4(%rbp),%rax
mov    -0xd0(%rbp,%rax,4),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    11bf <main+0x7f>
lea    -0xd0(%rbp),%rdi
mov    -0xd8(%rbp),%esi
call   1040 <bubbleSort@plt>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xd4(%rbp)
cmpl   $0x32,-0xd4(%rbp)
jge    1263 <main+0x123>
movslq -0xd4(%rbp),%rax
mov    -0xd0(%rbp,%rax,4),%esi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    1226 <main+0xe6>
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xc8,%rsp
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x32,%rbx
jne    1160 <main+0x10>
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe6a(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x32,%rbx
jne    11b0 <main+0x60>
mov    %rsp,%rdi
mov    $0x32,%esi
call   1050 <bubbleSort@plt>
lea    0xe55(%rip),%rdi
call   1030 <puts@plt>
lea    0xe2c(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x32,%rbx
jne    11f0 <main+0xa0>
lea    0xe09(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"\0AArray is: \00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [21 x i8] c"\0A\0ASorted Array is: \0A\00"
@.str.3 = [25 x i8] c"\0A\0A[Press Enter to close]\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 50, i32* %4
store i32 0, i32* %3
br label %5
5: ; preds = %15, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 50
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 100
%11 = add nsw i32 %10, 1
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %13
store i32 %11, i32* %14
br label %15
15: ; preds = %8
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %5
18: ; preds = %5
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %20
20: ; preds = %29, %18
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 50
br i1 %22, label %23, label %32
23: ; preds = %20
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %23
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %20
32: ; preds = %20
%33 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%34 = load i32, i32* %4
%35 = call i32 @bubbleSort(i32* %33, i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %37
37: ; preds = %46, %32
%38 = load i32, i32* %3
%39 = icmp slt i32 %38, 50
br i1 %39, label %40, label %49
40: ; preds = %37
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %40
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
br label %37
49: ; preds = %37
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%51 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"\0AArray is: \00"
@.str.1 = [4 x i8] c"%d \00"
@.str.3 = [25 x i8] c"\0A\0A[Press Enter to close]\00"
@str = [20 x i8] c"\0A\0ASorted Array is: \00"
define i32 @main() {
%1 = alloca [50 x i32]
%2 = bitcast [50 x i32]* %1 to i8*
br label %3
3: ; preds = %0, %3
%4 = phi i64 [ 0, %0 ], [ %9, %3 ]
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 100
%7 = add nsw i32 %6, 1
%8 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %4
store i32 %7, i32* %8
%9 = add nuw nsw i64 %4, 1
%10 = icmp eq i64 %9, 50
br i1 %10, label %11, label %3
11: ; preds = %3
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ 0, %11 ], [ %18, %13 ]
%15 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = add nuw nsw i64 %14, 1
%19 = icmp eq i64 %18, 50
br i1 %19, label %20, label %13
20: ; preds = %13
%21 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 0
%22 = call i32 @bubbleSort(i32* %21, i32 50)
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %20, %24
%25 = phi i64 [ 0, %20 ], [ %29, %24 ]
%26 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = add nuw nsw i64 %25, 1
%30 = icmp eq i64 %29, 50
br i1 %30, label %31, label %24
31: ; preds = %24
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 (...) @getchar()
ret i32 0
}