#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 */
int /*<<< orphan*/ cov(size_t, size_t, size_t, size_t, double **, double **,
                       double *, double *, double **);
int /*<<< orphan*/ dump1d(size_t, double *);
int /*<<< orphan*/ dump2d(size_t, size_t, double **);
int /*<<< orphan*/ printf(char *, ...);
void testcov(size_t xr, size_t xc, size_t yr, size_t yc, double X[xr][xc],
             double Y[yr][yc]) {
  double Z[xc][yc];
  double xm[xc];
  double ym[yc];
  cov(xr, xc, yr, yc, X, Y, xm, ym, Z);
  printf("cov(X[%zu, %zu], Y[%zu, %zu]) = Z[%zu, %zu]\n", xr, xc, yr, yc, xc,
         yc);
  printf("X Means\n");
  dump1d(xc, xm);
  printf("\n");
  printf("Y Means\n");
  dump1d(yc, ym);
  printf("\n");
  printf("Covariance\n");
  dump2d(xc, yc, Z);
  printf("\n");
}


x86 assembly (clang, -O0):
<testcov>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    %rsp,%rax
mov    %rax,-0x38(%rbp)
mov    %rdx,%rax
imul   %rcx,%rax
lea    0xf(,%rax,8),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rax
sub    %rsi,%rax
mov    %rax,-0x60(%rbp)
mov    %rax,%rsp
mov    %rdx,-0x40(%rbp)
mov    %rcx,-0x48(%rbp)
mov    -0x10(%rbp),%rcx
lea    0xf(,%rcx,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%r11
sub    %rdx,%r11
mov    %r11,-0x70(%rbp)
mov    %r11,%rsp
mov    %rcx,-0x50(%rbp)
mov    -0x20(%rbp),%rcx
lea    0xf(,%rcx,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%r10
sub    %rdx,%r10
mov    %r10,-0x68(%rbp)
mov    %r10,%rsp
mov    %rcx,-0x58(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
sub    $0x20,%rsp
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <cov@plt>
add    $0x20,%rsp
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x10(%rbp),%r9
mov    -0x20(%rbp),%rax
lea    0xdd5(%rip),%rdi
sub    $0x10,%rsp
mov    %rax,(%rsp)
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x10,%rsp
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x70(%rbp),%rsi
mov    -0x10(%rbp),%rdi
call   1060 <dump1d@plt>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x68(%rbp),%rsi
mov    -0x20(%rbp),%rdi
call   1060 <dump1d@plt>
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x60(%rbp),%rdx
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <dump2d@plt>
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testcov>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rdx,-0x38(%rbp)
mov    %rsi,%r12
mov    %rdi,-0x30(%rbp)
mov    %rcx,%rax
imul   %rsi,%rax
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%r13
lea    0xf(,%rsi,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %rsp,%rbx
lea    0xf(,%rcx,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
sub    $0x8,%rsp
push   %r15
push   %rbx
push   %r13
call   1060 <cov@plt>
add    $0x18,%rsp
lea    0xe22(%rip),%rdi
mov    -0x30(%rbp),%rsi
mov    %r12,%rdx
mov    -0x38(%rbp),%rcx
mov    %r14,%r8
mov    %r12,%r9
xor    %eax,%eax
push   %r14
call   1070 <printf@plt>
add    $0x10,%rsp
lea    0xe2a(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1080 <dump1d@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe11(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <dump1d@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdf8(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <dump2d@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [45 x i8] c"cov(X[%zu, %zu], Y[%zu, %zu]) = Z[%zu, %zu]\0A\00"
@.str.1 = [9 x i8] c"X Means\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [9 x i8] c"Y Means\0A\00"
@.str.4 = [12 x i8] c"Covariance\0A\00"
define void @testcov(i64 %0, i64 %1, i64 %2, i64 %3, double* %4, double* %5) {
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca double*
%12 = alloca double*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
store i64 %0, i64* %7
store i64 %1, i64* %8
store i64 %2, i64* %9
store i64 %3, i64* %10
store double* %4, double** %11
store double* %5, double** %12
%18 = load i64, i64* %7
%19 = load i64, i64* %8
%20 = load i64, i64* %9
%21 = load i64, i64* %10
%22 = load i64, i64* %8
%23 = load i64, i64* %10
%24 = call i8* @llvm.stacksave()
store i8* %24, i8** %13
%25 = mul nuw i64 %22, %23
%26 = alloca double, i64 %25
store i64 %22, i64* %14
store i64 %23, i64* %15
%27 = load i64, i64* %8
%28 = alloca double, i64 %27
store i64 %27, i64* %16
%29 = load i64, i64* %10
%30 = alloca double, i64 %29
store i64 %29, i64* %17
%31 = load i64, i64* %7
%32 = load i64, i64* %8
%33 = load i64, i64* %9
%34 = load i64, i64* %10
%35 = load double*, double** %11
%36 = bitcast double* %35 to double**
%37 = load double*, double** %12
%38 = bitcast double* %37 to double**
%39 = bitcast double* %26 to double**
%40 = call i32 @cov(i64 %31, i64 %32, i64 %33, i64 %34, double** %36, double** %38, double* %28, double* %30, double** %39)
%41 = load i64, i64* %7
%42 = load i64, i64* %8
%43 = load i64, i64* %9
%44 = load i64, i64* %10
%45 = load i64, i64* %8
%46 = load i64, i64* %10
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i64 %41, i64 %42, i64 %43, i64 %44, i64 %45, i64 %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%49 = load i64, i64* %8
%50 = call i32 @dump1d(i64 %49, double* %28)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%53 = load i64, i64* %10
%54 = call i32 @dump1d(i64 %53, double* %30)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%57 = load i64, i64* %8
%58 = load i64, i64* %10
%59 = bitcast double* %26 to double**
%60 = call i32 @dump2d(i64 %57, i64 %58, double** %59)
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%62 = load i8*, i8** %13
ret void
}

LLVM IR (-O2):
@.str = [45 x i8] c"cov(X[%zu, %zu], Y[%zu, %zu]) = Z[%zu, %zu]\0A\00"
@str = [8 x i8] c"X Means\00"
@str.5 = [8 x i8] c"Y Means\00"
@str.6 = [11 x i8] c"Covariance\00"
define void @testcov(i64 %0, i64 %1, i64 %2, i64 %3, double* %4, double* %5) {
%7 = mul nuw i64 %3, %1
%8 = alloca double*, i64 %7
%9 = alloca double, i64 %1
%10 = alloca double, i64 %3
%11 = bitcast double* %4 to double**
%12 = bitcast double* %5 to double**
%13 = call i32 @cov(i64 %0, i64 %1, i64 %2, i64 %3, double** %11, double** %12, double* %9, double* %10, double** %8)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i64 %0, i64 %1, i64 %2, i64 %3, i64 %1, i64 %3)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%16 = call i32 @dump1d(i64 %1, double* %9)
%17 = call i32 @putchar(i32 10)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.5, i64 0, i64 0))
%19 = call i32 @dump1d(i64 %3, double* %10)
%20 = call i32 @putchar(i32 10)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.6, i64 0, i64 0))
%22 = call i32 @dump2d(i64 %1, i64 %3, double** %8)
%23 = call i32 @putchar(i32 10)
ret void
}