#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 covar(int const, double const *, double const *);
int pcapack_symmetrize(int, int const, int const, double *);
int pcapack_cov_naive(const int m, const int n, const double *restrict x,
                      double *restrict cov) {
  int i, j;
#pragma omp parallel for
  for (j = 0; j < n; j++) {
    for (i = j; i < n; i++)
      cov[i + n * j] = covar(m, x + m * j, x + m * i);
  }
  int info = pcapack_symmetrize(2, n, n, cov);
  return info;
}


x86 assembly (clang, -O0):
<pcapack_cov_naive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c4 <pcapack_cov_naive+0xa4>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b1 <pcapack_cov_naive+0x91>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x4(%rbp),%eax
imul   -0x20(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x10(%rbp),%rdx
mov    -0x4(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
call   1040 <covar@plt>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%edx
imul   -0x20(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114f <pcapack_cov_naive+0x2f>
jmp    11b6 <pcapack_cov_naive+0x96>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113d <pcapack_cov_naive+0x1d>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x2,%edi
call   1030 <pcapack_symmetrize@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pcapack_cov_naive>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,0x8(%rsp)
mov    %rdx,0x10(%rsp)
mov    %esi,0x4(%rsp)
test   %esi,%esi
jle    11f9 <pcapack_cov_naive+0xd9>
mov    %edi,%r14d
movslq %edi,%rax
mov    0x4(%rsp),%r12d
lea    0x8(,%r12,8),%rcx
mov    %rcx,0x18(%rsp)
mov    %rax,0x28(%rsp)
lea    0x0(,%rax,8),%rdx
xor    %eax,%eax
mov    %r12,0x20(%rsp)
mov    0x10(%rsp),%rbp
mov    0x8(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %rax,0x38(%rsp)
imul   0x28(%rsp),%rax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%rax
mov    %rax,0x40(%rsp)
mov    %rbp,0x30(%rsp)
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    0x40(%rsp),%rsi
mov    %rdx,%r15
mov    %rbp,%rdx
call   1040 <covar@plt>
mov    %r15,%rdx
movsd  %xmm0,(%rbx,%r13,8)
add    $0x1,%r13
add    %r15,%rbp
cmp    %r13,%r12
jne    11b0 <pcapack_cov_naive+0x90>
mov    0x38(%rsp),%rax
add    $0x1,%rax
add    0x18(%rsp),%rbx
mov    0x30(%rsp),%rbp
add    %rdx,%rbp
add    $0xffffffffffffffff,%r12
cmp    0x20(%rsp),%rax
jne    1180 <pcapack_cov_naive+0x60>
mov    $0x2,%edi
mov    0x4(%rsp),%edx
mov    %edx,%esi
mov    0x8(%rsp),%rcx
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <pcapack_symmetrize@plt>

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

LLVM IR (-O2):
define i32 @pcapack_cov_naive(i32 %0, i32 %1, double* noalias %2, double* noalias %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %27
6: ; preds = %4
%7 = sext i32 %0 to i64
%8 = zext i32 %1 to i64
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %24, %6
%11 = phi i64 [ 0, %6 ], [ %25, %24 ]
%12 = mul nsw i64 %11, %7
%13 = getelementptr inbounds double, double* %2, i64 %12
%14 = mul nsw i64 %11, %8
br label %15
15: ; preds = %10, %15
%16 = phi i64 [ %11, %10 ], [ %22, %15 ]
%17 = mul nsw i64 %16, %7
%18 = getelementptr inbounds double, double* %2, i64 %17
%19 = tail call double @covar(i32 %0, double* %13, double* %18)
%20 = add nuw nsw i64 %16, %14
%21 = getelementptr inbounds double, double* %3, i64 %20
store double %19, double* %21
%22 = add nuw nsw i64 %16, 1
%23 = icmp eq i64 %22, %9
br i1 %23, label %24, label %15
24: ; preds = %15
%25 = add nuw nsw i64 %11, 1
%26 = icmp eq i64 %25, %9
br i1 %26, label %27, label %10
27: ; preds = %24, %4
%28 = tail call i32 @pcapack_symmetrize(i32 2, i32 %1, i32 %1, double* %3)
ret i32 %28
}