#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ free(float *);
float *malloc(size_t);
int /*<<< orphan*/ memcpy(float *, float const *, size_t);
int /*<<< orphan*/ normalizeRows(float *, size_t const, size_t const);
float *tcrossprod(float *, size_t const, size_t const);
extern float *getCorrelation(const float *vectors, const size_t cols,
                             const size_t rows) {
  size_t inputSize = cols * rows * sizeof(float);
  float *input = malloc(inputSize);
  assert(input != NULL);
  memcpy(input, vectors, inputSize);
  normalizeRows(input, cols, rows);
  float *output = tcrossprod(input, cols, rows);
  free(input);
  return output;
}


x86 assembly (clang, -O0):
<getCorrelation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
imul   -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <memcpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <normalizeRows@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1080 <tcrossprod@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCorrelation>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
mov    %rsi,%rbx
imul   %rdx,%rbx
shl    $0x2,%rbx
mov    %rbx,%rdi
call   1060 <malloc@plt>
mov    %rax,%r13
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1040 <assert@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <memcpy@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1070 <normalizeRows@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1080 <tcrossprod@plt>
mov    %rax,%rbx
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float* @getCorrelation(float* %0, i64 %1, i64 %2) {
%4 = alloca float*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca float*
%9 = alloca float*
store float* %0, float** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%10 = load i64, i64* %5
%11 = load i64, i64* %6
%12 = mul i64 %10, %11
%13 = mul i64 %12, 4
store i64 %13, i64* %7
%14 = load i64, i64* %7
%15 = call float* @malloc(i64 %14)
store float* %15, float** %8
%16 = load float*, float** %8
%17 = icmp ne float* %16, null
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load float*, float** %8
%21 = load float*, float** %4
%22 = load i64, i64* %7
%23 = call i32 @memcpy(float* %20, float* %21, i64 %22)
%24 = load float*, float** %8
%25 = load i64, i64* %5
%26 = load i64, i64* %6
%27 = call i32 @normalizeRows(float* %24, i64 %25, i64 %26)
%28 = load float*, float** %8
%29 = load i64, i64* %5
%30 = load i64, i64* %6
%31 = call float* @tcrossprod(float* %28, i64 %29, i64 %30)
store float* %31, float** %9
%32 = load float*, float** %8
%33 = call i32 @free(float* %32)
%34 = load float*, float** %9
ret float* %34
}

LLVM IR (-O2):
define float* @getCorrelation(float* %0, i64 %1, i64 %2) {
%4 = shl i64 %1, 2
%5 = mul i64 %4, %2
%6 = tail call float* @malloc(i64 %5)
%7 = icmp ne float* %6, null
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32 @memcpy(float* %6, float* %0, i64 %5)
%11 = tail call i32 @normalizeRows(float* %6, i64 %1, i64 %2)
%12 = tail call float* @tcrossprod(float* %6, i64 %1, i64 %2)
%13 = tail call i32 @free(float* %6)
ret float* %12
}