#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ memcpy(double *, double *, int);
int /*<<< orphan*/ tqli(double *, int, double *, double *);
int /*<<< orphan*/ tred2(double *, int, double *, double *);
void eigensystem(double *mat, int N, double *eval, double *evec) {
  double *e;
  e = (double *)calloc(N, sizeof(double));
  memcpy(evec, mat, sizeof(double) * N * N);
  tred2(evec, N, eval, e);
  tqli(eval, N, e, evec);
  free(e);
}


x86 assembly (clang, -O0):
<eigensystem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
movslq -0xc(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1070 <tred2@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <tqli@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eigensystem>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r12
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%r15
mov    %esi,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
mov    %ebp,%edx
imul   %ebp,%edx
shl    $0x3,%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1060 <memcpy@plt>
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1070 <tred2@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    %r12,%rcx
call   1040 <tqli@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @eigensystem(double* %0, i32 %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
store double* %0, double** %5
store i32 %1, i32* %6
store double* %2, double** %7
store double* %3, double** %8
%10 = load i32, i32* %6
%11 = call i64 @calloc(i32 %10, i32 8)
%12 = inttoptr i64 %11 to double*
store double* %12, double** %9
%13 = load double*, double** %8
%14 = load double*, double** %5
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = mul i64 8, %16
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = mul i64 %17, %19
%21 = trunc i64 %20 to i32
%22 = call i32 @memcpy(double* %13, double* %14, i32 %21)
%23 = load double*, double** %8
%24 = load i32, i32* %6
%25 = load double*, double** %7
%26 = load double*, double** %9
%27 = call i32 @tred2(double* %23, i32 %24, double* %25, double* %26)
%28 = load double*, double** %7
%29 = load i32, i32* %6
%30 = load double*, double** %9
%31 = load double*, double** %8
%32 = call i32 @tqli(double* %28, i32 %29, double* %30, double* %31)
%33 = load double*, double** %9
%34 = call i32 @free(double* %33)
ret void
}

LLVM IR (-O2):
define void @eigensystem(double* %0, i32 %1, double* %2, double* %3) {
%5 = tail call i64 @calloc(i32 %1, i32 8)
%6 = inttoptr i64 %5 to double*
%7 = shl i32 %1, 3
%8 = mul i32 %7, %1
%9 = tail call i32 @memcpy(double* %3, double* %0, i32 %8)
%10 = tail call i32 @tred2(double* %3, i32 %1, double* %2, double* %6)
%11 = tail call i32 @tqli(double* %2, i32 %1, double* %6, double* %3)
%12 = tail call i32 @free(double* %6)
ret void
}