#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 */
typedef scalar_t__ clock_t;

/* Variables and functions */
scalar_t__ CLOCKS_PER_SEC;
int /*<<< orphan*/ bubbleSort(int *, int);
scalar_t__ clock();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int rows, iterator, rowValue, *arrayToBeSort;
  double seconds;
  scanf("%d", &rows);
  if ((arrayToBeSort = malloc(rows * sizeof(int))) == NULL) {
    printf("Impossible to allocate space");
    exit(0);
  }
  arrayToBeSort = malloc(rows * sizeof(int));
  for (iterator = 0; iterator < rows; iterator++) {
    scanf("%d", &rowValue);
    arrayToBeSort[iterator] = rowValue;
  }
  clock_t clockStarts = clock();
  bubbleSort(arrayToBeSort, rows);
  clock_t clockEnds = clock();
  seconds = (double)(clockEnds - clockStarts) / (double)CLOCKS_PER_SEC;
  printf("\nStarted at: %g", (double)clockStarts / (double)CLOCKS_PER_SEC);
  printf("\nCompleted at: %g", (double)clockEnds / (double)CLOCKS_PER_SEC);
  printf("\nExecution time in seconds: %g", seconds);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11b1 <main+0x51>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1203 <main+0xa3>
lea    0xe22(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11cb <main+0x6b>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <bubbleSort@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x28(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2daf(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdq -0x28(%rbp),%xmm0
mov    0x2d94(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
lea    0xdbc(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cvtsi2sdq -0x30(%rbp),%xmm0
mov    0x2d70(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
lea    0xda8(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xda7(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe8e(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x8(%rsp),%r14d
lea    0x0(,%r14,4),%ebx
mov    %ebx,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     127d <main+0x11d>
mov    %ebx,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
test   %r14d,%r14d
jle    11e1 <main+0x81>
xor    %ebx,%ebx
lea    0xe4f(%rip),%r14
lea    0xc(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%eax
mov    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
cmp    %rax,%rbx
jl     11c0 <main+0x60>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%r14
mov    0x8(%rsp),%esi
mov    %r12,%rdi
call   1050 <bubbleSort@plt>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
sub    %r14,%rax
cvtsi2sd %rax,%xmm0
mov    0x2dd8(%rip),%r15
cvtsi2sdq (%r15),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r14,%xmm0
divsd  %xmm1,%xmm0
lea    0xdee(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq (%r15),%xmm1
divsd  %xmm1,%xmm0
lea    0xddc(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xde0(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xd7f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [29 x i8] c"Impossible to allocate space\00"
@CLOCKS_PER_SEC = global i64 0
@.str.2 = [16 x i8] c"\0AStarted at: %g\00"
@.str.3 = [18 x i8] c"\0ACompleted at: %g\00"
@.str.4 = [31 x i8] c"\0AExecution time in seconds: %g\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca double
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %1
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 4
%13 = trunc i64 %12 to i32
%14 = call i32* @malloc(i32 %13)
store i32* %14, i32** %5
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %0
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 4
%23 = trunc i64 %22 to i32
%24 = call i32* @malloc(i32 %23)
store i32* %24, i32** %5
store i32 0, i32* %3
br label %25
25: ; preds = %36, %19
%26 = load i32, i32* %3
%27 = load i32, i32* %2
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %39
29: ; preds = %25
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%31 = load i32, i32* %4
%32 = load i32*, i32** %5
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
store i32 %31, i32* %35
br label %36
36: ; preds = %29
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %25
39: ; preds = %25
%40 = call i64 (...) @clock()
store i64 %40, i64* %7
%41 = load i32*, i32** %5
%42 = load i32, i32* %2
%43 = call i32 @bubbleSort(i32* %41, i32 %42)
%44 = call i64 (...) @clock()
store i64 %44, i64* %8
%45 = load i64, i64* %8
%46 = load i64, i64* %7
%47 = sub nsw i64 %45, %46
%48 = sitofp i64 %47 to double
%49 = load i64, i64* @CLOCKS_PER_SEC
%50 = sitofp i64 %49 to double
%51 = fdiv double %48, %50
store double %51, double* %6
%52 = load i64, i64* %7
%53 = sitofp i64 %52 to double
%54 = load i64, i64* @CLOCKS_PER_SEC
%55 = sitofp i64 %54 to double
%56 = fdiv double %53, %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %56)
%58 = load i64, i64* %8
%59 = sitofp i64 %58 to double
%60 = load i64, i64* @CLOCKS_PER_SEC
%61 = sitofp i64 %60 to double
%62 = fdiv double %59, %61
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), double %62)
%64 = load double, double* %6
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), double %64)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [29 x i8] c"Impossible to allocate space\00"
@CLOCKS_PER_SEC = global i64 0
@.str.2 = [16 x i8] c"\0AStarted at: %g\00"
@.str.3 = [18 x i8] c"\0ACompleted at: %g\00"
@.str.4 = [31 x i8] c"\0AExecution time in seconds: %g\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = shl i32 %6, 2
%8 = call i32* @malloc(i32 %7)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @exit(i32 0)
unreachable
13: ; preds = %0
%14 = call i32* @malloc(i32 %7)
%15 = icmp sgt i32 %6, 0
br i1 %15, label %16, label %25
16: ; preds = %13, %16
%17 = phi i64 [ %21, %16 ], [ 0, %13 ]
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%19 = load i32, i32* %2
%20 = getelementptr inbounds i32, i32* %14, i64 %17
store i32 %19, i32* %20
%21 = add nuw nsw i64 %17, 1
%22 = load i32, i32* %1
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %21, %23
br i1 %24, label %16, label %25
25: ; preds = %16, %13
%26 = call i64 (...) @clock()
%27 = load i32, i32* %1
%28 = call i32 @bubbleSort(i32* %14, i32 %27)
%29 = call i64 (...) @clock()
%30 = sub nsw i64 %29, %26
%31 = sitofp i64 %30 to double
%32 = load i64, i64* @CLOCKS_PER_SEC
%33 = sitofp i64 %32 to double
%34 = fdiv double %31, %33
%35 = sitofp i64 %26 to double
%36 = fdiv double %35, %33
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %36)
%38 = sitofp i64 %29 to double
%39 = load i64, i64* @CLOCKS_PER_SEC
%40 = sitofp i64 %39 to double
%41 = fdiv double %38, %40
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), double %41)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), double %34)
ret i32 0
}