#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*/ gen_sym_eigen(int, double *, double *, double *, double *);
int /*<<< orphan*/ print_matrix(double *, int, int);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  double A[16] = {1.0, 2.0, 0.0, 0.0, 2.0, 1.0, 0.0, 0.0,
                  0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0};
  double S[16] = {1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
                  0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0};
  double e[4], X[16];
  double MCad_e[4] = {-1, 3, 1, 0.5};
  double MCad_X[16] = {1.0, 1.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0,
                       0.0, 0.0, 1.0, 0.0, 0.0,  0.0, 0.0, 1.0};
  printf("Solving generalized eigen value problem Ax=eSx\n");
  printf("Matrix A = \n");
  print_matrix(A, 4, 4);
  printf("Matrix S = \n");
  print_matrix(S, 4, 4);
  gen_sym_eigen(4, A, S, e, X);
  printf("Lapack Answer -- Eigen Row Vector -------\n");
  printf("Eigen Value = \n");
  print_matrix(e, 1, 4);
  printf("Matrix X = \n");
  print_matrix(X, 4, 4);
  printf("MathCAD14 Answer -- Eigen Column Vector ------\n");
  printf("Eigen Value = \n");
  print_matrix(MCad_e, 1, 4);
  printf("Matrix X = \n");
  print_matrix(MCad_X, 4, 4);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1050 <memset@plt>
