#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 avg_array(double *, int);
double compute_C(double *R1, double *R2, int N) {
  double mu1, mu2, sum1, sum2;
  mu1 = avg_array(R1, N);
  mu2 = avg_array(R2, N);
  sum1 = mu1 * N;
  sum2 = mu2 * N;
  return N * mu1 * mu2 - mu2 * sum1 - mu1 * sum2;
}


x86 assembly (clang, -O0):
<compute_C>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <avg_array@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <avg_array@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_C>:
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r14
mov    %edx,%esi
call   1030 <avg_array@plt>
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <avg_array@plt>
cvtsi2sd %ebx,%xmm1
movsd  (%rsp),%xmm3
movapd %xmm3,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm0,%xmm1
mulsd  %xmm2,%xmm0
subsd  %xmm0,%xmm0
mulsd  %xmm3,%xmm1
subsd  %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @compute_C(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
%11 = load double*, double** %4
%12 = load i32, i32* %6
%13 = call double @avg_array(double* %11, i32 %12)
store double %13, double* %7
%14 = load double*, double** %5
%15 = load i32, i32* %6
%16 = call double @avg_array(double* %14, i32 %15)
store double %16, double* %8
%17 = load double, double* %7
%18 = load i32, i32* %6
%19 = sitofp i32 %18 to double
%20 = fmul double %17, %19
store double %20, double* %9
%21 = load double, double* %8
%22 = load i32, i32* %6
%23 = sitofp i32 %22 to double
%24 = fmul double %21, %23
store double %24, double* %10
%25 = load i32, i32* %6
%26 = sitofp i32 %25 to double
%27 = load double, double* %7
%28 = fmul double %26, %27
%29 = load double, double* %8
%30 = load double, double* %8
%31 = load double, double* %9
%32 = fmul double %30, %31
%33 = fneg double %32
%34 = call double @llvm.fmuladd.f64(double %28, double %29, double %33)
%35 = load double, double* %7
%36 = load double, double* %10
%37 = fneg double %35
%38 = call double @llvm.fmuladd.f64(double %37, double %36, double %34)
ret double %38
}

LLVM IR (-O2):
define double @compute_C(double* %0, double* %1, i32 %2) {
%4 = tail call double @avg_array(double* %0, i32 %2)
%5 = tail call double @avg_array(double* %1, i32 %2)
%6 = sitofp i32 %2 to double
%7 = fmul double %4, %6
%8 = fmul double %5, %6
%9 = fneg double %5
%10 = fmul double %7, %9
%11 = tail call double @llvm.fmuladd.f64(double %7, double %5, double %10)
%12 = fneg double %4
%13 = tail call double @llvm.fmuladd.f64(double %12, double %8, double %11)
ret double %13
}