#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*/ doubleSort(int, double *);
int /*<<< orphan*/ errAbort(char *, int);
int /*<<< orphan*/ verbose(int, char *, int, int, int);
void doubleBoxWhiskerCalc(int count, double *array, double *retMin,
                          double *retQ1, double *retMedian, double *retQ3,
                          double *retMax) {
  if (count <= 0)
    errAbort("doubleBoxWhiskerCalc needs a positive number, not %d for count",
             count);
  if (count == 1) {
    *retMin = *retQ1 = *retMedian = *retQ3 = *retMax = array[0];
    return;
  }
  doubleSort(count, array);
  double min = array[0];
  double max = array[count - 1];
  double median;
  int halfCount = count >> 1;
  if ((count & 1) == 1)
    median = array[halfCount];
  else {
    median = (array[halfCount] + array[halfCount - 1]) * 0.5;
  }
  double q1, q3;
  if (count <= 3) {
    q1 = 0.5 * (median + min);
    q3 = 0.5 * (median + max);
  } else {
    int q1Ix = count / 4;
    int q3Ix = count - 1 - q1Ix;
    verbose(4, "count %d, q1Ix %d, q3Ix %d\n", count, q1Ix, q3Ix);
    q1 = array[q1Ix];
    q3 = array[q3Ix];
  }
  *retMin = min;
  *retQ1 = q1;
  *retMedian = median;
  *retQ3 = q3;
  *retMax = max;
}


