#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);
int /*<<< orphan*/ free(double *);
double *malloc(int);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ scanf(char *, ...);
int main(int argc, char *argv[]) {
  int nthreads, size;
  double *array;
  int i;
  double t;
  scanf("%d %d", &nthreads, &size);
  array = malloc(size * sizeof(double));
  for (i = 0; i < size; i++) {
    scanf("%lf", &array[i]);
  }
  t = count_sort_parallel(array, size, nthreads);
  printf("%f\n", t);
  free(array);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1070 <scanf@plt>
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11cd <main+0x7d>
mov    -0x20(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1196 <main+0x46>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <count_sort_parallel@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xe1d(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe9c(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x8(%rsp),%r12d
lea    0x0(,%r12,8),%edi
call   1060 <malloc@plt>
mov    %rax,%r14
test   %r12d,%r12d
jle    11bf <main+0x6f>
lea    0xe70(%rip),%r15
mov    %r14,%r13
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%r12
add    $0x8,%r13
cmp    %r12,%rbx
jl     11a0 <main+0x50>
mov    0xc(%rsp),%edx
mov    %r14,%rdi
mov    %r12d,%esi
call   1040 <count_sort_parallel@plt>
lea    0xe35(%rip),%rdi
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [4 x i8] c"%f\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 ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%8 = load i32, i32* %4
%9 = shl i32 %8, 3
%10 = call double* @malloc(i32 %9)
%11 = icmp sgt i32 %8, 0
br i1 %11, label %12, label %20
12: ; preds = %2, %12
%13 = phi i64 [ %16, %12 ], [ 0, %2 ]
%14 = getelementptr inbounds double, double* %10, i64 %13
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %14)
%16 = add nuw nsw i64 %13, 1
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %12, label %20
20: ; preds = %12, %2
%21 = phi i32 [ %8, %2 ], [ %17, %12 ]
%22 = load i32, i32* %3
%23 = call double @count_sort_parallel(double* %10, i32 %21, i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %23)
%25 = call i32 @free(double* %10)
ret i32 0
}