#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*/ sprintf(char *, char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  int language = 0, algorithm = 0, size = 0, increaseSize = 10,
      increaseSizeAux = 1;
  char algorithmText[50], program[200];
  system("rm -rf ../../outputs && mkdir ../../outputs");
  for (language = 0; language <= 5; language++) {
    for (increaseSize = 10, increaseSizeAux = 1, size = 10; size <= 1000000;
         size += increaseSize) {
      if (increaseSizeAux % 10 == 0) {
        increaseSizeAux = 1;
        increaseSize = increaseSize * 10;
      }
      for (algorithm = 0; algorithm < 7; algorithm++) {
        strcpy(algorithmText, (algorithm == 0)   ? "bubbleSort"
                              : (algorithm == 1) ? "countingSort"
                              : (algorithm == 2) ? "heapSort"
                              : (algorithm == 3) ? "insertionSort"
                              : (algorithm == 4) ? "mergeSort"
                              : (algorithm == 5) ? "quickSort"
                                                 : "selectionSort");
        sprintf(program,
                "gcc benchmark.c -o benchmark.out && ./benchmark.out %s %d",
                algorithmText, size);
        system(program);
        system("sudo sync && free -m && sudo sysctl -w vm.drop_caches=3");
      }
      increaseSizeAux++;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0xa,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
lea    0xe8d(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jg     134e <main+0x21e>
movl   $0xa,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0xa,-0x1c(%rbp)
cmpl   $0xf4240,-0x1c(%rbp)
jg     133b <main+0x20b>
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11cd <main+0x9d>
movl   $0x1,-0x24(%rbp)
imul   $0xa,-0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x7,-0x18(%rbp)
jge    1324 <main+0x1f4>
lea    -0x60(%rbp),%rax
mov    %rax,-0x138(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1206 <main+0xd6>
lea    0xe32(%rip),%rax
mov    %rax,-0x140(%rbp)
jmp    12d1 <main+0x1a1>
cmpl   $0x1,-0x18(%rbp)
jne    1223 <main+0xf3>
lea    0xe20(%rip),%rax
mov    %rax,-0x148(%rbp)
jmp    12c3 <main+0x193>
cmpl   $0x2,-0x18(%rbp)
jne    1240 <main+0x110>
lea    0xe10(%rip),%rax
mov    %rax,-0x150(%rbp)
jmp    12b5 <main+0x185>
cmpl   $0x3,-0x18(%rbp)
jne    125d <main+0x12d>
lea    0xdfc(%rip),%rax
mov    %rax,-0x158(%rbp)
jmp    12a7 <main+0x177>
cmpl   $0x4,-0x18(%rbp)
jne    127a <main+0x14a>
lea    0xded(%rip),%rax
mov    %rax,-0x160(%rbp)
jmp    1299 <main+0x169>
mov    -0x18(%rbp),%edx
lea    0xdeb(%rip),%rax
lea    0xdda(%rip),%rcx
cmp    $0x5,%edx
cmove  %rcx,%rax
mov    %rax,-0x160(%rbp)
mov    -0x160(%rbp),%rax
mov    %rax,-0x158(%rbp)
mov    -0x158(%rbp),%rax
mov    %rax,-0x150(%rbp)
mov    -0x150(%rbp),%rax
mov    %rax,-0x148(%rbp)
mov    -0x148(%rbp),%rax
mov    %rax,-0x140(%rbp)
mov    -0x138(%rbp),%rdi
mov    -0x140(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x130(%rbp),%rdi
lea    -0x60(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
lea    0xd84(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x130(%rbp),%rdi
call   1040 <system@plt>
lea    0xda6(%rip),%rdi
call   1040 <system@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11d4 <main+0xa4>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    119e <main+0x6e>
jmp    1340 <main+0x210>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117f <main+0x4f>
xor    %eax,%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
lea    0xeb8(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
lea    0x10(%rsp),%r12
lea    0x50(%rsp),%rbx
nopl   0x0(%rax)
mov    %eax,(%rsp)
mov    $0xa,%eax
mov    $0x1,%r14d
mov    $0xa,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rax,0x8(%rsp)
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %eax,0x4(%rsp)
mov    %r12,%rdi
lea    0xe94(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
lea    0xed6(%rip),%r15
mov    %r15,%rsi
mov    %r12,%rdx
mov    %ebp,%ecx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
lea    0xef4(%rip),%r13
mov    %r13,%rdi
call   1040 <system@plt>
mov    %r12,%rdi
lea    0xe62(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %ebp,%ecx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %r13,%rdi
call   1040 <system@plt>
mov    %r12,%rdi
lea    0xe40(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %ebp,%ecx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %r13,%rdi
call   1040 <system@plt>
mov    %r12,%rdi
lea    0xe1a(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %ebp,%ecx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %r13,%rdi
call   1040 <system@plt>
mov    %r12,%rdi
lea    0xdf9(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %ebp,%ecx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %r13,%rdi
call   1040 <system@plt>
mov    %r12,%rdi
lea    0xdd4(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %ebp,%ecx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %r13,%rdi
call   1040 <system@plt>
mov    %r12,%rdi
lea    0xdaf(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %ebp,%ecx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %r13,%rdi
call   1040 <system@plt>
mov    $0x2,%ecx
imul   $0xcccccccd,%r14d,%eax
add    $0x19999998,%eax
ror    %eax
add    $0x1,%r14d
cmp    $0x19999999,%eax
mov    0x4(%rsp),%eax
cmovae 0x8(%rsp),%eax
cmovb  %ecx,%r14d
add    %eax,%ebp
cmp    $0xf4241,%ebp
jl     1180 <main+0x50>
mov    (%rsp),%eax
add    $0x1,%eax
cmp    $0x6,%eax
jne    1160 <main+0x30>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"rm -rf ../../outputs && mkdir ../../outputs\00"
@.str.1 = [11 x i8] c"bubbleSort\00"
@.str.2 = [13 x i8] c"countingSort\00"
@.str.3 = [9 x i8] c"heapSort\00"
@.str.4 = [14 x i8] c"insertionSort\00"
@.str.5 = [10 x i8] c"mergeSort\00"
@.str.6 = [10 x i8] c"quickSort\00"
@.str.7 = [14 x i8] c"selectionSort\00"
@.str.8 = [58 x i8] c"gcc benchmark.c -o benchmark.out && ./benchmark.out %s %d\00"
@.str.9 = [56 x i8] c"sudo sync && free -m && sudo sysctl -w vm.drop_caches=3\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [50 x i8]
%12 = alloca [200 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 10, i32* %9
store i32 1, i32* %10
%13 = call i32 @system(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %14
14: ; preds = %87, %2
%15 = load i32, i32* %6
%16 = icmp sle i32 %15, 5
br i1 %16, label %17, label %90
17: ; preds = %14
store i32 10, i32* %9
store i32 1, i32* %10
store i32 10, i32* %8
br label %18
18: ; preds = %82, %17
%19 = load i32, i32* %8
%20 = icmp sle i32 %19, 1000000
br i1 %20, label %21, label %86
21: ; preds = %18
%22 = load i32, i32* %10
%23 = srem i32 %22, 10
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
store i32 1, i32* %10
%26 = load i32, i32* %9
%27 = mul nsw i32 %26, 10
store i32 %27, i32* %9
br label %28
28: ; preds = %25, %21
store i32 0, i32* %7
br label %29
29: ; preds = %76, %28
%30 = load i32, i32* %7
%31 = icmp slt i32 %30, 7
br i1 %31, label %32, label %79
32: ; preds = %29
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %11, i64 0, i64 0
%34 = load i32, i32* %7
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
br label %66
37: ; preds = %32
%38 = load i32, i32* %7
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %41
40: ; preds = %37
br label %64
41: ; preds = %37
%42 = load i32, i32* %7
%43 = icmp eq i32 %42, 2
br i1 %43, label %44, label %45
44: ; preds = %41
br label %62
45: ; preds = %41
%46 = load i32, i32* %7
%47 = icmp eq i32 %46, 3
br i1 %47, label %48, label %49
48: ; preds = %45
br label %60
49: ; preds = %45
%50 = load i32, i32* %7
%51 = icmp eq i32 %50, 4
br i1 %51, label %52, label %53
52: ; preds = %49
br label %58
53: ; preds = %49
%54 = load i32, i32* %7
%55 = icmp eq i32 %54, 5
%56 = zext i1 %55 to i64
%57 = select i1 %55, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0)
br label %58
58: ; preds = %53, %52
%59 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), %52 ], [ %57, %53 ]
br label %60
60: ; preds = %58, %48
%61 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), %48 ], [ %59, %58 ]
br label %62
62: ; preds = %60, %44
%63 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), %44 ], [ %61, %60 ]
br label %64
64: ; preds = %62, %40
%65 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), %40 ], [ %63, %62 ]
br label %66
66: ; preds = %64, %36
%67 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), %36 ], [ %65, %64 ]
%68 = call i32 @strcpy(i8* %33, i8* %67)
%69 = getelementptr inbounds [200 x i8], [200 x i8]* %12, i64 0, i64 0
%70 = getelementptr inbounds [50 x i8], [50 x i8]* %11, i64 0, i64 0
%71 = load i32, i32* %8
%72 = call i32 @sprintf(i8* %69, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0), i8* %70, i32 %71)
%73 = getelementptr inbounds [200 x i8], [200 x i8]* %12, i64 0, i64 0
%74 = call i32 @system(i8* %73)
%75 = call i32 @system(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.9, i64 0, i64 0))
br label %76
76: ; preds = %66
%77 = load i32, i32* %7
%78 = add nsw i32 %77, 1
store i32 %78, i32* %7
br label %29
79: ; preds = %29
%80 = load i32, i32* %10
%81 = add nsw i32 %80, 1
store i32 %81, i32* %10
br label %82
82: ; preds = %79
%83 = load i32, i32* %9
%84 = load i32, i32* %8
%85 = add nsw i32 %84, %83
store i32 %85, i32* %8
br label %18
86: ; preds = %18
br label %87
87: ; preds = %86
%88 = load i32, i32* %6
%89 = add nsw i32 %88, 1
store i32 %89, i32* %6
br label %14
90: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"rm -rf ../../outputs && mkdir ../../outputs\00"
@.str.1 = [11 x i8] c"bubbleSort\00"
@.str.2 = [13 x i8] c"countingSort\00"
@.str.3 = [9 x i8] c"heapSort\00"
@.str.4 = [14 x i8] c"insertionSort\00"
@.str.5 = [10 x i8] c"mergeSort\00"
@.str.6 = [10 x i8] c"quickSort\00"
@.str.7 = [14 x i8] c"selectionSort\00"
@.str.8 = [58 x i8] c"gcc benchmark.c -o benchmark.out && ./benchmark.out %s %d\00"
@.str.9 = [56 x i8] c"sudo sync && free -m && sudo sysctl -w vm.drop_caches=3\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [50 x i8]
%4 = alloca [200 x i8]
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @system(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %2, %50
%9 = phi i32 [ 0, %2 ], [ %51, %50 ]
br label %10
10: ; preds = %10, %8
%11 = phi i32 [ 1, %8 ], [ %47, %10 ]
%12 = phi i32 [ 10, %8 ], [ %45, %10 ]
%13 = phi i32 [ 10, %8 ], [ %48, %10 ]
%14 = srem i32 %11, 10
%15 = mul nsw i32 %12, 10
%16 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0), i8* %5, i32 %13)
%18 = call i32 @system(i8* %6)
%19 = call i32 @system(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.9, i64 0, i64 0))
%20 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0), i8* %5, i32 %13)
%22 = call i32 @system(i8* %6)
%23 = call i32 @system(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.9, i64 0, i64 0))
%24 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0), i8* %5, i32 %13)
%26 = call i32 @system(i8* %6)
%27 = call i32 @system(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.9, i64 0, i64 0))
%28 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0), i8* %5, i32 %13)
%30 = call i32 @system(i8* %6)
%31 = call i32 @system(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.9, i64 0, i64 0))
%32 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%33 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0), i8* %5, i32 %13)
%34 = call i32 @system(i8* %6)
%35 = call i32 @system(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.9, i64 0, i64 0))
%36 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%37 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0), i8* %5, i32 %13)
%38 = call i32 @system(i8* %6)
%39 = call i32 @system(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.9, i64 0, i64 0))
%40 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%41 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0), i8* %5, i32 %13)
%42 = call i32 @system(i8* %6)
%43 = call i32 @system(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.9, i64 0, i64 0))
%44 = icmp eq i32 %14, 0
%45 = select i1 %44, i32 %15, i32 %12
%46 = add nsw i32 %11, 1
%47 = select i1 %44, i32 2, i32 %46
%48 = add nsw i32 %45, %13
%49 = icmp slt i32 %48, 1000001
br i1 %49, label %10, label %50
50: ; preds = %10
%51 = add nuw nsw i32 %9, 1
%52 = icmp eq i32 %51, 6
br i1 %52, label %53, label %8
53: ; preds = %50
ret i32 0
}