#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 */
scalar_t__ fabs(double);
double sqrt(double);
double *geary_test(double *x, int n) {
  int i;
  static double y[2];
  double diff, s = 0.0, mean = 0.0;
  y[0] = 0.0;
  for (i = 0; i < n; ++i)
    mean += x[i];
  mean /= n;
  for (i = 0; i < n; ++i) {
    diff = x[i] - mean;
    y[0] += fabs(diff);
    s += diff * diff;
  }
  s *= n;
  y[0] /= sqrt(s);
  y[1] = (y[0] - 0.7979) * sqrt((double)n) / 0.2123;
  return y;
}


x86 assembly (clang, -O0):
<geary_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,0x2ef6(%rip)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1182 <geary_test+0x62>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1151 <geary_test+0x31>
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1208 <geary_test+0xe8>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %rax,%xmm0
addsd  0x2e6a(%rip),%xmm0
movsd  %xmm0,0x2e62(%rip)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119c <geary_test+0x7c>
cvtsi2sdl -0xc(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0x2e14(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x2e08(%rip)
movsd  0x2e00(%rip),%xmm0
movsd  0xdc0(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd91(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x2dcd(%rip)
lea    0x2dbe(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geary_test>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movq   $0x0,0x2f0a(%rip)
test   %esi,%esi
jle    1158 <geary_test+0x38>
mov    %rdi,%r15
mov    %esi,%r14d
lea    -0x1(%r14),%rax
mov    %r14d,%ecx
and    $0x7,%ecx
cmp    $0x7,%rax
jae    1165 <geary_test+0x45>
xorpd  %xmm2,%xmm2
xor    %edx,%edx
jmp    11c0 <geary_test+0xa0>
cvtsi2sd %esi,%xmm1
xorpd  %xmm0,%xmm0
jmp    132f <geary_test+0x20f>
mov    %r14d,%edi
and    $0xfffffff8,%edi
xorpd  %xmm2,%xmm2
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
addsd  (%r15,%rdx,8),%xmm2
addsd  0x8(%r15,%rdx,8),%xmm2
addsd  0x10(%r15,%rdx,8),%xmm2
addsd  0x18(%r15,%rdx,8),%xmm2
addsd  0x20(%r15,%rdx,8),%xmm2
addsd  0x28(%r15,%rdx,8),%xmm2
addsd  0x30(%r15,%rdx,8),%xmm2
addsd  0x38(%r15,%rdx,8),%xmm2
add    $0x8,%rdx
cmp    %rdx,%rdi
jne    1180 <geary_test+0x60>
test   %rcx,%rcx
je     11de <geary_test+0xbe>
lea    (%r15,%rdx,8),%rdx
xor    %edi,%edi
nopl   0x0(%rax,%rax,1)
addsd  (%rdx,%rdi,8),%xmm2
add    $0x1,%rdi
cmp    %rdi,%rcx
jne    11d0 <geary_test+0xb0>
cvtsi2sd %esi,%xmm1
test   %esi,%esi
jle    12d0 <geary_test+0x1b0>
movsd  %xmm1,0x18(%rsp)
divsd  %xmm1,%xmm2
test   %rax,%rax
je     12d6 <geary_test+0x1b6>
mov    %r14d,%r12d
and    $0xfffffffe,%r12d
xorpd  %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
xor    %ebx,%ebx
movsd  %xmm2,0x20(%rsp)
cs nopw 0x0(%rax,%rax,1)
movsd  (%r15,%rbx,8),%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%rsp)
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x2dfb(%rip),%xmm0
movsd  %xmm0,0x2df3(%rip)
movsd  0x10(%rsp),%xmm0
mulsd  %xmm0,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%r15,%rbx,8),%xmm0
subsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x2db5(%rip),%xmm0
movsd  %xmm0,0x2dad(%rip)
movsd  0x20(%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
add    $0x2,%rbx
cmp    %rbx,%r12
jne    1220 <geary_test+0x100>
test   $0x1,%r14b
jne    12e8 <geary_test+0x1c8>
movsd  0x18(%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
jmp    132f <geary_test+0x20f>
xorpd  %xmm0,%xmm0
jmp    132f <geary_test+0x20f>
xorpd  %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
xor    %ebx,%ebx
test   $0x1,%r14b
je     12c2 <geary_test+0x1a2>
movsd  (%r15,%rbx,8),%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%rsp)
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x2d33(%rip),%xmm0
movsd  %xmm0,0x2d2b(%rip)
movsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  %xmm1,%xmm0
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
jb     1343 <geary_test+0x223>
sqrtsd %xmm0,%xmm0
jmp    1358 <geary_test+0x238>
movsd  %xmm1,0x18(%rsp)
call   1040 <sqrt@plt>
xorpd  %xmm3,%xmm3
movsd  0x18(%rsp),%xmm1
movsd  0x2ce0(%rip),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x2cd4(%rip)
addsd  0xc8c(%rip),%xmm2
ucomisd %xmm3,%xmm1
jb     1383 <geary_test+0x263>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    1398 <geary_test+0x278>
movapd %xmm1,%xmm0
movsd  %xmm2,0x8(%rsp)
call   1040 <sqrt@plt>
movsd  0x8(%rsp),%xmm2
mulsd  %xmm0,%xmm2
divsd  0xc64(%rip),%xmm2
movsd  %xmm2,0x2c9c(%rip)
lea    0x2c8d(%rip),%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@geary_test.y = internal global [2 x double] zeroinitializer
define double* @geary_test(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double* %0, double** %3
store i32 %1, i32* %4
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
store double 0.000000e+00, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
store i32 0, i32* %5
br label %9
9: ; preds = %21, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = load double*, double** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %14, i64 %16
%18 = load double, double* %17
%19 = load double, double* %8
%20 = fadd double %19, %18
store double %20, double* %8
br label %21
21: ; preds = %13
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %9
24: ; preds = %9
%25 = load i32, i32* %4
%26 = sitofp i32 %25 to double
%27 = load double, double* %8
%28 = fdiv double %27, %26
store double %28, double* %8
store i32 0, i32* %5
br label %29
29: ; preds = %50, %24
%30 = load i32, i32* %5
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %53
33: ; preds = %29
%34 = load double*, double** %3
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = load double, double* %8
%40 = fsub double %38, %39
store double %40, double* %6
%41 = load double, double* %6
%42 = call i64 @fabs(double %41)
%43 = sitofp i64 %42 to double
%44 = load double, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
%45 = fadd double %44, %43
store double %45, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
%46 = load double, double* %6
%47 = load double, double* %6
%48 = load double, double* %7
%49 = call double @llvm.fmuladd.f64(double %46, double %47, double %48)
store double %49, double* %7
br label %50
50: ; preds = %33
%51 = load i32, i32* %5
%52 = add nsw i32 %51, 1
store i32 %52, i32* %5
br label %29
53: ; preds = %29
%54 = load i32, i32* %4
%55 = sitofp i32 %54 to double
%56 = load double, double* %7
%57 = fmul double %56, %55
store double %57, double* %7
%58 = load double, double* %7
%59 = call double @sqrt(double %58)
%60 = load double, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
%61 = fdiv double %60, %59
store double %61, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
%62 = load double, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
%63 = fsub double %62, 7.979000e-01
%64 = load i32, i32* %4
%65 = sitofp i32 %64 to double
%66 = call double @sqrt(double %65)
%67 = fmul double %63, %66
%68 = fdiv double %67, 2.123000e-01
store double %68, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 1)
ret double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
}

LLVM IR (-O2):
@geary_test.y = internal global [2 x double] zeroinitializer
define double* @geary_test(double* nocapture %0, i32 %1) {
store double 0.000000e+00, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
%3 = icmp sgt i32 %1, 0
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = sitofp i32 %1 to double
br label %113
6: ; preds = %2
%7 = zext i32 %1 to i64
%8 = add nsw i64 %7, -1
%9 = and i64 %7, 7
%10 = icmp ult i64 %8, 7
br i1 %10, label %51, label %11
11: ; preds = %6
%12 = and i64 %7, 4294967288
br label %13
13: ; preds = %13, %11
%14 = phi i64 [ 0, %11 ], [ %48, %13 ]
%15 = phi double [ 0.000000e+00, %11 ], [ %47, %13 ]
%16 = phi i64 [ 0, %11 ], [ %49, %13 ]
%17 = getelementptr inbounds double, double* %0, i64 %14
%18 = load double, double* %17
%19 = fadd double %15, %18
%20 = or i64 %14, 1
%21 = getelementptr inbounds double, double* %0, i64 %20
%22 = load double, double* %21
%23 = fadd double %19, %22
%24 = or i64 %14, 2
%25 = getelementptr inbounds double, double* %0, i64 %24
%26 = load double, double* %25
%27 = fadd double %23, %26
%28 = or i64 %14, 3
%29 = getelementptr inbounds double, double* %0, i64 %28
%30 = load double, double* %29
%31 = fadd double %27, %30
%32 = or i64 %14, 4
%33 = getelementptr inbounds double, double* %0, i64 %32
%34 = load double, double* %33
%35 = fadd double %31, %34
%36 = or i64 %14, 5
%37 = getelementptr inbounds double, double* %0, i64 %36
%38 = load double, double* %37
%39 = fadd double %35, %38
%40 = or i64 %14, 6
%41 = getelementptr inbounds double, double* %0, i64 %40
%42 = load double, double* %41
%43 = fadd double %39, %42
%44 = or i64 %14, 7
%45 = getelementptr inbounds double, double* %0, i64 %44
%46 = load double, double* %45
%47 = fadd double %43, %46
%48 = add nuw nsw i64 %14, 8
%49 = add i64 %16, 8
%50 = icmp eq i64 %49, %12
br i1 %50, label %51, label %13
51: ; preds = %13, %6
%52 = phi double [ undef, %6 ], [ %47, %13 ]
%53 = phi i64 [ 0, %6 ], [ %48, %13 ]
%54 = phi double [ 0.000000e+00, %6 ], [ %47, %13 ]
%55 = icmp eq i64 %9, 0
br i1 %55, label %66, label %56
56: ; preds = %51, %56
%57 = phi i64 [ %63, %56 ], [ %53, %51 ]
%58 = phi double [ %62, %56 ], [ %54, %51 ]
%59 = phi i64 [ %64, %56 ], [ 0, %51 ]
%60 = getelementptr inbounds double, double* %0, i64 %57
%61 = load double, double* %60
%62 = fadd double %58, %61
%63 = add nuw nsw i64 %57, 1
%64 = add i64 %59, 1
%65 = icmp eq i64 %64, %9
br i1 %65, label %66, label %56
66: ; preds = %56, %51
%67 = phi double [ %52, %51 ], [ %62, %56 ]
%68 = sitofp i32 %1 to double
%69 = fdiv double %67, %68
br i1 %3, label %70, label %113
70: ; preds = %66
%71 = and i64 %7, 1
%72 = icmp eq i64 %8, 0
br i1 %72, label %99, label %73
73: ; preds = %70
%74 = and i64 %7, 4294967294
br label %75
75: ; preds = %75, %73
%76 = phi i64 [ 0, %73 ], [ %96, %75 ]
%77 = phi double [ 0.000000e+00, %73 ], [ %95, %75 ]
%78 = phi i64 [ 0, %73 ], [ %97, %75 ]
%79 = getelementptr inbounds double, double* %0, i64 %76
%80 = load double, double* %79
%81 = fsub double %80, %69
%82 = tail call i64 @fabs(double %81)
%83 = sitofp i64 %82 to double
%84 = load double, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
%85 = fadd double %84, %83
store double %85, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
%86 = tail call double @llvm.fmuladd.f64(double %81, double %81, double %77)
%87 = or i64 %76, 1
%88 = getelementptr inbounds double, double* %0, i64 %87
%89 = load double, double* %88
%90 = fsub double %89, %69
%91 = tail call i64 @fabs(double %90)
%92 = sitofp i64 %91 to double
%93 = load double, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
%94 = fadd double %93, %92
store double %94, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
%95 = tail call double @llvm.fmuladd.f64(double %90, double %90, double %86)
%96 = add nuw nsw i64 %76, 2
%97 = add i64 %78, 2
%98 = icmp eq i64 %97, %74
br i1 %98, label %99, label %75
99: ; preds = %75, %70
%100 = phi double [ undef, %70 ], [ %95, %75 ]
%101 = phi i64 [ 0, %70 ], [ %96, %75 ]
%102 = phi double [ 0.000000e+00, %70 ], [ %95, %75 ]
%103 = icmp eq i64 %71, 0
br i1 %103, label %113, label %104
104: ; preds = %99
%105 = getelementptr inbounds double, double* %0, i64 %101
%106 = load double, double* %105
%107 = fsub double %106, %69
%108 = tail call i64 @fabs(double %107)
%109 = sitofp i64 %108 to double
%110 = load double, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
%111 = fadd double %110, %109
store double %111, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
%112 = tail call double @llvm.fmuladd.f64(double %107, double %107, double %102)
br label %113
113: ; preds = %104, %99, %4, %66
%114 = phi double [ %68, %66 ], [ %5, %4 ], [ %68, %99 ], [ %68, %104 ]
%115 = phi double [ 0.000000e+00, %66 ], [ 0.000000e+00, %4 ], [ %100, %99 ], [ %112, %104 ]
%116 = fmul double %115, %114
%117 = tail call double @sqrt(double %116)
%118 = load double, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
%119 = fdiv double %118, %117
store double %119, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
%120 = fadd double %119, -7.979000e-01
%121 = tail call double @sqrt(double %114)
%122 = fmul double %120, %121
%123 = fdiv double %122, 2.123000e-01
store double %123, double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 1)
ret double* getelementptr inbounds ([2 x double], [2 x double]* @geary_test.y, i64 0, i64 0)
}