#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);
scalar_t__ pow(double, int);
double sqrt(double);
double compute_D(double *R1, double *R2, int N) {
  double mu1, mu2, s1, s2;
  int i;
  mu1 = avg_array(R1, N);
  mu2 = avg_array(R1, N);
  s1 = s2 = 0.0;
  for (i = 0; i < N; i++) {
    s1 += pow((R1[i] - mu1), 2);
    s2 += pow((R2[i] - mu2), 2);
  }
  return sqrt(s1 * s2);
}


x86 assembly (clang, -O0):
<compute_D>:
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    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <avg_array@plt>
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ec <compute_D+0xbc>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x20(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x28(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    117c <compute_D+0x4c>
movsd  -0x30(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1050 <sqrt@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_D>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %edx,%esi
call   1030 <avg_array@plt>
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <avg_array@plt>
xorpd  %xmm1,%xmm1
xorpd  %xmm2,%xmm2
test   %ebp,%ebp
jle    12db <compute_D+0x1ab>
movsd  %xmm0,0x18(%rsp)
mov    %ebp,%r15d
cmp    $0x1,%ebp
jne    1193 <compute_D+0x63>
xorpd  %xmm0,%xmm0
xor    %ebp,%ebp
xorpd  %xmm1,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm1
jmp    1265 <compute_D+0x135>
mov    %r15d,%r12d
and    $0xfffffffe,%r12d
xorpd  %xmm0,%xmm0
xor    %ebp,%ebp
xorpd  %xmm1,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm1
nop
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
subsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%r14,%rbp,8),%xmm0
subsd  0x18(%rsp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rbx,%rbp,8),%xmm0
subsd  0x10(%rsp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%r14,%rbp,8),%xmm0
subsd  0x18(%rsp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  0x10(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x2,%rbp
cmp    %rbp,%r12
jne    11b0 <compute_D+0x80>
test   $0x1,%r15b
je     12ce <compute_D+0x19e>
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
subsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%r14,%rbp,8),%xmm0
subsd  0x18(%rsp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm2
mulsd  %xmm0,%xmm2
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm2
jb     12f5 <compute_D+0x1c5>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
movapd %xmm2,%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <sqrt@plt>

LLVM IR (-O0):
define double @compute_D(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
%11 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
%12 = load double*, double** %4
%13 = load i32, i32* %6
%14 = call double @avg_array(double* %12, i32 %13)
store double %14, double* %7
%15 = load double*, double** %4
%16 = load i32, i32* %6
%17 = call double @avg_array(double* %15, i32 %16)
store double %17, double* %8
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %9
store i32 0, i32* %11
br label %18
18: ; preds = %45, %3
%19 = load i32, i32* %11
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %48
22: ; preds = %18
%23 = load double*, double** %4
%24 = load i32, i32* %11
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = load double, double* %7
%29 = fsub double %27, %28
%30 = call i64 @pow(double %29, i32 2)
%31 = sitofp i64 %30 to double
%32 = load double, double* %9
%33 = fadd double %32, %31
store double %33, double* %9
%34 = load double*, double** %5
%35 = load i32, i32* %11
%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
%41 = call i64 @pow(double %40, i32 2)
%42 = sitofp i64 %41 to double
%43 = load double, double* %10
%44 = fadd double %43, %42
store double %44, double* %10
br label %45
45: ; preds = %22
%46 = load i32, i32* %11
%47 = add nsw i32 %46, 1
store i32 %47, i32* %11
br label %18
48: ; preds = %18
%49 = load double, double* %9
%50 = load double, double* %10
%51 = fmul double %49, %50
%52 = call double @sqrt(double %51)
ret double %52
}

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