#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*/ eigsrta(double *, double *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(double *, double *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ tqlia(double *, double *, int, double *);
int /*<<< orphan*/ tred2a(double *, int, double *, double *);
void eigenanalyasis(int n, double *cov, double *vals, double *vecs) {
  double *e;
  if ((e = (double *)malloc(n * sizeof(double))) == NULL) {
    fprintf(stderr, "eigenanalyasis: Can't allocate memory\n");
    exit(-1);
  }
  memcpy(vecs, cov, sizeof(double) * n * n);
  tred2a(vecs, n, vals, e);
  tqlia(vals, e, n, vecs);
  eigsrta(vals, vecs, n);
  free(e);
}


x86 assembly (clang, -O0):
<eigenanalyasis>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11d3 <eigenanalyasis+0x53>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
movslq -0x4(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edx
call   1080 <memcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <tred2a@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x4(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1070 <tqlia@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   1050 <eigsrta@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eigenanalyasis>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%r13
mov    %edi,%ebx
lea    0x0(,%rbx,8),%ebp
mov    %ebp,%edi
call   1090 <malloc@plt>
test   %rax,%rax
je     11ff <eigenanalyasis+0x7f>
mov    %rax,%r12
imul   %ebx,%ebp
mov    %r15,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1080 <memcpy@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %r12,%rcx
call   1030 <tred2a@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
mov    %r15,%rcx
call   1070 <tqlia@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1050 <eigsrta@plt>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <free@plt>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
lea    0xdf1(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"eigenanalyasis: Can't allocate memory\0A\00"
define void @eigenanalyasis(i32 %0, double* %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 8
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to double*
store double* %15, double** %9
%16 = icmp eq double* %15, null
br i1 %16, label %17, label %21
17: ; preds = %4
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %4
%22 = load double*, double** %8
%23 = load double*, double** %6
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = mul i64 8, %25
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = mul i64 %26, %28
%30 = trunc i64 %29 to i32
%31 = call i32 @memcpy(double* %22, double* %23, i32 %30)
%32 = load double*, double** %8
%33 = load i32, i32* %5
%34 = load double*, double** %7
%35 = load double*, double** %9
%36 = call i32 @tred2a(double* %32, i32 %33, double* %34, double* %35)
%37 = load double*, double** %7
%38 = load double*, double** %9
%39 = load i32, i32* %5
%40 = load double*, double** %8
%41 = call i32 @tqlia(double* %37, double* %38, i32 %39, double* %40)
%42 = load double*, double** %7
%43 = load double*, double** %8
%44 = load i32, i32* %5
%45 = call i32 @eigsrta(double* %42, double* %43, i32 %44)
%46 = load double*, double** %9
%47 = call i32 @free(double* %46)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"eigenanalyasis: Can't allocate memory\0A\00"
define void @eigenanalyasis(i32 %0, double* %1, double* %2, double* %3) {
%5 = shl i32 %0, 3
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to double*
%8 = icmp eq i64 %6, 0
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 -1)
unreachable
13: ; preds = %4
%14 = mul i32 %5, %0
%15 = tail call i32 @memcpy(double* %3, double* %1, i32 %14)
%16 = tail call i32 @tred2a(double* %3, i32 %0, double* %2, double* %7)
%17 = tail call i32 @tqlia(double* %2, double* %7, i32 %0, double* %3)
%18 = tail call i32 @eigsrta(double* %2, double* %3, i32 %0)
%19 = tail call i32 @free(double* %7)
ret void
}