movsd  0xe93(%rip),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  0xe93(%rip),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0xe83(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xe66(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xe59(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe4c(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1050 <memset@plt>
movsd  0xe2c(%rip),%xmm0
movsd  %xmm0,-0x110(%rbp)
ff
movsd  0xe1c(%rip),%xmm0
movsd  %xmm0,-0xe8(%rbp)
ff
movsd  0xe0c(%rip),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  0xe0c(%rip),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
mov    0xe0d(%rip),%rax
mov    %rax,-0x1d0(%rbp)
mov    0xe07(%rip),%rax
mov    %rax,-0x1c8(%rbp)
mov    0xe01(%rip),%rax
mov    %rax,-0x1c0(%rbp)
mov    0xdfb(%rip),%rax
mov    %rax,-0x1b8(%rbp)
lea    -0x250(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1050 <memset@plt>
movsd  0xda1(%rip),%xmm0
movsd  %xmm0,-0x250(%rbp)
ff
movsd  0xd91(%rip),%xmm0
movsd  %xmm0,-0x248(%rbp)
ff
movsd  0xd89(%rip),%xmm0
movsd  %xmm0,-0x230(%rbp)
ff
movsd  0xd71(%rip),%xmm0
movsd  %xmm0,-0x228(%rbp)
ff
movsd  0xd61(%rip),%xmm0
movsd  %xmm0,-0x200(%rbp)
ff
movsd  0xd51(%rip),%xmm0
movsd  %xmm0,-0x1d8(%rbp)
ff
lea    0xd82(%rip),%rdi
call   1040 <printf@plt>
lea    0xda6(%rip),%rdi
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    $0x4,%edx
mov    %edx,%esi
call   1060 <print_matrix@plt>
lea    0xd94(%rip),%rdi
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    $0x4,%edx
mov    %edx,%esi
call   1060 <print_matrix@plt>
lea    -0x90(%rbp),%rsi
lea    -0x110(%rbp),%rdx
lea    -0x130(%rbp),%rcx
lea    -0x1b0(%rbp),%r8
mov    $0x4,%edi
call   1030 <gen_sym_eigen@plt>
lea    0xd5c(%rip),%rdi
call   1040 <printf@plt>
lea    0xd7b(%rip),%rdi
call   1040 <printf@plt>
lea    -0x130(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1060 <print_matrix@plt>
lea    0xd69(%rip),%rdi
call   1040 <printf@plt>
lea    -0x1b0(%rbp),%rdi
mov    $0x4,%edx
mov    %edx,%esi
call   1060 <print_matrix@plt>
lea    0xd57(%rip),%rdi
call   1040 <printf@plt>
lea    0xd2e(%rip),%rdi
call   1040 <printf@plt>
lea    -0x1d0(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1060 <print_matrix@plt>
lea    0xd1c(%rip),%rdi
call   1040 <printf@plt>
lea    -0x250(%rbp),%rdi
mov    $0x4,%edx
mov    %edx,%esi
call   1060 <print_matrix@plt>
xor    %eax,%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x248,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x130(%rsp)
movaps 0xe88(%rip),%xmm1
movaps %xmm1,0x120(%rsp)
movaps 0xe89(%rip),%xmm1
movaps %xmm1,0x140(%rsp)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x170(%rsp)
mov    %rax,0x198(%rsp)
movaps %xmm0,(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x10(%rsp)
mov    %rax,(%rsp)
mov    %rax,0x28(%rsp)
mov    %rax,0x50(%rsp)
movabs $0x4000000000000000,%rcx
mov    %rcx,0x78(%rsp)
movaps 0xe5c(%rip),%xmm1
movaps %xmm1,0x90(%rsp)
movaps 0xe3d(%rip),%xmm1
movaps %xmm1,0x80(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps 0xdde(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xddf(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
mov    %rax,0xf0(%rsp)
mov    %rax,0x118(%rsp)
lea    0xdf0(%rip),%rdi
call   1040 <puts@plt>
lea    0xe13(%rip),%rdi
call   1040 <puts@plt>
lea    0x120(%rsp),%r15
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x4,%edx
call   1050 <print_matrix@plt>
lea    0xdf9(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x4,%edx
call   1050 <print_matrix@plt>
lea    0x1a0(%rsp),%r12
lea    0x1c0(%rsp),%r14
mov    $0x4,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r14,%r8
call   1030 <gen_sym_eigen@plt>
lea    0xdbe(%rip),%rdi
call   1040 <puts@plt>
lea    0xe0b(%rip),%r15
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1050 <print_matrix@plt>
lea    0xdf9(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x4,%edx
call   1050 <print_matrix@plt>
lea    0xd9a(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
lea    0x80(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1050 <print_matrix@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xa0(%rsp),%rdi
mov    $0x4,%esi
mov    $0x4,%edx
call   1050 <print_matrix@plt>
xor    %eax,%eax
add    $0x248,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.MCad_e = [4 x double] [double -1.000000e+00, double 3.000000e+00, double 1.000000e+00, double 5.000000e-01]
@.str = [48 x i8] c"Solving generalized eigen value problem Ax=eSx\0A\00"
@.str.1 = [13 x i8] c"Matrix A = \0A\00"
@.str.2 = [13 x i8] c"Matrix S = \0A\00"
@.str.3 = [43 x i8] c"Lapack Answer -- Eigen Row Vector -------\0A\00"
@.str.4 = [16 x i8] c"Eigen Value = \0A\00"
@.str.5 = [13 x i8] c"Matrix X = \0A\00"
@.str.6 = [48 x i8] c"MathCAD14 Answer -- Eigen Column Vector ------\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [16 x double]
%6 = alloca [16 x double]
%7 = alloca [4 x double]
%8 = alloca [16 x double]
%9 = alloca [4 x double]
%10 = alloca [16 x double]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%11 = bitcast [16 x double]* %5 to i8*
%12 = bitcast i8* %11 to [16 x double]*
%13 = getelementptr inbounds [16 x double], [16 x double]* %12, i32 0, i32 0
store double 1.000000e+00, double* %13
%14 = getelementptr inbounds [16 x double], [16 x double]* %12, i32 0, i32 1
store double 2.000000e+00, double* %14
%15 = getelementptr inbounds [16 x double], [16 x double]* %12, i32 0, i32 4
store double 2.000000e+00, double* %15
%16 = getelementptr inbounds [16 x double], [16 x double]* %12, i32 0, i32 5
store double 1.000000e+00, double* %16
%17 = getelementptr inbounds [16 x double], [16 x double]* %12, i32 0, i32 10
store double 1.000000e+00, double* %17
%18 = getelementptr inbounds [16 x double], [16 x double]* %12, i32 0, i32 15
store double 1.000000e+00, double* %18
%19 = bitcast [16 x double]* %6 to i8*
%20 = bitcast i8* %19 to [16 x double]*
%21 = getelementptr inbounds [16 x double], [16 x double]* %20, i32 0, i32 0
store double 1.000000e+00, double* %21
%22 = getelementptr inbounds [16 x double], [16 x double]* %20, i32 0, i32 5
store double 1.000000e+00, double* %22
%23 = getelementptr inbounds [16 x double], [16 x double]* %20, i32 0, i32 10
store double 1.000000e+00, double* %23
%24 = getelementptr inbounds [16 x double], [16 x double]* %20, i32 0, i32 15
store double 2.000000e+00, double* %24
%25 = bitcast [4 x double]* %9 to i8*
%26 = bitcast [16 x double]* %10 to i8*
%27 = bitcast i8* %26 to [16 x double]*
%28 = getelementptr inbounds [16 x double], [16 x double]* %27, i32 0, i32 0
store double 1.000000e+00, double* %28
%29 = getelementptr inbounds [16 x double], [16 x double]* %27, i32 0, i32 1
store double 1.000000e+00, double* %29
%30 = getelementptr inbounds [16 x double], [16 x double]* %27, i32 0, i32 4
store double -1.000000e+00, double* %30
%31 = getelementptr inbounds [16 x double], [16 x double]* %27, i32 0, i32 5
store double 1.000000e+00, double* %31
%32 = getelementptr inbounds [16 x double], [16 x double]* %27, i32 0, i32 10
store double 1.000000e+00, double* %32
%33 = getelementptr inbounds [16 x double], [16 x double]* %27, i32 0, i32 15
store double 1.000000e+00, double* %33
%34 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%35 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%36 = getelementptr inbounds [16 x double], [16 x double]* %5, i64 0, i64 0
%37 = call i32 @print_matrix(double* %36, i32 4, i32 4)
%38 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%39 = getelementptr inbounds [16 x double], [16 x double]* %6, i64 0, i64 0
%40 = call i32 @print_matrix(double* %39, i32 4, i32 4)
%41 = getelementptr inbounds [16 x double], [16 x double]* %5, i64 0, i64 0
%42 = getelementptr inbounds [16 x double], [16 x double]* %6, i64 0, i64 0
%43 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0, i64 0
%44 = getelementptr inbounds [16 x double], [16 x double]* %8, i64 0, i64 0
%45 = call i32 @gen_sym_eigen(i32 4, double* %41, double* %42, double* %43, double* %44)
%46 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%47 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%48 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0, i64 0
%49 = call i32 @print_matrix(double* %48, i32 1, i32 4)
%50 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%51 = getelementptr inbounds [16 x double], [16 x double]* %8, i64 0, i64 0
%52 = call i32 @print_matrix(double* %51, i32 4, i32 4)
%53 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
%54 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%55 = getelementptr inbounds [4 x double], [4 x double]* %9, i64 0, i64 0
%56 = call i32 @print_matrix(double* %55, i32 1, i32 4)
%57 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%58 = getelementptr inbounds [16 x double], [16 x double]* %10, i64 0, i64 0
%59 = call i32 @print_matrix(double* %58, i32 4, i32 4)
ret i32 0
}

LLVM IR (-O2):
@__const.main.MCad_e = [4 x double] [double -1.000000e+00, double 3.000000e+00, double 1.000000e+00, double 5.000000e-01]
@str = [47 x i8] c"Solving generalized eigen value problem Ax=eSx\00"
@str.7 = [12 x i8] c"Matrix A = \00"
@str.8 = [12 x i8] c"Matrix S = \00"
@str.9 = [42 x i8] c"Lapack Answer -- Eigen Row Vector -------\00"
@str.12 = [47 x i8] c"MathCAD14 Answer -- Eigen Column Vector ------\00"
@str.13 = [15 x i8] c"Eigen Value = \00"
@str.14 = [12 x i8] c"Matrix X = \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [16 x double]
%4 = alloca [16 x double]
%5 = alloca [4 x double]
%6 = alloca [16 x double]
%7 = alloca [4 x double]
%8 = alloca [16 x double]
%9 = bitcast [16 x double]* %3 to i8*
%10 = getelementptr inbounds [16 x double], [16 x double]* %3, i64 0, i64 2
%11 = bitcast double* %10 to i8*
%12 = getelementptr inbounds [16 x double], [16 x double]* %3, i64 0, i64 0
%13 = bitcast [16 x double]* %3 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 2.000000e+00>, <2 x double>* %13
%14 = getelementptr inbounds [16 x double], [16 x double]* %3, i64 0, i64 4
%15 = bitcast double* %14 to <2 x double>*
store <2 x double> <double 2.000000e+00, double 1.000000e+00>, <2 x double>* %15
%16 = getelementptr inbounds [16 x double], [16 x double]* %3, i64 0, i64 10
store double 1.000000e+00, double* %16
%17 = getelementptr inbounds [16 x double], [16 x double]* %3, i64 0, i64 15
store double 1.000000e+00, double* %17
%18 = bitcast [16 x double]* %4 to i8*
%19 = getelementptr inbounds [16 x double], [16 x double]* %4, i64 0, i64 0
store double 1.000000e+00, double* %19
%20 = getelementptr inbounds [16 x double], [16 x double]* %4, i64 0, i64 5
store double 1.000000e+00, double* %20
%21 = getelementptr inbounds [16 x double], [16 x double]* %4, i64 0, i64 10
store double 1.000000e+00, double* %21
%22 = getelementptr inbounds [16 x double], [16 x double]* %4, i64 0, i64 15
store double 2.000000e+00, double* %22
%23 = bitcast [4 x double]* %5 to i8*
%24 = bitcast [16 x double]* %6 to i8*
%25 = bitcast [4 x double]* %7 to i8*
%26 = bitcast [16 x double]* %8 to i8*
%27 = getelementptr inbounds [16 x double], [16 x double]* %8, i64 0, i64 2
%28 = bitcast double* %27 to i8*
%29 = getelementptr inbounds [16 x double], [16 x double]* %8, i64 0, i64 0
%30 = bitcast [16 x double]* %8 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %30
%31 = getelementptr inbounds [16 x double], [16 x double]* %8, i64 0, i64 4
%32 = bitcast double* %31 to <2 x double>*
store <2 x double> <double -1.000000e+00, double 1.000000e+00>, <2 x double>* %32
%33 = getelementptr inbounds [16 x double], [16 x double]* %8, i64 0, i64 10
store double 1.000000e+00, double* %33
%34 = getelementptr inbounds [16 x double], [16 x double]* %8, i64 0, i64 15
store double 1.000000e+00, double* %34
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.7, i64 0, i64 0))
%37 = call i32 @print_matrix(double* %12, i32 4, i32 4)
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0))
%39 = call i32 @print_matrix(double* %19, i32 4, i32 4)
%40 = getelementptr inbounds [4 x double], [4 x double]* %5, i64 0, i64 0
%41 = getelementptr inbounds [16 x double], [16 x double]* %6, i64 0, i64 0
%42 = call i32 @gen_sym_eigen(i32 4, double* %12, double* %19, double* %40, double* %41)
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.9, i64 0, i64 0))
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.13, i64 0, i64 0))
%45 = call i32 @print_matrix(double* %40, i32 1, i32 4)
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.14, i64 0, i64 0))
%47 = call i32 @print_matrix(double* %41, i32 4, i32 4)
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.12, i64 0, i64 0))
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.13, i64 0, i64 0))
%50 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0, i64 0
%51 = call i32 @print_matrix(double* %50, i32 1, i32 4)
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.14, i64 0, i64 0))
%53 = call i32 @print_matrix(double* %29, i32 4, i32 4)
ret i32 0
}