#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_parallel(double *, int, int);
scalar_t__ malloc(int);
double omp_get_wtime();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(int argc, char *argv[]) {
  int i, len, n_threads;
  scanf("%d", &n_threads);
  scanf("%d", &len);
  double *sequence = (double *)malloc(len * sizeof(double)), *sorted;
  for (i = 0; i < len; i++)
    scanf("%lf", &sequence[i]);
  double time_elapsed = omp_get_wtime();
  sorted = count_sort_parallel(sequence, len, n_threads);
  time_elapsed = omp_get_wtime() - time_elapsed;
  for (i = 0; i < len; i++)
    printf("%.2lf ", sorted[i]);
  printf("\n");
  printf("%lf\n", time_elapsed);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xe81(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11db <main+0x8b>
mov    -0x28(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a4 <main+0x54>
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <count_sort_parallel@plt>
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1247 <main+0xf7>
mov    -0x30(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xdd5(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1212 <main+0xc2>
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x38(%rbp),%xmm0
lea    0xdad(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe8e(%rip),%rbx
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0xc(%rsp),%edi
shl    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
cmpl   $0x0,0xc(%rsp)
jle    11df <main+0x7f>
lea    0xe56(%rip),%r15
mov    %r14,%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x8,%r12
cmp    %rax,%rbx
jl     11c0 <main+0x60>
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,0x20(%rsp)
mov    0xc(%rsp),%esi
mov    0x1c(%rsp),%edx
mov    %r14,%rdi
call   1050 <count_sort_parallel@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,0x10(%rsp)
cmpl   $0x0,0xc(%rsp)
jle    123e <main+0xde>
xor    %ebx,%ebx
lea    0xdeb(%rip),%r14
nopl   0x0(%rax)
movsd  (%r15,%rbx,8),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1220 <main+0xc0>
movsd  0x10(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdad(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [7 x i8] c"%.2lf \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [5 x i8] c"%lf\0A\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 double*
%10 = alloca double*
%11 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 8
%17 = trunc i64 %16 to i32
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to double*
store double* %19, double** %9
store i32 0, i32* %6
br label %20
20: ; preds = %30, %2
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %33
24: ; preds = %20
%25 = load double*, double** %9
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %28)
br label %30
30: ; preds = %24
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %20
33: ; preds = %20
%34 = call double (...) @omp_get_wtime()
store double %34, double* %11
%35 = load double*, double** %9
%36 = load i32, i32* %7
%37 = load i32, i32* %8
%38 = call double* @count_sort_parallel(double* %35, i32 %36, i32 %37)
store double* %38, double** %10
%39 = call double (...) @omp_get_wtime()
%40 = load double, double* %11
%41 = fsub double %39, %40
store double %41, double* %11
store i32 0, i32* %6
br label %42
42: ; preds = %53, %33
%43 = load i32, i32* %6
%44 = load i32, i32* %7
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %56
46: ; preds = %42
%47 = load double*, double** %10
%48 = load i32, i32* %6
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
%51 = load double, double* %50
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %51)
br label %53
53: ; preds = %46
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 1
store i32 %55, i32* %6
br label %42
56: ; preds = %42
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%58 = load double, double* %11
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %58)
ret i32 0
}

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