#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 */
double count_sort_serial(double *, int);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  double v[20001];
  int nthreads, n;
  int i;
  scanf(" %d %d", &nthreads, &n);
  for (i = 0; i < n; i++) {
    scanf(" %lf", &v[i]);
  }
  double time = count_sort_serial(v, n);
  for (i = 0; i < n; i++) {
    printf(" %.2lf", v[i]);
  }
  printf("\n%lf\n", time);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x27130,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x27114(%rbp),%rsi
lea    -0x27118(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x2711c(%rbp)
mov    -0x2711c(%rbp),%eax
cmp    -0x27118(%rbp),%eax
jge    11b1 <main+0x81>
movslq -0x2711c(%rbp),%rax
lea    -0x27110(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x2711c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2711c(%rbp)
jmp    1168 <main+0x38>
lea    -0x27110(%rbp),%rdi
mov    -0x27118(%rbp),%esi
call   1030 <count_sort_serial@plt>
movsd  %xmm0,-0x27128(%rbp)
ff
movl   $0x0,-0x2711c(%rbp)
mov    -0x2711c(%rbp),%eax
cmp    -0x27118(%rbp),%eax
jge    1217 <main+0xe7>
movslq -0x2711c(%rbp),%rax
movsd  -0x27110(%rbp,%rax,8),%xmm0
fd ff
lea    0xe0e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x2711c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2711c(%rbp)
jmp    11d5 <main+0xa5>
movsd  -0x27128(%rbp),%xmm0
ff
lea    0xded(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x27130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x27130,%rsp
lea    0xebd(%rip),%rdi
lea    0x1c(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    118f <main+0x5f>
lea    0x20(%rsp),%r15
lea    0xe9f(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rsi
add    $0x8,%r15
cmp    %rsi,%rbx
jl     1170 <main+0x40>
lea    0x20(%rsp),%rdi
call   1030 <count_sort_serial@plt>
movsd  %xmm0,0x10(%rsp)
cmpl   $0x0,0xc(%rsp)
jle    11cc <main+0x9c>
xor    %ebx,%ebx
lea    0xe5d(%rip),%r14
nop
movsd  0x20(%rsp,%rbx,8),%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11b0 <main+0x80>
lea    0xe40(%rip),%rdi
movsd  0x10(%rsp),%xmm0
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x27130,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c" %d %d\00"
@.str.1 = [5 x i8] c" %lf\00"
@.str.2 = [7 x i8] c" %.2lf\00"
@.str.3 = [6 x i8] c"\0A%lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20001 x double]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
store i32 0, i32* %5
br label %8
8: ; preds = %17, %0
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [20001 x double], [20001 x double]* %2, i64 0, i64 %14
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %15)
br label %17
17: ; preds = %12
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
br label %8
20: ; preds = %8
%21 = getelementptr inbounds [20001 x double], [20001 x double]* %2, i64 0, i64 0
%22 = load i32, i32* %4
%23 = call double @count_sort_serial(double* %21, i32 %22)
store double %23, double* %6
store i32 0, i32* %5
br label %24
24: ; preds = %34, %20
%25 = load i32, i32* %5
%26 = load i32, i32* %4
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [20001 x double], [20001 x double]* %2, i64 0, i64 %30
%32 = load double, double* %31
%33 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %32)
br label %34
34: ; preds = %28
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %24
37: ; preds = %24
%38 = load double, double* %6
%39 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c" %d %d\00"
@.str.1 = [5 x i8] c" %lf\00"
@.str.2 = [7 x i8] c" %.2lf\00"
@.str.3 = [6 x i8] c"\0A%lf\0A\00"
define i32 @main() {
%1 = alloca [20001 x double]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [20001 x double]* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %0, %10
%11 = phi i64 [ %14, %10 ], [ 0, %0 ]
%12 = getelementptr inbounds [20001 x double], [20001 x double]* %1, i64 0, i64 %11
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %12)
%14 = add nuw nsw i64 %11, 1
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = icmp slt i64 %14, %16
br i1 %17, label %10, label %18
18: ; preds = %10, %0
%19 = phi i32 [ %8, %0 ], [ %15, %10 ]
%20 = getelementptr inbounds [20001 x double], [20001 x double]* %1, i64 0, i64 0
%21 = call double @count_sort_serial(double* %20, i32 %19)
%22 = load i32, i32* %3
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %33
24: ; preds = %18, %24
%25 = phi i64 [ %29, %24 ], [ 0, %18 ]
%26 = getelementptr inbounds [20001 x double], [20001 x double]* %1, i64 0, i64 %25
%27 = load double, double* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %27)
%29 = add nuw nsw i64 %25, 1
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = icmp slt i64 %29, %31
br i1 %32, label %24, label %33
33: ; preds = %24, %18
%34 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double %21)
ret i32 0
}