#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 EXIT_SUCCESS;
int /*<<< orphan*/ calc_mm_std(float *, float *, float *, float *);
int /*<<< orphan*/ calcmean(float *, float *);
int /*<<< orphan*/ free(float *);
float *malloc(int);
int /*<<< orphan*/ pearson(float *, float *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ readmatrix(char *, float *);
int main(int argc, char **argv) {
  float *matrix, *minusmean, *mean, *std;
  matrix = malloc(sizeof(float) * 4000 * 20530);
  if (matrix == NULL) {
    return (1);
  }
  minusmean = malloc(sizeof(float) * 4000 * 20530);
  if (minusmean == NULL) {
    return (1);
  }
  mean = malloc(sizeof(float) * 20530);
  std = malloc(sizeof(float) * 20530);
  if (mean == NULL || std == NULL) {
    return (1);
  }
  if (argc != 2) {
    printf("Missing matrix file\n");
  } else {
    readmatrix(argv[1], matrix);
    calcmean(matrix, mean);
    calc_mm_std(matrix, mean, minusmean, std);
    pearson(minusmean, std);
  }
  free(mean);
  free(std);
  free(matrix);
  free(minusmean);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x13943500,%edi
call   1090 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ab <main+0x3b>
movl   $0x1,-0x4(%rbp)
jmp    1299 <main+0x129>
mov    $0x13943500,%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11d0 <main+0x60>
movl   $0x1,-0x4(%rbp)
jmp    1299 <main+0x129>
mov    $0x140c8,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x140c8,%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1202 <main+0x92>
cmpq   $0x0,-0x30(%rbp)
jne    120e <main+0x9e>
movl   $0x1,-0x4(%rbp)
jmp    1299 <main+0x129>
cmpl   $0x2,-0x8(%rbp)
je     1229 <main+0xb9>
lea    0xde1(%rip),%rdi
call   1050 <printf@plt>
jmp    1269 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <readmatrix@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <calcmean@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1040 <calc_mm_std@plt>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1060 <pearson@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%r12d
mov    $0x13943500,%edi
call   1090 <malloc@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     1246 <main+0xd6>
mov    %rax,%rbx
mov    $0x13943500,%edi
call   1090 <malloc@plt>
test   %rax,%rax
je     1246 <main+0xd6>
mov    %rax,%r14
mov    $0x140c8,%edi
call   1090 <malloc@plt>
mov    %rax,%r15
mov    $0x140c8,%edi
call   1090 <malloc@plt>
test   %r15,%r15
je     1246 <main+0xd6>
test   %rax,%rax
je     1246 <main+0xd6>
mov    %rax,%rbp
cmp    $0x2,%r12d
jne    1211 <main+0xa1>
mov    0x8(%r13),%rdi
mov    %rbx,%rsi
call   1070 <readmatrix@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <calcmean@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %rbp,%rcx
call   1050 <calc_mm_std@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1060 <pearson@plt>
jmp    121d <main+0xad>
lea    0xde8(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2d9c(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Missing matrix file\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca float*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call float* @malloc(i32 328480000)
store float* %10, float** %6
%11 = load float*, float** %6
%12 = icmp eq float* %11, null
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 1, i32* %3
br label %60
14: ; preds = %2
%15 = call float* @malloc(i32 328480000)
store float* %15, float** %7
%16 = load float*, float** %7
%17 = icmp eq float* %16, null
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 1, i32* %3
br label %60
19: ; preds = %14
%20 = call float* @malloc(i32 82120)
store float* %20, float** %8
%21 = call float* @malloc(i32 82120)
store float* %21, float** %9
%22 = load float*, float** %8
%23 = icmp eq float* %22, null
br i1 %23, label %27, label %24
24: ; preds = %19
%25 = load float*, float** %9
%26 = icmp eq float* %25, null
br i1 %26, label %27, label %28
27: ; preds = %24, %19
store i32 1, i32* %3
br label %60
28: ; preds = %24
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 2
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %50
33: ; preds = %28
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = load float*, float** %6
%38 = call i32 @readmatrix(i8* %36, float* %37)
%39 = load float*, float** %6
%40 = load float*, float** %8
%41 = call i32 @calcmean(float* %39, float* %40)
%42 = load float*, float** %6
%43 = load float*, float** %8
%44 = load float*, float** %7
%45 = load float*, float** %9
%46 = call i32 @calc_mm_std(float* %42, float* %43, float* %44, float* %45)
%47 = load float*, float** %7
%48 = load float*, float** %9
%49 = call i32 @pearson(float* %47, float* %48)
br label %50
50: ; preds = %33, %31
%51 = load float*, float** %8
%52 = call i32 @free(float* %51)
%53 = load float*, float** %9
%54 = call i32 @free(float* %53)
%55 = load float*, float** %6
%56 = call i32 @free(float* %55)
%57 = load float*, float** %7
%58 = call i32 @free(float* %57)
%59 = load i32, i32* @EXIT_SUCCESS
store i32 %59, i32* %3
br label %60
60: ; preds = %50, %27, %18, %13
%61 = load i32, i32* %3
ret i32 %61
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@str = [20 x i8] c"Missing matrix file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call float* @malloc(i32 328480000)
%4 = icmp eq float* %3, null
br i1 %4, label %31, label %5
5: ; preds = %2
%6 = tail call float* @malloc(i32 328480000)
%7 = icmp eq float* %6, null
br i1 %7, label %31, label %8
8: ; preds = %5
%9 = tail call float* @malloc(i32 82120)
%10 = tail call float* @malloc(i32 82120)
%11 = icmp eq float* %9, null
%12 = icmp eq float* %10, null
%13 = or i1 %11, %12
br i1 %13, label %31, label %14
14: ; preds = %8
%15 = icmp eq i32 %0, 2
br i1 %15, label %18, label %16
16: ; preds = %14
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %25
18: ; preds = %14
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = tail call i32 @readmatrix(i8* %20, float* %3)
%22 = tail call i32 @calcmean(float* %3, float* %9)
%23 = tail call i32 @calc_mm_std(float* %3, float* %9, float* %6, float* %10)
%24 = tail call i32 @pearson(float* %6, float* %10)
br label %25
25: ; preds = %18, %16
%26 = tail call i32 @free(float* %9)
%27 = tail call i32 @free(float* %10)
%28 = tail call i32 @free(float* %3)
%29 = tail call i32 @free(float* %6)
%30 = load i32, i32* @EXIT_SUCCESS
br label %31
31: ; preds = %8, %5, %2, %25
%32 = phi i32 [ %30, %25 ], [ 1, %2 ], [ 1, %5 ], [ 1, %8 ]
ret i32 %32
}