#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 arithmetic(double *, size_t);
double variance(double *x, double *y, size_t n) {
  double xm, ym, s;
  size_t i;
  if (n < 2)
    return 0;
  xm = arithmetic(x, n);
  ym = arithmetic(y, n);
  s = 0.0;
  for (i = 0; i < n; i++)
    s += (x[i] - xm) * (y[i] - ym);
  return s / (n - 1);
}


x86 assembly (clang, -O0):
<variance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x2,-0x20(%rbp)
jae    113c <variance+0x2c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1202 <variance+0xf2>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <arithmetic@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <arithmetic@plt>
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11c5 <variance+0xb5>
mov    -0x10(%rbp),%rax
mov    -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
subsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1170 <variance+0x60>
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
movq   %rax,%xmm1
movaps 0xe22(%rip),%xmm2
punpckldq %xmm2,%xmm1
movapd 0xe26(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<variance>:
xorpd  %xmm0,%xmm0
cmp    $0x2,%rdx
jb     11f4 <variance+0xe4>
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rdx,%rsi
call   1030 <arithmetic@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <arithmetic@plt>
movsd  0x8(%rsp),%xmm5
movapd %xmm0,%xmm1
mov    %r14,%rcx
and    $0xfffffffffffffffe,%rcx
xorpd  %xmm0,%xmm0
xor    %eax,%eax
movsd  (%rbx,%rax,8),%xmm2
movsd  0x8(%rbx,%rax,8),%xmm3
subsd  %xmm5,%xmm2
movsd  (%r15,%rax,8),%xmm4
subsd  %xmm1,%xmm4
mulsd  %xmm2,%xmm4
addsd  %xmm0,%xmm4
movsd  0x8(%r15,%rax,8),%xmm0
subsd  %xmm5,%xmm3
subsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm4,%xmm0
add    $0x2,%rax
cmp    %rax,%rcx
jne    1160 <variance+0x50>
test   $0x1,%r14b
je     11c2 <variance+0xb2>
movsd  (%rbx,%rax,8),%xmm2
subsd  %xmm5,%xmm2
movsd  (%r15,%rax,8),%xmm3
subsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm3,%xmm0
add    $0xffffffffffffffff,%r14
movq   %r14,%xmm1
punpckldq 0xe2d(%rip),%xmm1
subpd  0xe35(%rip),%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
addsd  %xmm1,%xmm2
divsd  %xmm2,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define double @variance(double* %0, double* %1, i64 %2) {
%4 = icmp ult i64 %2, 2
br i1 %4, label %47, label %5
5: ; preds = %3
%6 = tail call double @arithmetic(double* %0, i64 %2)
%7 = tail call double @arithmetic(double* %1, i64 %2)
%8 = and i64 %2, 1
%9 = and i64 %2, -2
br label %10
10: ; preds = %10, %5
%11 = phi i64 [ 0, %5 ], [ %29, %10 ]
%12 = phi double [ 0.000000e+00, %5 ], [ %28, %10 ]
%13 = phi i64 [ 0, %5 ], [ %30, %10 ]
%14 = getelementptr inbounds double, double* %0, i64 %11
%15 = load double, double* %14
%16 = fsub double %15, %6
%17 = getelementptr inbounds double, double* %1, i64 %11
%18 = load double, double* %17
%19 = fsub double %18, %7
%20 = tail call double @llvm.fmuladd.f64(double %16, double %19, double %12)
%21 = or i64 %11, 1
%22 = getelementptr inbounds double, double* %0, i64 %21
%23 = load double, double* %22
%24 = fsub double %23, %6
%25 = getelementptr inbounds double, double* %1, i64 %21
%26 = load double, double* %25
%27 = fsub double %26, %7
%28 = tail call double @llvm.fmuladd.f64(double %24, double %27, double %20)
%29 = add nuw i64 %11, 2
%30 = add nuw i64 %13, 2
%31 = icmp eq i64 %30, %9
br i1 %31, label %32, label %10
32: ; preds = %10
%33 = icmp eq i64 %8, 0
br i1 %33, label %42, label %34
34: ; preds = %32
%35 = getelementptr inbounds double, double* %0, i64 %29
%36 = load double, double* %35
%37 = fsub double %36, %6
%38 = getelementptr inbounds double, double* %1, i64 %29
%39 = load double, double* %38
%40 = fsub double %39, %7
%41 = tail call double @llvm.fmuladd.f64(double %37, double %40, double %28)
br label %42
42: ; preds = %32, %34
%43 = phi double [ %28, %32 ], [ %41, %34 ]
%44 = add i64 %2, -1
%45 = uitofp i64 %44 to double
%46 = fdiv double %43, %45
br label %47
47: ; preds = %3, %42
%48 = phi double [ %46, %42 ], [ 0.000000e+00, %3 ]
ret double %48
}