x86 assembly (clang, -O0):
<doubleBoxWhiskerCalc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     116c <doubleBoxWhiskerCalc+0x3c>
mov    -0x4(%rbp),%esi
lea    0xea1(%rip),%rdi
call   1030 <errAbort@plt>
cmpl   $0x1,-0x4(%rbp)
jne    11ab <doubleBoxWhiskerCalc+0x7b>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1319 <doubleBoxWhiskerCalc+0x1e9>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <doubleSort@plt>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x1,%eax
jne    120a <doubleBoxWhiskerCalc+0xda>
mov    -0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    123a <doubleBoxWhiskerCalc+0x10a>
mov    -0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  0xdcf(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
cmpl   $0x3,-0x4(%rbp)
jg     127f <doubleBoxWhiskerCalc+0x14f>
movsd  -0x48(%rbp),%xmm1
addsd  -0x38(%rbp),%xmm1
movsd  0xdaa(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm1
addsd  -0x40(%rbp),%xmm1
movsd  0xd8f(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    12d8 <doubleBoxWhiskerCalc+0x1a8>
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x64(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
sub    -0x64(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x4(%rbp),%edx
mov    -0x64(%rbp),%ecx
mov    -0x68(%rbp),%r8d
mov    $0x4,%edi
lea    0xd98(%rip),%rsi
call   1050 <verbose@plt>
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x60(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
mov    0x10(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doubleBoxWhiskerCalc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %edi,%ebp
test   %edi,%edi
jle    1180 <doubleBoxWhiskerCalc+0x50>
cmp    $0x1,%ebp
jne    118e <doubleBoxWhiskerCalc+0x5e>
movsd  (%rbx),%xmm0
mov    0x60(%rsp),%rax
movsd  %xmm0,(%rax)
movsd  %xmm0,(%r14)
movsd  %xmm0,(%r15)
movsd  %xmm0,(%r12)
movsd  %xmm0,0x0(%r13)
jmp    1276 <doubleBoxWhiskerCalc+0x146>
lea    0xe81(%rip),%rdi
mov    %ebp,%esi
call   1030 <errAbort@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <doubleSort@plt>
movslq %ebp,%rax
mov    %ebp,%ecx
sar    %ecx
movslq %ecx,%rcx
movsd  (%rbx,%rcx,8),%xmm3
test   $0x1,%bpl
jne    11bb <doubleBoxWhiskerCalc+0x8b>
addsd  -0x8(%rbx,%rcx,8),%xmm3
mulsd  0xe45(%rip),%xmm3
movsd  (%rbx),%xmm5
movsd  -0x8(%rbx,%rax,8),%xmm4
cmp    $0x3,%ebp
jg     11ec <doubleBoxWhiskerCalc+0xbc>
movapd %xmm5,%xmm0
addsd  %xmm3,%xmm0
movsd  0xe26(%rip),%xmm2
mulsd  %xmm2,%xmm0
movapd %xmm4,%xmm1
addsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm1
jmp    1257 <doubleBoxWhiskerCalc+0x127>
mov    %r14,0x20(%rsp)
lea    -0x1(%rbp),%r14d
mov    %r15,0x18(%rsp)
mov    %ebp,%r15d
shr    $0x2,%r15d
sub    %r15d,%r14d
lea    0xe3c(%rip),%rsi
mov    $0x4,%edi
mov    %ebp,%edx
mov    %r15d,%ecx
mov    %r14d,%r8d
movsd  %xmm3,0x10(%rsp)
movsd  %xmm4,0x8(%rsp)
movsd  %xmm5,(%rsp)
call   1050 <verbose@plt>
movsd  (%rsp),%xmm5
movsd  0x8(%rsp),%xmm4
movsd  0x10(%rsp),%xmm3
movsd  (%rbx,%r15,8),%xmm0
mov    0x18(%rsp),%r15
movslq %r14d,%rax
mov    0x20(%rsp),%r14
movsd  (%rbx,%rax,8),%xmm1
mov    0x60(%rsp),%rax
movsd  %xmm5,0x0(%r13)
movsd  %xmm0,(%r12)
movsd  %xmm3,(%r15)
movsd  %xmm1,(%r14)
movsd  %xmm4,(%rax)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [63 x i8] c"doubleBoxWhiskerCalc needs a positive number, not %d for count\00"
@.str.1 = [28 x i8] c"count %d, q1Ix %d, q3Ix %d\0A\00"
define void @doubleBoxWhiskerCalc(i32 %0, double* %1, double* %2, double* %3, double* %4, double* %5, double* %6) {
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca i32
%19 = alloca double
%20 = alloca double
%21 = alloca i32
%22 = alloca i32
store i32 %0, i32* %8
store double* %1, double** %9
store double* %2, double** %10
store double* %3, double** %11
store double* %4, double** %12
store double* %5, double** %13
store double* %6, double** %14
%23 = load i32, i32* %8
%24 = icmp sle i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %7
%26 = load i32, i32* %8
%27 = call i32 @errAbort(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %25, %7
%29 = load i32, i32* %8
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %40
31: ; preds = %28
%32 = load double*, double** %9
%33 = getelementptr inbounds double, double* %32, i64 0
%34 = load double, double* %33
%35 = load double*, double** %14
store double %34, double* %35
%36 = load double*, double** %13
store double %34, double* %36
%37 = load double*, double** %12
store double %34, double* %37
%38 = load double*, double** %11
store double %34, double* %38
%39 = load double*, double** %10
store double %34, double* %39
br label %122
40: ; preds = %28
%41 = load i32, i32* %8
%42 = load double*, double** %9
%43 = call i32 @doubleSort(i32 %41, double* %42)
%44 = load double*, double** %9
%45 = getelementptr inbounds double, double* %44, i64 0
%46 = load double, double* %45
store double %46, double* %15
%47 = load double*, double** %9
%48 = load i32, i32* %8
%49 = sub nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %47, i64 %50
%52 = load double, double* %51
store double %52, double* %16
%53 = load i32, i32* %8
%54 = ashr i32 %53, 1
store i32 %54, i32* %18
%55 = load i32, i32* %8
%56 = and i32 %55, 1
%57 = icmp eq i32 %56, 1
br i1 %57, label %58, label %64
58: ; preds = %40
%59 = load double*, double** %9
%60 = load i32, i32* %18
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %59, i64 %61
%63 = load double, double* %62
store double %63, double* %17
br label %78
64: ; preds = %40
%65 = load double*, double** %9
%66 = load i32, i32* %18
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %65, i64 %67
%69 = load double, double* %68
%70 = load double*, double** %9
%71 = load i32, i32* %18
%72 = sub nsw i32 %71, 1
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %70, i64 %73
%75 = load double, double* %74
%76 = fadd double %69, %75
%77 = fmul double %76, 5.000000e-01
store double %77, double* %17
br label %78
78: ; preds = %64, %58
%79 = load i32, i32* %8
%80 = icmp sle i32 %79, 3
br i1 %80, label %81, label %90
81: ; preds = %78
%82 = load double, double* %17
%83 = load double, double* %15
%84 = fadd double %82, %83
%85 = fmul double 5.000000e-01, %84
store double %85, double* %19
%86 = load double, double* %17
%87 = load double, double* %16
%88 = fadd double %86, %87
%89 = fmul double 5.000000e-01, %88
store double %89, double* %20
br label %111
90: ; preds = %78
%91 = load i32, i32* %8
%92 = sdiv i32 %91, 4
store i32 %92, i32* %21
%93 = load i32, i32* %8
%94 = sub nsw i32 %93, 1
%95 = load i32, i32* %21
%96 = sub nsw i32 %94, %95
store i32 %96, i32* %22
%97 = load i32, i32* %8
%98 = load i32, i32* %21
%99 = load i32, i32* %22
%100 = call i32 @verbose(i32 4, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %97, i32 %98, i32 %99)
%101 = load double*, double** %9
%102 = load i32, i32* %21
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds double, double* %101, i64 %103
%105 = load double, double* %104
store double %105, double* %19
%106 = load double*, double** %9
%107 = load i32, i32* %22
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds double, double* %106, i64 %108
%110 = load double, double* %109
store double %110, double* %20
br label %111
111: ; preds = %90, %81
%112 = load double, double* %15
%113 = load double*, double** %10
store double %112, double* %113
%114 = load double, double* %19
%115 = load double*, double** %11
store double %114, double* %115
%116 = load double, double* %17
%117 = load double*, double** %12
store double %116, double* %117
%118 = load double, double* %20
%119 = load double*, double** %13
store double %118, double* %119
%120 = load double, double* %16
%121 = load double*, double** %14
store double %120, double* %121
br label %122
122: ; preds = %111, %31
ret void
}

LLVM IR (-O2):
@.str = [63 x i8] c"doubleBoxWhiskerCalc needs a positive number, not %d for count\00"
@.str.1 = [28 x i8] c"count %d, q1Ix %d, q3Ix %d\0A\00"
define void @doubleBoxWhiskerCalc(i32 %0, double* %1, double* nocapture writeonly %2, double* nocapture writeonly %3, double* nocapture writeonly %4, double* nocapture writeonly %5, double* nocapture writeonly %6) {
%8 = icmp slt i32 %0, 1
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 @errAbort(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %15
11: ; preds = %7
%12 = icmp eq i32 %0, 1
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = load double, double* %1
store double %14, double* %6
store double %14, double* %5
store double %14, double* %4
store double %14, double* %3
store double %14, double* %2
br label %56
15: ; preds = %9, %11
%16 = tail call i32 @doubleSort(i32 %0, double* %1)
%17 = load double, double* %1
%18 = add nsw i32 %0, -1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %1, i64 %19
%21 = load double, double* %20
%22 = ashr i32 %0, 1
%23 = and i32 %0, 1
%24 = icmp eq i32 %23, 0
%25 = sext i32 %22 to i64
%26 = getelementptr inbounds double, double* %1, i64 %25
%27 = load double, double* %26
br i1 %24, label %28, label %35
28: ; preds = %15
%29 = add nsw i32 %22, -1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %1, i64 %30
%32 = load double, double* %31
%33 = fadd double %27, %32
%34 = fmul double %33, 5.000000e-01
br label %35
35: ; preds = %15, %28
%36 = phi double [ %34, %28 ], [ %27, %15 ]
%37 = icmp slt i32 %0, 4
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = fadd double %17, %36
%40 = fmul double %39, 5.000000e-01
%41 = fadd double %21, %36
%42 = fmul double %41, 5.000000e-01
br label %53
43: ; preds = %35
%44 = lshr i32 %0, 2
%45 = sub nsw i32 %18, %44
%46 = tail call i32 @verbose(i32 4, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %44, i32 %45)
%47 = zext i32 %44 to i64
%48 = getelementptr inbounds double, double* %1, i64 %47
%49 = load double, double* %48
%50 = sext i32 %45 to i64
%51 = getelementptr inbounds double, double* %1, i64 %50
%52 = load double, double* %51
br label %53
53: ; preds = %43, %38
%54 = phi double [ %42, %38 ], [ %52, %43 ]
%55 = phi double [ %40, %38 ], [ %49, %43 ]
store double %17, double* %2
store double %55, double* %3
store double %36, double* %4
store double %54, double* %5
store double %21, double* %6
br label %56
56: ; preds = %53, %13
ret void
}