#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 */
double CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ quicksort(int *, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  clock_t tic = clock();
  int a[10];
  int i = 0;
  printf("enter the %d numbers to be sorted: \n", 10);
  while (i < 10) {
    scanf("%d", &a[i]);
    i++;
  }
  printf("original array: ");
  for (i = 0; i < 10; i++) {
    printf("%d  ", a[i]);
  }
  printf("\n");
  quicksort(a, (10 - 10), (10 - 1));
  printf("sorted array: ");
  for (i = 0; i < 10; i++) {
    printf("%d  ", a[i]);
  }
  printf("\n");
  clock_t toc = clock();
  printf("elapsed: %f seconds\n", (double)(toc - tic) / CLOCKS_PER_SEC);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x44(%rbp)
lea    0xe98(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0xa,-0x44(%rbp)
jge    11a7 <main+0x67>
movslq -0x44(%rbp),%rax
lea    -0x40(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe91(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1174 <main+0x34>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0xa,-0x44(%rbp)
jge    11ea <main+0xaa>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11bc <main+0x7c>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1040 <quicksort@plt>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0xa,-0x44(%rbp)
jge    124b <main+0x10b>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    121d <main+0xdd>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
sub    -0x10(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2d70(%rip),%rax
divsd  (%rax),%xmm0
lea    0xdca(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r14
lea    0xe96(%rip),%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xea8(%rip),%rbx
mov    %rsp,%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0x24(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0xe21(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rsp),%esi
lea    0xe21(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1050 <quicksort@plt>
lea    0xd7e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <clock@plt>
sub    %r14,%rax
cvtsi2sd %rax,%xmm0
mov    0x2c76(%rip),%rax
divsd  (%rax),%xmm0
lea    0xcd0(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [37 x i8] c"enter the %d numbers to be sorted: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"original array: \00"
@.str.3 = [5 x i8] c"%d \00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [15 x i8] c"sorted array: \00"
@.str.6 = [21 x i8] c"elapsed: %f seconds\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [10 x i32]
%4 = alloca i32
%5 = alloca i64
store i32 0, i32* %1
%6 = call i64 (...) @clock()
store i64 %6, i64* %2
store i32 0, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 10)
br label %8
8: ; preds = %11, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 10
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
br label %8
18: ; preds = %8
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %20
20: ; preds = %29, %18
%21 = load i32, i32* %4
%22 = icmp slt i32 %21, 10
br i1 %22, label %23, label %32
23: ; preds = %20
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %23
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %20
32: ; preds = %20
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%34 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%35 = call i32 @quicksort(i32* %34, i32 0, i32 9)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %4
br label %37
37: ; preds = %46, %32
%38 = load i32, i32* %4
%39 = icmp slt i32 %38, 10
br i1 %39, label %40, label %49
40: ; preds = %37
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %40
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %37
49: ; preds = %37
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%51 = call i64 (...) @clock()
store i64 %51, i64* %5
%52 = load i64, i64* %5
%53 = load i64, i64* %2
%54 = sub nsw i64 %52, %53
%55 = sitofp i64 %54 to double
%56 = load double, double* @CLOCKS_PER_SEC
%57 = fdiv double %55, %56
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), double %57)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"enter the %d numbers to be sorted: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"original array: \00"
@.str.3 = [5 x i8] c"%d \00"
@.str.5 = [15 x i8] c"sorted array: \00"
@.str.6 = [21 x i8] c"elapsed: %f seconds\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main() {
%1 = alloca [10 x i32]
%2 = tail call i64 (...) @clock()
%3 = bitcast [10 x i32]* %1 to i8*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 10)
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %11)
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %13)
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %15)
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %19)
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %21)
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* %5
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %7
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %9
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %11
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %13
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %15
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %17
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %19
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %21
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %23
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %44)
%46 = call i32 @putchar(i32 10)
%47 = call i32 @quicksort(i32* %5, i32 0, i32 9)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%49 = load i32, i32* %5
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %7
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %51)
%53 = load i32, i32* %9
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %53)
%55 = load i32, i32* %11
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %55)
%57 = load i32, i32* %13
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %57)
%59 = load i32, i32* %15
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %59)
%61 = load i32, i32* %17
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %19
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %63)
%65 = load i32, i32* %21
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %65)
%67 = load i32, i32* %23
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %67)
%69 = call i32 @putchar(i32 10)
%70 = call i64 (...) @clock()
%71 = sub nsw i64 %70, %2
%72 = sitofp i64 %71 to double
%73 = load double, double* @CLOCKS_PER_SEC
%74 = fdiv double %72, %73
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), double %74)
ret i32 0
}