#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;
  int i;
  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    $0x40,%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    $0x40,%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*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call float* @malloc(i32 328480000)
store float* %11, float** %6
%12 = load float*, float** %6
%13 = icmp eq float* %12, null
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 1, i32* %3
br label %61
15: ; preds = %2
%16 = call float* @malloc(i32 328480000)
store float* %16, float** %7
%17 = load float*, float** %7
%18 = icmp eq float* %17, null
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 1, i32* %3
br label %61
20: ; preds = %15
%21 = call float* @malloc(i32 82120)
store float* %21, float** %8
%22 = call float* @malloc(i32 82120)
store float* %22, float** %9
%23 = load float*, float** %8
%24 = icmp eq float* %23, null
br i1 %24, label %28, label %25
25: ; preds = %20
%26 = load float*, float** %9
%27 = icmp eq float* %26, null
br i1 %27, label %28, label %29
28: ; preds = %25, %20
store i32 1, i32* %3
br label %61
29: ; preds = %25
%30 = load i32, i32* %4
%31 = icmp ne i32 %30, 2
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %51
34: ; preds = %29
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = load float*, float** %6
%39 = call i32 @readmatrix(i8* %37, float* %38)
%40 = load float*, float** %6
%41 = load float*, float** %8
%42 = call i32 @calcmean(float* %40, float* %41)
%43 = load float*, float** %6
%44 = load float*, float** %8
%45 = load float*, float** %7
%46 = load float*, float** %9
%47 = call i32 @calc_mm_std(float* %43, float* %44, float* %45, float* %46)
%48 = load float*, float** %7
%49 = load float*, float** %9
%50 = call i32 @pearson(float* %48, float* %49)
br label %51
51: ; preds = %34, %32
%52 = load float*, float** %8
%53 = call i32 @free(float* %52)
%54 = load float*, float** %9
%55 = call i32 @free(float* %54)
%56 = load float*, float** %6
%57 = call i32 @free(float* %56)
%58 = load float*, float** %7
%59 = call i32 @free(float* %58)
%60 = load i32, i32* @EXIT_SUCCESS
store i32 %60, i32* %3
br label %61
61: ; preds = %51, %28, %19, %14
%62 = load i32, i32* %3
ret i32 %62
}

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
}