#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 sqrt(double);
void zscore_calc(double *zscore, double *sum, double *sum2, int n, int cur) {
  int i;
  double var;
  for (i = n; i < 2 * n; i++) {
    var = ((sum2[i] - sum[i] * sum[i] / (double)cur) / (double)(cur - 1));
    zscore[(i - n)] = (sum[i]) / (sqrt(var) * (double)cur);
  }
}


x86 assembly (clang, -O0):
<zscore_calc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    11da <zscore_calc+0xca>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
cvtsi2sdl -0x20(%rbp),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
cvtsi2sdl -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1131 <zscore_calc+0x21>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zscore_calc>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    (%rcx,%rcx,1),%eax
cmp    %ecx,%eax
jle    11c4 <zscore_calc+0xb4>
mov    %rdi,%r14
cvtsi2sd %r8d,%xmm2
add    $0xffffffff,%r8d
cvtsi2sd %r8d,%xmm3
movslq %ecx,%rcx
movslq %eax,%r13
lea    (%rdx,%rcx,8),%r15
lea    (%rsi,%rcx,8),%r12
sub    %rcx,%r13
xor    %ebx,%ebx
xorpd  %xmm4,%xmm4
movsd  %xmm2,0x10(%rsp)
movsd  %xmm3,0x8(%rsp)
jmp    1198 <zscore_calc+0x88>
xchg   %ax,%ax
movsd  %xmm5,0x18(%rsp)
call   1030 <sqrt@plt>
movsd  0x18(%rsp),%xmm5
xorpd  %xmm4,%xmm4
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm0
divsd  %xmm0,%xmm5
movsd  %xmm5,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
je     11c4 <zscore_calc+0xb4>
movsd  (%r15,%rbx,8),%xmm0
movsd  (%r12,%rbx,8),%xmm5
movapd %xmm5,%xmm1
mulsd  %xmm5,%xmm1
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
divsd  %xmm3,%xmm0
ucomisd %xmm4,%xmm0
jb     1160 <zscore_calc+0x50>
sqrtsd %xmm0,%xmm0
jmp    1181 <zscore_calc+0x71>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @zscore_calc(double* %0, double* %1, double* %2, i32 %3, i32 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%13 = load i32, i32* %9
store i32 %13, i32* %11
br label %14
14: ; preds = %61, %5
%15 = load i32, i32* %11
%16 = load i32, i32* %9
%17 = mul nsw i32 2, %16
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %64
19: ; preds = %14
%20 = load double*, double** %8
%21 = load i32, i32* %11
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = load double*, double** %7
%26 = load i32, i32* %11
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = load double*, double** %7
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
%34 = load double, double* %33
%35 = fmul double %29, %34
%36 = load i32, i32* %10
%37 = sitofp i32 %36 to double
%38 = fdiv double %35, %37
%39 = fsub double %24, %38
%40 = load i32, i32* %10
%41 = sub nsw i32 %40, 1
%42 = sitofp i32 %41 to double
%43 = fdiv double %39, %42
store double %43, double* %12
%44 = load double*, double** %7
%45 = load i32, i32* %11
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
%48 = load double, double* %47
%49 = load double, double* %12
%50 = call double @sqrt(double %49)
%51 = load i32, i32* %10
%52 = sitofp i32 %51 to double
%53 = fmul double %50, %52
%54 = fdiv double %48, %53
%55 = load double*, double** %6
%56 = load i32, i32* %11
%57 = load i32, i32* %9
%58 = sub nsw i32 %56, %57
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %55, i64 %59
store double %54, double* %60
br label %61
61: ; preds = %19
%62 = load i32, i32* %11
%63 = add nsw i32 %62, 1
store i32 %63, i32* %11
br label %14
64: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @zscore_calc(double* nocapture writeonly %0, double* nocapture %1, double* nocapture %2, i32 %3, i32 %4) {
%6 = shl i32 %3, 1
%7 = icmp sgt i32 %6, %3
br i1 %7, label %8, label %31
8: ; preds = %5
%9 = sitofp i32 %4 to double
%10 = add nsw i32 %4, -1
%11 = sitofp i32 %10 to double
%12 = sext i32 %3 to i64
%13 = sext i32 %6 to i64
br label %14
14: ; preds = %8, %14
%15 = phi i64 [ %12, %8 ], [ %29, %14 ]
%16 = getelementptr inbounds double, double* %2, i64 %15
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %1, i64 %15
%19 = load double, double* %18
%20 = fmul double %19, %19
%21 = fdiv double %20, %9
%22 = fsub double %17, %21
%23 = fdiv double %22, %11
%24 = tail call double @sqrt(double %23)
%25 = fmul double %24, %9
%26 = fdiv double %19, %25
%27 = sub nsw i64 %15, %12
%28 = getelementptr inbounds double, double* %0, i64 %27
store double %26, double* %28
%29 = add nsw i64 %15, 1
%30 = icmp eq i64 %29, %13
br i1 %30, label %31, label %14
31: ; preds = %14, %5
ret void
}