#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*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ free(double *);
double *malloc(int);
int /*<<< orphan*/ stderr;
void dgeev_wrap(int n, const double *a, double *wr, double *wi, double *v) {
  char jobvl = 'N';
  char jobvr = 'V';
  int lda;
  int ldvl;
  int ldvr;
  int lwork;
  int info;
  double *vl;
  double *work;
  double *aa;
  int i, j;
  lda = n;
  ldvl = 1;
  ldvr = n;
  lwork = 4 * n;
  aa = malloc(sizeof(double) * n * n);
  vl = malloc(sizeof(double) * ldvl * n);
  work = malloc(sizeof(double) * lwork);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      aa[i * n + j] = a[j * n + i];
    }
  }
  dgeev_(&jobvl, &jobvr, &n, aa, &lda, wr, wi, vl, &ldvl, v, &ldvr, work,
         &lwork, &info);
  if (info != 0) {
    fprintf(stderr, "info = %d\n", info);
  }
  free(aa);
  free(vl);
  free(work);
}


x86 assembly (clang, -O0):
<dgeev_wrap>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %edi,-0x2c(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    %rcx,-0x48(%rbp)
mov    %r8,-0x50(%rbp)
movb   $0x4e,-0x51(%rbp)
movb   $0x56,-0x52(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x58(%rbp)
movl   $0x1,-0x5c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x2c(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x64(%rbp)
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
movslq -0x2c(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x80(%rbp)
movslq -0x5c(%rbp),%rax
shl    $0x3,%rax
movslq -0x2c(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x70(%rbp)
movslq -0x64(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x78(%rbp)
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    126b <dgeev_wrap+0x12b>
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1252 <dgeev_wrap+0x112>
mov    -0x38(%rbp),%rax
mov    -0x88(%rbp),%ecx
imul   -0x2c(%rbp),%ecx
add    -0x84(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x80(%rbp),%rax
mov    -0x84(%rbp),%ecx
imul   -0x2c(%rbp),%ecx
add    -0x88(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    11f7 <dgeev_wrap+0xb7>
jmp    1257 <dgeev_wrap+0x117>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11de <dgeev_wrap+0x9e>
mov    -0x80(%rbp),%rcx
mov    -0x40(%rbp),%r9
mov    -0x48(%rbp),%r13
mov    -0x70(%rbp),%r12
mov    -0x50(%rbp),%r14
mov    -0x78(%rbp),%r11
lea    -0x51(%rbp),%rdi
lea    -0x52(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x58(%rbp),%r8
lea    -0x5c(%rbp),%r15
lea    -0x60(%rbp),%rbx
lea    -0x64(%rbp),%r10
lea    -0x68(%rbp),%rax
mov    %r13,(%rsp)
mov    %r12,0x8(%rsp)
mov    %r15,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>
cmpl   $0x0,-0x68(%rbp)
je     12f1 <dgeev_wrap+0x1b1>
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
mov    -0x68(%rbp),%edx
lea    0xd14(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x80(%rbp),%rdi
call   1030 <free@plt>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<dgeev_wrap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r8,0x30(%rsp)
mov    %rcx,0x40(%rsp)
mov    %rdx,0x28(%rsp)
mov    %rsi,%r14
mov    %edi,%r12d
mov    %edi,0x24(%rsp)
movb   $0x4e,0xf(%rsp)
movb   $0x56,0xe(%rsp)
mov    %edi,0x20(%rsp)
movl   $0x1,0x1c(%rsp)
mov    %edi,0x18(%rsp)
lea    0x0(,%r12,4),%eax
mov    %eax,0x14(%rsp)
lea    0x0(,%r12,8),%ebp
mov    %ebp,%edi
imul   %r12d,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,0x38(%rsp)
mov    %r12d,%edi
shl    $0x5,%edi
call   1060 <malloc@plt>
mov    %rax,%r13
test   %r12d,%r12d
jle    1268 <dgeev_wrap+0x128>
mov    %r12d,%r8d
mov    %r8d,%ecx
and    $0xfffffffe,%ecx
lea    0x0(,%r8,8),%rdx
mov    %r8,%rsi
shl    $0x4,%rsi
mov    %r15,%rdi
add    $0x8,%rdi
xor    %r10d,%r10d
mov    %r14,%r9
jmp    1200 <dgeev_wrap+0xc0>
nopl   (%rax)
add    $0x1,%r10
add    $0x8,%r9
add    %rdx,%rdi
cmp    %r8,%r10
je     1268 <dgeev_wrap+0x128>
cmp    $0x1,%r12d
jne    1210 <dgeev_wrap+0xd0>
xor    %ebp,%ebp
jmp    1240 <dgeev_wrap+0x100>
nopw   0x0(%rax,%rax,1)
mov    %r9,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rbx),%xmm0
movsd  %xmm0,-0x8(%rdi,%rbp,8)
movsd  (%rbx,%rdx,1),%xmm0
movsd  %xmm0,(%rdi,%rbp,8)
add    $0x2,%rbp
add    %rsi,%rbx
cmp    %rbp,%rcx
jne    1220 <dgeev_wrap+0xe0>
test   $0x1,%r8b
je     11f0 <dgeev_wrap+0xb0>
mov    %r10,%rbx
imul   %r8,%rbx
mov    %rbp,%rax
imul   %r8,%rax
add    %r10,%rax
movsd  (%r14,%rax,8),%xmm0
add    %rbp,%rbx
movsd  %xmm0,(%r15,%rbx,8)
jmp    11f0 <dgeev_wrap+0xb0>
lea    0x10(%rsp),%rax
lea    0x14(%rsp),%rbp
lea    0x18(%rsp),%rbx
lea    0x1c(%rsp),%r10
lea    0xf(%rsp),%rdi
lea    0xe(%rsp),%rsi
lea    0x24(%rsp),%rdx
lea    0x20(%rsp),%r8
mov    %r15,%rcx
mov    0x28(%rsp),%r9
push   %rax
push   %rbp
push   %r13
push   %rbx
push   0x50(%rsp)
push   %r10
mov    0x68(%rsp),%rbx
push   %rbx
push   0x78(%rsp)
call   1040 <dgeev_@plt>
add    $0x40,%rsp
mov    0x10(%rsp),%edx
test   %edx,%edx
je     12d3 <dgeev_wrap+0x193>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
lea    0xd32(%rip),%rsi
call   1050 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [11 x i8] c"info = %d\0A\00"
define void @dgeev_wrap(i32 %0, double* %1, double* %2, double* %3, double* %4) {
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca i8
%12 = alloca i8
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca double*
%19 = alloca double*
%20 = alloca double*
%21 = alloca i32
%22 = alloca i32
store i32 %0, i32* %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
store i8 78, i8* %11
store i8 86, i8* %12
%23 = load i32, i32* %6
store i32 %23, i32* %13
store i32 1, i32* %14
%24 = load i32, i32* %6
store i32 %24, i32* %15
%25 = load i32, i32* %6
%26 = mul nsw i32 4, %25
store i32 %26, i32* %16
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = mul i64 8, %28
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = mul i64 %29, %31
%33 = trunc i64 %32 to i32
%34 = call double* @malloc(i32 %33)
store double* %34, double** %20
%35 = load i32, i32* %14
%36 = sext i32 %35 to i64
%37 = mul i64 8, %36
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = mul i64 %37, %39
%41 = trunc i64 %40 to i32
%42 = call double* @malloc(i32 %41)
store double* %42, double** %18
%43 = load i32, i32* %16
%44 = sext i32 %43 to i64
%45 = mul i64 8, %44
%46 = trunc i64 %45 to i32
%47 = call double* @malloc(i32 %46)
store double* %47, double** %19
store i32 0, i32* %21
br label %48
48: ; preds = %79, %5
%49 = load i32, i32* %21
%50 = load i32, i32* %6
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %82
52: ; preds = %48
store i32 0, i32* %22
br label %53
53: ; preds = %75, %52
%54 = load i32, i32* %22
%55 = load i32, i32* %6
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %78
57: ; preds = %53
%58 = load double*, double** %7
%59 = load i32, i32* %22
%60 = load i32, i32* %6
%61 = mul nsw i32 %59, %60
%62 = load i32, i32* %21
%63 = add nsw i32 %61, %62
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %58, i64 %64
%66 = load double, double* %65
%67 = load double*, double** %20
%68 = load i32, i32* %21
%69 = load i32, i32* %6
%70 = mul nsw i32 %68, %69
%71 = load i32, i32* %22
%72 = add nsw i32 %70, %71
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %67, i64 %73
store double %66, double* %74
br label %75
75: ; preds = %57
%76 = load i32, i32* %22
%77 = add nsw i32 %76, 1
store i32 %77, i32* %22
br label %53
78: ; preds = %53
br label %79
79: ; preds = %78
%80 = load i32, i32* %21
%81 = add nsw i32 %80, 1
store i32 %81, i32* %21
br label %48
82: ; preds = %48
%83 = load double*, double** %20
%84 = load double*, double** %8
%85 = load double*, double** %9
%86 = load double*, double** %18
%87 = load double*, double** %10
%88 = load double*, double** %19
%89 = call i32 @dgeev_(i8* %11, i8* %12, i32* %6, double* %83, i32* %13, double* %84, double* %85, double* %86, i32* %14, double* %87, i32* %15, double* %88, i32* %16, i32* %17)
%90 = load i32, i32* %17
%91 = icmp ne i32 %90, 0
br i1 %91, label %92, label %96
92: ; preds = %82
%93 = load i32, i32* @stderr
%94 = load i32, i32* %17
%95 = call i32 @fprintf(i32 %93, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %94)
br label %96
96: ; preds = %92, %82
%97 = load double*, double** %20
%98 = call i32 @free(double* %97)
%99 = load double*, double** %18
%100 = call i32 @free(double* %99)
%101 = load double*, double** %19
%102 = call i32 @free(double* %101)
ret void
}

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