#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*/ circularMeanLength(int, int, int, double *, double *);
scalar_t__ pow(double, int);
void linearVariance(int n, int p, int j, double *data, double *var) {
  double temp;
  double mu;
  circularMeanLength(n, p, j, data, &mu);
  int i;
  temp = 0.0;
  for (i = 0; i < n; i++) {
    temp += pow(data[i * p + j] - mu, 2);
  }
  *var = temp / (n - 1);
}


x86 assembly (clang, -O0):
<linearVariance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1040 <circularMeanLength@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ac <linearVariance+0x8c>
mov    -0x18(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0xc(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x30(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    115e <linearVariance+0x3e>
movsd  -0x28(%rbp),%xmm0
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linearVariance>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8,%r15
mov    %rcx,%r12
mov    %edx,%r14d
mov    %esi,%ebx
mov    %edi,%ebp
lea    0x8(%rsp),%r8
call   1040 <circularMeanLength@plt>
test   %ebp,%ebp
jle    117a <linearVariance+0x5a>
mov    %r15,0x30(%rsp)
movslq %ebx,%r15
movslq %r14d,%rbx
mov    %ebp,%eax
mov    %ebp,0x14(%rsp)
cmp    $0x1,%ebp
mov    %r12,0x20(%rsp)
mov    %r15,0x18(%rsp)
mov    %rax,0x28(%rsp)
jne    1183 <linearVariance+0x63>
xorpd  %xmm1,%xmm1
xor    %r14d,%r14d
jmp    11fc <linearVariance+0xdc>
xorpd  %xmm1,%xmm1
jmp    1246 <linearVariance+0x126>
mov    %eax,%ebp
and    $0xfffffffe,%ebp
lea    (%rbx,%r15,1),%r13
shl    $0x4,%r15
xorpd  %xmm1,%xmm1
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
movsd  %xmm1,(%rsp)
movsd  (%r12,%rbx,8),%xmm0
subsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%r12,%r13,8),%xmm0
subsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
addsd  (%rsp),%xmm1
add    $0x2,%r14
add    %r15,%r12
cmp    %r14,%rbp
jne    11a0 <linearVariance+0x80>
testb  $0x1,0x28(%rsp)
mov    0x30(%rsp),%r15
mov    0x14(%rsp),%ebp
je     1246 <linearVariance+0x126>
imul   0x18(%rsp),%r14
add    %rbx,%r14
mov    0x20(%rsp),%rax
movsd  (%rax,%r14,8),%xmm0
subsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
movsd  %xmm1,(%rsp)
call   1030 <pow@plt>
movsd  (%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  %xmm0,%xmm1
add    $0xffffffff,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r15)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @linearVariance(i32 %0, i32 %1, i32 %2, double* %3, double* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca double
%12 = alloca double
%13 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store double* %3, double** %9
store double* %4, double** %10
%14 = load i32, i32* %6
%15 = load i32, i32* %7
%16 = load i32, i32* %8
%17 = load double*, double** %9
%18 = call i32 @circularMeanLength(i32 %14, i32 %15, i32 %16, double* %17, double* %12)
store double 0.000000e+00, double* %11
store i32 0, i32* %13
br label %19
19: ; preds = %39, %5
%20 = load i32, i32* %13
%21 = load i32, i32* %6
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %42
23: ; preds = %19
%24 = load double*, double** %9
%25 = load i32, i32* %13
%26 = load i32, i32* %7
%27 = mul nsw i32 %25, %26
%28 = load i32, i32* %8
%29 = add nsw i32 %27, %28
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %24, i64 %30
%32 = load double, double* %31
%33 = load double, double* %12
%34 = fsub double %32, %33
%35 = call i64 @pow(double %34, i32 2)
%36 = sitofp i64 %35 to double
%37 = load double, double* %11
%38 = fadd double %37, %36
store double %38, double* %11
br label %39
39: ; preds = %23
%40 = load i32, i32* %13
%41 = add nsw i32 %40, 1
store i32 %41, i32* %13
br label %19
42: ; preds = %19
%43 = load double, double* %11
%44 = load i32, i32* %6
%45 = sub nsw i32 %44, 1
%46 = sitofp i32 %45 to double
%47 = fdiv double %43, %46
%48 = load double*, double** %10
store double %47, double* %48
ret void
}

LLVM IR (-O2):
define void @linearVariance(i32 %0, i32 %1, i32 %2, double* %3, double* nocapture writeonly %4) {
%6 = alloca double
%7 = bitcast double* %6 to i8*
%8 = call i32 @circularMeanLength(i32 %0, i32 %1, i32 %2, double* %3, double* %6)
%9 = icmp sgt i32 %0, 0
br i1 %9, label %10, label %59
10: ; preds = %5
%11 = sext i32 %1 to i64
%12 = sext i32 %2 to i64
%13 = zext i32 %0 to i64
%14 = and i64 %13, 1
%15 = icmp eq i32 %0, 1
br i1 %15, label %44, label %16
16: ; preds = %10
%17 = and i64 %13, 4294967294
br label %18
18: ; preds = %18, %16
%19 = phi i64 [ 0, %16 ], [ %41, %18 ]
%20 = phi double [ 0.000000e+00, %16 ], [ %40, %18 ]
%21 = phi i64 [ 0, %16 ], [ %42, %18 ]
%22 = mul nsw i64 %19, %11
%23 = add nsw i64 %22, %12
%24 = getelementptr inbounds double, double* %3, i64 %23
%25 = load double, double* %24
%26 = load double, double* %6
%27 = fsub double %25, %26
%28 = call i64 @pow(double %27, i32 2)
%29 = sitofp i64 %28 to double
%30 = fadd double %20, %29
%31 = or i64 %19, 1
%32 = mul nsw i64 %31, %11
%33 = add nsw i64 %32, %12
%34 = getelementptr inbounds double, double* %3, i64 %33
%35 = load double, double* %34
%36 = load double, double* %6
%37 = fsub double %35, %36
%38 = call i64 @pow(double %37, i32 2)
%39 = sitofp i64 %38 to double
%40 = fadd double %30, %39
%41 = add nuw nsw i64 %19, 2
%42 = add i64 %21, 2
%43 = icmp eq i64 %42, %17
br i1 %43, label %44, label %18
44: ; preds = %18, %10
%45 = phi double [ undef, %10 ], [ %40, %18 ]
%46 = phi i64 [ 0, %10 ], [ %41, %18 ]
%47 = phi double [ 0.000000e+00, %10 ], [ %40, %18 ]
%48 = icmp eq i64 %14, 0
br i1 %48, label %59, label %49
49: ; preds = %44
%50 = mul nsw i64 %46, %11
%51 = add nsw i64 %50, %12
%52 = getelementptr inbounds double, double* %3, i64 %51
%53 = load double, double* %52
%54 = load double, double* %6
%55 = fsub double %53, %54
%56 = call i64 @pow(double %55, i32 2)
%57 = sitofp i64 %56 to double
%58 = fadd double %47, %57
br label %59
59: ; preds = %49, %44, %5
%60 = phi double [ 0.000000e+00, %5 ], [ %45, %44 ], [ %58, %49 ]
%61 = add nsw i32 %0, -1
%62 = sitofp i32 %61 to double
%63 = fdiv double %60, %62
store double %63, double* %4
ret void
}