#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);
double llz_corr_cof(double *a, double *b, int len) {
  int k;
  double ta, tb, tc;
  double rab;
  ta = tb = tc = 0;
  for (k = 0; k < len; k++) {
    ta += a[k] * b[k];
    tb += a[k] * a[k];
    tc += b[k] * b[k];
  }
  rab = ta / sqrt(tb * tc);
  return rab;
}


x86 assembly (clang, -O0):
<llz_corr_cof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e0 <llz_corr_cof+0xd0>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1142 <llz_corr_cof+0x32>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<llz_corr_cof>:
sub    $0x18,%rsp
xorpd  %xmm1,%xmm1
xorpd  %xmm7,%xmm7
xorpd  %xmm0,%xmm0
test   %edx,%edx
jle    11d5 <llz_corr_cof+0xc5>
mov    %edx,%eax
cmp    $0x1,%edx
jne    113b <llz_corr_cof+0x2b>
xorpd  %xmm2,%xmm2
xorpd  %xmm7,%xmm7
xor    %ecx,%ecx
jmp    11a3 <llz_corr_cof+0x93>
mov    %eax,%edx
and    $0xfffffffe,%edx
xorpd  %xmm0,%xmm0
xorpd  %xmm7,%xmm7
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
movsd  (%rdi,%rcx,8),%xmm3
movsd  0x8(%rdi,%rcx,8),%xmm4
movsd  (%rsi,%rcx,8),%xmm5
movsd  0x8(%rsi,%rcx,8),%xmm2
movapd %xmm3,%xmm6
mulsd  %xmm5,%xmm6
addsd  %xmm7,%xmm6
unpcklpd %xmm3,%xmm5
mulpd  %xmm5,%xmm5
addpd  %xmm0,%xmm5
movapd %xmm4,%xmm7
mulsd  %xmm2,%xmm7
addsd  %xmm6,%xmm7
unpcklpd %xmm4,%xmm2
mulpd  %xmm2,%xmm2
addpd  %xmm5,%xmm2
add    $0x2,%rcx
movapd %xmm2,%xmm0
cmp    %rcx,%rdx
jne    1150 <llz_corr_cof+0x40>
test   $0x1,%al
je     11c9 <llz_corr_cof+0xb9>
movsd  (%rdi,%rcx,8),%xmm0
movsd  (%rsi,%rcx,8),%xmm3
movapd %xmm0,%xmm4
mulsd  %xmm3,%xmm4
addsd  %xmm4,%xmm7
unpcklpd %xmm0,%xmm3
mulpd  %xmm3,%xmm3
addpd  %xmm3,%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jb     11e1 <llz_corr_cof+0xd1>
sqrtsd %xmm0,%xmm0
jmp    11f0 <llz_corr_cof+0xe0>
movapd %xmm7,(%rsp)
call   1030 <sqrt@plt>
movapd (%rsp),%xmm7
divsd  %xmm0,%xmm7
movapd %xmm7,%xmm0
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define double @llz_corr_cof(double* nocapture %0, double* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %58
5: ; preds = %3
%6 = zext i32 %2 to i64
%7 = and i64 %6, 1
%8 = icmp eq i32 %2, 1
br i1 %8, label %36, label %9
9: ; preds = %5
%10 = and i64 %6, 4294967294
br label %11
11: ; preds = %11, %9
%12 = phi i64 [ 0, %9 ], [ %33, %11 ]
%13 = phi double [ 0.000000e+00, %9 ], [ %29, %11 ]
%14 = phi <2 x double> [ zeroinitializer, %9 ], [ %32, %11 ]
%15 = phi i64 [ 0, %9 ], [ %34, %11 ]
%16 = getelementptr inbounds double, double* %0, i64 %12
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %1, i64 %12
%19 = load double, double* %18
%20 = tail call double @llvm.fmuladd.f64(double %17, double %19, double %13)
%21 = insertelement <2 x double> poison, double %19, i64 0
%22 = insertelement <2 x double> %21, double %17, i64 1
%23 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %22, <2 x double> %22, <2 x double> %14)
%24 = or i64 %12, 1
%25 = getelementptr inbounds double, double* %0, i64 %24
%26 = load double, double* %25
%27 = getelementptr inbounds double, double* %1, i64 %24
%28 = load double, double* %27
%29 = tail call double @llvm.fmuladd.f64(double %26, double %28, double %20)
%30 = insertelement <2 x double> poison, double %28, i64 0
%31 = insertelement <2 x double> %30, double %26, i64 1
%32 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %31, <2 x double> %23)
%33 = add nuw nsw i64 %12, 2
%34 = add i64 %15, 2
%35 = icmp eq i64 %34, %10
br i1 %35, label %36, label %11
36: ; preds = %11, %5
%37 = phi double [ undef, %5 ], [ %29, %11 ]
%38 = phi <2 x double> [ undef, %5 ], [ %32, %11 ]
%39 = phi i64 [ 0, %5 ], [ %33, %11 ]
%40 = phi double [ 0.000000e+00, %5 ], [ %29, %11 ]
%41 = phi <2 x double> [ zeroinitializer, %5 ], [ %32, %11 ]
%42 = icmp eq i64 %7, 0
br i1 %42, label %52, label %43
43: ; preds = %36
%44 = getelementptr inbounds double, double* %0, i64 %39
%45 = load double, double* %44
%46 = getelementptr inbounds double, double* %1, i64 %39
%47 = load double, double* %46
%48 = tail call double @llvm.fmuladd.f64(double %45, double %47, double %40)
%49 = insertelement <2 x double> poison, double %47, i64 0
%50 = insertelement <2 x double> %49, double %45, i64 1
%51 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %50, <2 x double> %50, <2 x double> %41)
br label %52
52: ; preds = %36, %43
%53 = phi double [ %37, %36 ], [ %48, %43 ]
%54 = phi <2 x double> [ %38, %36 ], [ %51, %43 ]
%55 = shufflevector <2 x double> %54, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%56 = fmul <2 x double> %55, %54
%57 = extractelement <2 x double> %56, i64 0
br label %58
58: ; preds = %52, %3
%59 = phi double [ 0.000000e+00, %3 ], [ %53, %52 ]
%60 = phi double [ 0.000000e+00, %3 ], [ %57, %52 ]
%61 = tail call double @sqrt(double %60)
%62 = fdiv double %59, %61
ret double %62
}