#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*/ dgeev_(char *, char *, int *, double *, int *, double *,
                          double *, double *, int *, double *, int *, double *,
                          int *, int *);
int /*<<< orphan*/ free(void *);
scalar_t__ malloc(int);
int eigen_double(int n, double *a, double *out) {
  int j;
  int info, lwork;
  double wkopt;
  double *work;
  double wr[n], wi[n], vl[n * n], vr[n * n];
  lwork = -1;
  dgeev_("Vectors", "Vectors", &n, a, &n, wr, wi, vl, &n, vr, &n, &wkopt,
         &lwork, &info);
  lwork = (int)wkopt;
  work = (double *)malloc(lwork * sizeof(double));
  dgeev_("Vectors", "Vectors", &n, a, &n, wr, wi, vl, &n, vr, &n, work, &lwork,
         &info);
  free((void *)work);
  for (j = 0; j < n; j++) {
    if (wi[j] == (double)0.0) {
      out[j] = wr[j];
    } else {
      out[j] = (double)(1.0 / 0.0);
    }
  }
  if (info > 0) {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<eigen_double>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %edi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
mov    -0x28(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x60(%rbp)
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%r9
sub    %rcx,%r9
mov    %r9,-0x90(%rbp)
mov    %r9,%rsp
mov    %rax,-0x68(%rbp)
mov    -0x28(%rbp),%eax
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%r12
sub    %rcx,%r12
mov    %r12,-0x98(%rbp)
mov    %r12,%rsp
mov    %rax,-0x70(%rbp)
mov    -0x28(%rbp),%eax
imul   %eax,%eax
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%r15
sub    %rcx,%r15
mov    %r15,%rsp
mov    %rax,-0x78(%rbp)
mov    -0x28(%rbp),%eax
imul   %eax,%eax
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%r14
sub    %rcx,%r14
mov    %r14,%rsp
mov    %rax,-0x80(%rbp)
movl   $0xffffffff,-0x44(%rbp)
mov    -0x30(%rbp),%rcx
lea    0xe1e(%rip),%rsi
lea    -0x28(%rbp),%rbx
lea    -0x50(%rbp),%r11
lea    -0x44(%rbp),%r10
lea    -0x40(%rbp),%rax
sub    $0x40,%rsp
mov    %rsi,%rdi
mov    %rbx,%rdx
mov    %rbx,%r8
mov    %r12,(%rsp)
mov    %r15,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11,0x28(%rsp)
mov    %r10,0x30(%rsp)
mov    %rax,0x38(%rsp)
call   1040 <dgeev_@plt>
add    $0x40,%rsp
cvttsd2si -0x50(%rbp),%eax
mov    %eax,-0x44(%rbp)
movslq -0x44(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    -0x90(%rbp),%r9
mov    %rax,-0x58(%rbp)
mov    -0x30(%rbp),%rcx
mov    -0x58(%rbp),%r11
lea    0xda0(%rip),%rsi
lea    -0x28(%rbp),%rbx
lea    -0x44(%rbp),%r10
lea    -0x40(%rbp),%rax
sub    $0x40,%rsp
mov    %rsi,%rdi
mov    %rbx,%rdx
mov    %rbx,%r8
mov    %r12,(%rsp)
mov    %r15,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11,0x28(%rsp)
mov    %r10,0x30(%rsp)
mov    %rax,0x38(%rsp)
call   1040 <dgeev_@plt>
add    $0x40,%rsp
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    133a <eigen_double+0x20a>
mov    -0x98(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1312 <eigen_double+0x1e2>
jp     1312 <eigen_double+0x1e2>
mov    -0x90(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1327 <eigen_double+0x1f7>
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  0xcde(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    132c <eigen_double+0x1fc>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12c1 <eigen_double+0x191>
cmpl   $0x0,-0x40(%rbp)
jle    135a <eigen_double+0x22a>
movl   $0x1,-0x24(%rbp)
movl   $0x1,-0x84(%rbp)
jmp    136b <eigen_double+0x23b>
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x84(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,%rsp
mov    -0x24(%rbp),%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<eigen_double>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%rbx
mov    %rsi,%rcx
mov    %rsi,-0x48(%rbp)
mov    %rsp,-0x50(%rbp)
mov    %edi,-0x30(%rbp)
mov    %edi,%eax
mov    %rsp,%r14
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    %rsp,%r13
sub    %rax,%r13
mov    %r13,%rsp
imul   %edi,%edi
mov    %rsp,%r15
lea    0xf(,%rdi,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%r12
sub    %rax,%r12
mov    %r12,%rsp
movl   $0xffffffff,-0x2c(%rbp)
lea    -0x34(%rbp),%rax
lea    -0x2c(%rbp),%r11
lea    -0x58(%rbp),%r10
lea    -0x30(%rbp),%rdx
lea    0xe57(%rip),%rdi
mov    %rdi,%rsi
mov    %rdx,%r8
mov    %r14,%r9
push   %rax
push   %r11
push   %r10
push   %rdx
push   %r12
push   %rdx
push   %r15
push   %r13
call   1040 <dgeev_@plt>
add    $0x40,%rsp
cvttsd2si -0x58(%rbp),%edi
mov    %edi,-0x2c(%rbp)
shl    $0x3,%edi
call   1050 <malloc@plt>
mov    %rax,%r10
mov    %rax,-0x40(%rbp)
lea    0xe1a(%rip),%rdi
mov    %rdi,%rsi
lea    -0x30(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    %rdx,%r8
mov    %r14,%r9
lea    -0x34(%rbp),%rax
push   %rax
lea    -0x2c(%rbp),%rax
push   %rax
push   %r10
push   %rdx
push   %r12
push   %rdx
push   %r15
push   %r13
call   1040 <dgeev_@plt>
add    $0x40,%rsp
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%ecx
test   %ecx,%ecx
jle    12c4 <eigen_double+0x194>
cmp    $0x1,%ecx
jne    125b <eigen_double+0x12b>
xor    %eax,%eax
test   $0x1,%cl
je     12c4 <eigen_double+0x194>
movsd  0x0(%r13,%rax,8),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12b7 <eigen_double+0x187>
jp     12b7 <eigen_double+0x187>
movsd  (%r14,%rax,8),%xmm0
jmp    12bf <eigen_double+0x18f>
mov    %ecx,%edx
and    $0xfffffffe,%edx
xor    %eax,%eax
movsd  0xd96(%rip),%xmm0
xorpd  %xmm1,%xmm1
jmp    127f <eigen_double+0x14f>
movsd  %xmm2,0x8(%rbx,%rax,8)
add    $0x2,%rax
cmp    %rax,%rdx
je     1237 <eigen_double+0x107>
movsd  0x0(%r13,%rax,8),%xmm2
ucomisd %xmm1,%xmm2
movaps %xmm0,%xmm2
jne    1297 <eigen_double+0x167>
jp     1297 <eigen_double+0x167>
movsd  (%r14,%rax,8),%xmm2
movsd  %xmm2,(%rbx,%rax,8)
movsd  0x8(%r13,%rax,8),%xmm2
ucomisd %xmm1,%xmm2
movaps %xmm0,%xmm2
jne    1270 <eigen_double+0x140>
jp     1270 <eigen_double+0x140>
movsd  0x8(%r14,%rax,8),%xmm2
jmp    1270 <eigen_double+0x140>
movsd  0xd41(%rip),%xmm0
movsd  %xmm0,(%rbx,%rax,8)
xor    %eax,%eax
cmpl   $0x0,-0x34(%rbp)
setg   %al
mov    -0x50(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Vectors\00"
define i32 @eigen_double(i32 %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
%18 = alloca i32
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
%19 = load i32, i32* %5
%20 = zext i32 %19 to i64
%21 = call i8* @llvm.stacksave()
store i8* %21, i8** %13
%22 = alloca double, i64 %20
store i64 %20, i64* %14
%23 = load i32, i32* %5
%24 = zext i32 %23 to i64
%25 = alloca double, i64 %24
store i64 %24, i64* %15
%26 = load i32, i32* %5
%27 = load i32, i32* %5
%28 = mul nsw i32 %26, %27
%29 = zext i32 %28 to i64
%30 = alloca double, i64 %29
store i64 %29, i64* %16
%31 = load i32, i32* %5
%32 = load i32, i32* %5
%33 = mul nsw i32 %31, %32
%34 = zext i32 %33 to i64
%35 = alloca double, i64 %34
store i64 %34, i64* %17
store i32 -1, i32* %10
%36 = load double*, double** %6
%37 = call i32 @dgeev_(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %5, double* %36, i32* %5, double* %22, double* %25, double* %30, i32* %5, double* %35, i32* %5, double* %11, i32* %10, i32* %9)
%38 = load double, double* %11
%39 = fptosi double %38 to i32
store i32 %39, i32* %10
%40 = load i32, i32* %10
%41 = sext i32 %40 to i64
%42 = mul i64 %41, 8
%43 = trunc i64 %42 to i32
%44 = call i64 @malloc(i32 %43)
%45 = inttoptr i64 %44 to double*
store double* %45, double** %12
%46 = load double*, double** %6
%47 = load double*, double** %12
%48 = call i32 @dgeev_(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %5, double* %46, i32* %5, double* %22, double* %25, double* %30, i32* %5, double* %35, i32* %5, double* %47, i32* %10, i32* %9)
%49 = load double*, double** %12
%50 = bitcast double* %49 to i8*
%51 = call i32 @free(i8* %50)
store i32 0, i32* %8
br label %52
52: ; preds = %77, %3
%53 = load i32, i32* %8
%54 = load i32, i32* %5
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %80
56: ; preds = %52
%57 = load i32, i32* %8
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %25, i64 %58
%60 = load double, double* %59
%61 = fcmp oeq double %60, 0.000000e+00
br i1 %61, label %62, label %71
62: ; preds = %56
%63 = load i32, i32* %8
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %22, i64 %64
%66 = load double, double* %65
%67 = load double*, double** %7
%68 = load i32, i32* %8
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double, double* %67, i64 %69
store double %66, double* %70
br label %76
71: ; preds = %56
%72 = load double*, double** %7
%73 = load i32, i32* %8
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %72, i64 %74
store double 0x7FF0000000000000, double* %75
br label %76
76: ; preds = %71, %62
br label %77
77: ; preds = %76
%78 = load i32, i32* %8
%79 = add nsw i32 %78, 1
store i32 %79, i32* %8
br label %52
80: ; preds = %52
%81 = load i32, i32* %9
%82 = icmp sgt i32 %81, 0
br i1 %82, label %83, label %84
83: ; preds = %80
store i32 1, i32* %4
store i32 1, i32* %18
br label %85
84: ; preds = %80
store i32 0, i32* %4
store i32 1, i32* %18
br label %85
85: ; preds = %84, %83
%86 = load i8*, i8** %13
%87 = load i32, i32* %4
ret i32 %87
}

LLVM IR (-O2):
@.str = [8 x i8] c"Vectors\00"
define i32 @eigen_double(i32 %0, double* %1, double* nocapture writeonly %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store i32 %0, i32* %4
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = bitcast double* %7 to i8*
%11 = zext i32 %0 to i64
%12 = tail call i8* @llvm.stacksave()
%13 = alloca double, i64 %11
%14 = alloca double, i64 %11
%15 = mul nsw i32 %0, %0
%16 = zext i32 %15 to i64
%17 = alloca double, i64 %16
%18 = alloca double, i64 %16
store i32 -1, i32* %6
%19 = call i32 @dgeev_(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %4, double* %1, i32* %4, double* %13, double* %14, double* %17, i32* %4, double* %18, i32* %4, double* %7, i32* %6, i32* %5)
%20 = load double, double* %7
%21 = fptosi double %20 to i32
store i32 %21, i32* %6
%22 = shl i32 %21, 3
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to double*
%25 = call i32 @dgeev_(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %4, double* %1, i32* %4, double* %13, double* %14, double* %17, i32* %4, double* %18, i32* %4, double* %24, i32* %6, i32* %5)
%26 = inttoptr i64 %23 to i8*
%27 = call i32 @free(i8* %26)
%28 = load i32, i32* %4
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %74
30: ; preds = %3
%31 = zext i32 %28 to i64
%32 = and i64 %31, 1
%33 = icmp eq i32 %28, 1
br i1 %33, label %61, label %34
34: ; preds = %30
%35 = and i64 %31, 4294967294
br label %36
36: ; preds = %55, %34
%37 = phi i64 [ 0, %34 ], [ %58, %55 ]
%38 = phi i64 [ 0, %34 ], [ %59, %55 ]
%39 = getelementptr inbounds double, double* %14, i64 %37
%40 = load double, double* %39
%41 = fcmp oeq double %40, 0.000000e+00
br i1 %41, label %42, label %45
42: ; preds = %36
%43 = getelementptr inbounds double, double* %13, i64 %37
%44 = load double, double* %43
br label %45
45: ; preds = %36, %42
%46 = phi double [ %44, %42 ], [ 0x7FF0000000000000, %36 ]
%47 = getelementptr inbounds double, double* %2, i64 %37
store double %46, double* %47
%48 = or i64 %37, 1
%49 = getelementptr inbounds double, double* %14, i64 %48
%50 = load double, double* %49
%51 = fcmp oeq double %50, 0.000000e+00
br i1 %51, label %52, label %55
52: ; preds = %45
%53 = getelementptr inbounds double, double* %13, i64 %48
%54 = load double, double* %53
br label %55
55: ; preds = %52, %45
%56 = phi double [ %54, %52 ], [ 0x7FF0000000000000, %45 ]
%57 = getelementptr inbounds double, double* %2, i64 %48
store double %56, double* %57
%58 = add nuw nsw i64 %37, 2
%59 = add i64 %38, 2
%60 = icmp eq i64 %59, %35
br i1 %60, label %61, label %36
61: ; preds = %55, %30
%62 = phi i64 [ 0, %30 ], [ %58, %55 ]
%63 = icmp eq i64 %32, 0
br i1 %63, label %74, label %64
64: ; preds = %61
%65 = getelementptr inbounds double, double* %14, i64 %62
%66 = load double, double* %65
%67 = fcmp oeq double %66, 0.000000e+00
br i1 %67, label %68, label %71
68: ; preds = %64
%69 = getelementptr inbounds double, double* %13, i64 %62
%70 = load double, double* %69
br label %71
71: ; preds = %68, %64
%72 = phi double [ %70, %68 ], [ 0x7FF0000000000000, %64 ]
%73 = getelementptr inbounds double, double* %2, i64 %62
store double %72, double* %73
br label %74
74: ; preds = %71, %61, %3
%75 = load i32, i32* %5
%76 = icmp sgt i32 %75, 0
%77 = zext i1 %76 to i32
ret i32 %77
}