#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*/ assert(int);
int dspgeig(int *, char *, char *, char *, int *, double *, double *, double *,
            double *, int *, int *, int *, double *, double *, int *);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ init_sym_matrix_packed(double *, int);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  int i, j, k, info;
  int n = 100;
  int size = (n * (n + 1)) / 2;
  double *AP, *BP, *W, *Z;
  double vl, vu;
  int il, iu;
  int m;
  int itype;
  int ldz = n;
  AP = (double *)malloc((size_t)size * sizeof(double));
  assert(AP != NULL);
  BP = (double *)malloc((size_t)size * sizeof(double));
  assert(BP != NULL);
  W = (double *)malloc((size_t)n * sizeof(double));
  assert(W != NULL);
  Z = (double *)malloc((size_t)n * n * sizeof(double));
  assert(Z != NULL);
  init_sym_matrix_packed(AP, n);
  init_sym_matrix_packed(BP, n);
  k = 0;
  for (j = 0; j < n; j++)
    for (i = 0; i <= j; i++) {
      if (i == j)
        BP[k] += n;
      k++;
    }
  itype = 1;
  info = dspgeig(&itype, "Vectors", "All", "Upper", &n, AP, BP, &vl, &vu, &il,
                 &iu, &m, W, Z, &ldz);
  assert(info == 0);
  printf("Successfully computed eigenpairs!\n");
  free(AP);
  free(BP);
  free(Z);
  free(W);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
movl   $0x0,-0x2c(%rbp)
mov    %edi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
movl   $0x64,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0x4c(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x50(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x94(%rbp)
movslq -0x50(%rbp),%rdi
shl    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movslq -0x50(%rbp),%rdi
shl    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movslq -0x4c(%rbp),%rdi
shl    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movslq -0x4c(%rbp),%rdi
movslq -0x4c(%rbp),%rax
imul   %rax,%rdi
shl    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x58(%rbp),%rdi
mov    -0x4c(%rbp),%esi
call   1070 <init_sym_matrix_packed@plt>
mov    -0x60(%rbp),%rdi
mov    -0x4c(%rbp),%esi
call   1070 <init_sym_matrix_packed@plt>
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    12cf <main+0x16f>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x40(%rbp),%eax
jg     12bc <main+0x15c>
mov    -0x3c(%rbp),%eax
cmp    -0x40(%rbp),%eax
jne    12a5 <main+0x145>
cvtsi2sdl -0x4c(%rbp),%xmm0
mov    -0x60(%rbp),%rax
movslq -0x44(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1276 <main+0x116>
jmp    12c1 <main+0x161>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1263 <main+0x103>
movl   $0x1,-0x90(%rbp)
mov    -0x58(%rbp),%r9
mov    -0x60(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x68(%rbp),%r11
mov    -0x70(%rbp),%r10
lea    -0x90(%rbp),%rdi
lea    0xd02(%rip),%rsi
lea    0xd03(%rip),%rdx
lea    0xd00(%rip),%rcx
lea    -0x4c(%rbp),%r8
lea    -0x78(%rbp),%r13
lea    -0x80(%rbp),%r12
lea    -0x84(%rbp),%r15
lea    -0x88(%rbp),%r14
lea    -0x8c(%rbp),%rbx
lea    -0x94(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0xa8(%rbp),%rax
mov    %rax,(%rsp)
mov    -0xa0(%rbp),%rax
mov    %r13,0x8(%rsp)
mov    %r12,0x10(%rsp)
mov    %r15,0x18(%rsp)
mov    %r14,0x20(%rsp)
mov    %rbx,0x28(%rsp)
mov    %r11,0x30(%rsp)
mov    %r10,0x38(%rsp)
mov    %rax,0x40(%rsp)
call   1080 <dspgeig@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xc7d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movl   $0x64,0x8(%rsp)
movl   $0x64,(%rsp)
mov    $0x9dd0,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x9dd0,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x320,%edi
call   1060 <malloc@plt>
xor    %edi,%edi
mov    %rax,%r12
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x13880,%edi
call   1060 <malloc@plt>
xor    %edi,%edi
mov    %rax,%r15
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    %r14,%rdi
mov    $0x64,%esi
call   1070 <init_sym_matrix_packed@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <init_sym_matrix_packed@plt>
xor    %eax,%eax
mov    $0x1,%r8d
movsd  0xded(%rip),%xmm0
xor    %edx,%edx
jmp    1234 <main+0xd4>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rdx
add    $0x1,%eax
add    $0x1,%r8d
cmp    $0x64,%eax
je     12c7 <main+0x167>
movslq %edx,%rdx
test   %eax,%eax
je     12a0 <main+0x140>
mov    %r8d,%edi
and    $0xfffffffe,%edi
xor    %ecx,%ecx
jmp    125b <main+0xfb>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x2,%rdx
add    $0x1,%ecx
cmp    %edi,%ecx
je     1290 <main+0x130>
mov    %ecx,%esi
cmp    %ecx,%eax
jne    126f <main+0x10f>
movsd  (%rbx,%rdx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx,%rdx,8)
lea    0x1(%rsi),%ecx
cmp    %eax,%ecx
jne    1250 <main+0xf0>
movsd  0x8(%rbx,%rdx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rbx,%rdx,8)
jmp    1250 <main+0xf0>
nopl   0x0(%rax,%rax,1)
add    $0x2,%esi
test   $0x1,%r8b
je     1224 <main+0xc4>
jmp    12ac <main+0x14c>
nopl   0x0(%rax,%rax,1)
xor    %esi,%esi
test   $0x1,%r8b
je     1224 <main+0xc4>
cmp    %eax,%esi
jne    1220 <main+0xc0>
movsd  (%rbx,%rdx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx,%rdx,8)
jmp    1220 <main+0xc0>
movl   $0x1,0x4(%rsp)
sub    $0x8,%rsp
lea    0x8(%rsp),%rax
lea    0x14(%rsp),%r10
lea    0x18(%rsp),%r11
lea    0x1c(%rsp),%r13
lea    0x20(%rsp),%rbp
lea    0xd15(%rip),%rsi
lea    0xd16(%rip),%rdx
lea    0xd13(%rip),%rcx
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%r8
mov    %r14,%r9
push   %rax
push   %r15
push   %r12
push   %r10
push   %r11
push   %r13
push   %rbp
lea    0x60(%rsp),%rax
push   %rax
push   %rbx
call   1080 <dspgeig@plt>
add    $0x50,%rsp
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
lea    0xcdc(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Vectors\00"
@.str.1 = [4 x i8] c"All\00"
@.str.2 = [6 x i8] c"Upper\00"
@.str.3 = [35 x i8] c"Successfully computed eigenpairs!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double
%17 = alloca double
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 100, i32* %10
%23 = load i32, i32* %10
%24 = load i32, i32* %10
%25 = add nsw i32 %24, 1
%26 = mul nsw i32 %23, %25
%27 = sdiv i32 %26, 2
store i32 %27, i32* %11
%28 = load i32, i32* %10
store i32 %28, i32* %22
%29 = load i32, i32* %11
%30 = sext i32 %29 to i64
%31 = mul i64 %30, 8
%32 = call i64 @malloc(i64 %31)
%33 = inttoptr i64 %32 to double*
store double* %33, double** %12
%34 = load double*, double** %12
%35 = icmp ne double* %34, null
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i32, i32* %11
%39 = sext i32 %38 to i64
%40 = mul i64 %39, 8
%41 = call i64 @malloc(i64 %40)
%42 = inttoptr i64 %41 to double*
store double* %42, double** %13
%43 = load double*, double** %13
%44 = icmp ne double* %43, null
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
%47 = load i32, i32* %10
%48 = sext i32 %47 to i64
%49 = mul i64 %48, 8
%50 = call i64 @malloc(i64 %49)
%51 = inttoptr i64 %50 to double*
store double* %51, double** %14
%52 = load double*, double** %14
%53 = icmp ne double* %52, null
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
%56 = load i32, i32* %10
%57 = sext i32 %56 to i64
%58 = load i32, i32* %10
%59 = sext i32 %58 to i64
%60 = mul i64 %57, %59
%61 = mul i64 %60, 8
%62 = call i64 @malloc(i64 %61)
%63 = inttoptr i64 %62 to double*
store double* %63, double** %15
%64 = load double*, double** %15
%65 = icmp ne double* %64, null
%66 = zext i1 %65 to i32
%67 = call i32 @assert(i32 %66)
%68 = load double*, double** %12
%69 = load i32, i32* %10
%70 = call i32 @init_sym_matrix_packed(double* %68, i32 %69)
%71 = load double*, double** %13
%72 = load i32, i32* %10
%73 = call i32 @init_sym_matrix_packed(double* %71, i32 %72)
store i32 0, i32* %8
store i32 0, i32* %7
br label %74
74: ; preds = %103, %2
%75 = load i32, i32* %7
%76 = load i32, i32* %10
%77 = icmp slt i32 %75, %76
br i1 %77, label %78, label %106
78: ; preds = %74
store i32 0, i32* %6
br label %79
79: ; preds = %99, %78
%80 = load i32, i32* %6
%81 = load i32, i32* %7
%82 = icmp sle i32 %80, %81
br i1 %82, label %83, label %102
83: ; preds = %79
%84 = load i32, i32* %6
%85 = load i32, i32* %7
%86 = icmp eq i32 %84, %85
br i1 %86, label %87, label %96
87: ; preds = %83
%88 = load i32, i32* %10
%89 = sitofp i32 %88 to double
%90 = load double*, double** %13
%91 = load i32, i32* %8
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds double, double* %90, i64 %92
%94 = load double, double* %93
%95 = fadd double %94, %89
store double %95, double* %93
br label %96
96: ; preds = %87, %83
%97 = load i32, i32* %8
%98 = add nsw i32 %97, 1
store i32 %98, i32* %8
br label %99
99: ; preds = %96
%100 = load i32, i32* %6
%101 = add nsw i32 %100, 1
store i32 %101, i32* %6
br label %79
102: ; preds = %79
br label %103
103: ; preds = %102
%104 = load i32, i32* %7
%105 = add nsw i32 %104, 1
store i32 %105, i32* %7
br label %74
106: ; preds = %74
store i32 1, i32* %21
%107 = load double*, double** %12
%108 = load double*, double** %13
%109 = load double*, double** %14
%110 = load double*, double** %15
%111 = call i32 @dspgeig(i32* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %10, double* %107, double* %108, double* %16, double* %17, i32* %18, i32* %19, i32* %20, double* %109, double* %110, i32* %22)
store i32 %111, i32* %9
%112 = load i32, i32* %9
%113 = icmp eq i32 %112, 0
%114 = zext i1 %113 to i32
%115 = call i32 @assert(i32 %114)
%116 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%117 = load double*, double** %12
%118 = call i32 @free(double* %117)
%119 = load double*, double** %13
%120 = call i32 @free(double* %119)
%121 = load double*, double** %15
%122 = call i32 @free(double* %121)
%123 = load double*, double** %14
%124 = call i32 @free(double* %123)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"Vectors\00"
@.str.1 = [4 x i8] c"All\00"
@.str.2 = [6 x i8] c"Upper\00"
@str = [34 x i8] c"Successfully computed eigenpairs!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = bitcast i32* %3 to i8*
store i32 100, i32* %3
%12 = bitcast double* %4 to i8*
%13 = bitcast double* %5 to i8*
%14 = bitcast i32* %6 to i8*
%15 = bitcast i32* %7 to i8*
%16 = bitcast i32* %8 to i8*
%17 = bitcast i32* %9 to i8*
%18 = bitcast i32* %10 to i8*
store i32 100, i32* %10
%19 = tail call i64 @malloc(i64 40400)
%20 = inttoptr i64 %19 to double*
%21 = icmp ne i64 %19, 0
%22 = zext i1 %21 to i32
%23 = tail call i32 @assert(i32 %22)
%24 = tail call i64 @malloc(i64 40400)
%25 = inttoptr i64 %24 to double*
%26 = icmp ne i64 %24, 0
%27 = zext i1 %26 to i32
%28 = tail call i32 @assert(i32 %27)
%29 = tail call i64 @malloc(i64 800)
%30 = inttoptr i64 %29 to double*
%31 = icmp ne i64 %29, 0
%32 = zext i1 %31 to i32
%33 = tail call i32 @assert(i32 %32)
%34 = tail call i64 @malloc(i64 80000)
%35 = inttoptr i64 %34 to double*
%36 = icmp ne i64 %34, 0
%37 = zext i1 %36 to i32
%38 = tail call i32 @assert(i32 %37)
%39 = tail call i32 @init_sym_matrix_packed(double* %20, i32 100)
%40 = tail call i32 @init_sym_matrix_packed(double* %25, i32 100)
br label %41
41: ; preds = %2, %86
%42 = phi i32 [ 1, %2 ], [ %89, %86 ]
%43 = phi i32 [ 0, %2 ], [ %88, %86 ]
%44 = phi i64 [ 0, %2 ], [ %87, %86 ]
%45 = shl i64 %44, 32
%46 = ashr exact i64 %45, 32
%47 = and i32 %42, 1
%48 = icmp eq i32 %43, 0
br i1 %48, label %73, label %49
49: ; preds = %41
%50 = and i32 %42, -2
br label %51
51: ; preds = %68, %49
%52 = phi i64 [ %46, %49 ], [ %69, %68 ]
%53 = phi i32 [ 0, %49 ], [ %70, %68 ]
%54 = phi i32 [ 0, %49 ], [ %71, %68 ]
%55 = icmp eq i32 %53, %43
br i1 %55, label %56, label %60
56: ; preds = %51
%57 = getelementptr inbounds double, double* %25, i64 %52
%58 = load double, double* %57
%59 = fadd double %58, 1.000000e+02
store double %59, double* %57
br label %60
60: ; preds = %56, %51
%61 = or i32 %53, 1
%62 = icmp eq i32 %61, %43
br i1 %62, label %63, label %68
63: ; preds = %60
%64 = add nsw i64 %52, 1
%65 = getelementptr inbounds double, double* %25, i64 %64
%66 = load double, double* %65
%67 = fadd double %66, 1.000000e+02
store double %67, double* %65
br label %68
68: ; preds = %63, %60
%69 = add nsw i64 %52, 2
%70 = add nuw nsw i32 %53, 2
%71 = add i32 %54, 2
%72 = icmp eq i32 %71, %50
br i1 %72, label %73, label %51
73: ; preds = %68, %41
%74 = phi i64 [ undef, %41 ], [ %69, %68 ]
%75 = phi i64 [ %46, %41 ], [ %69, %68 ]
%76 = phi i32 [ 0, %41 ], [ %70, %68 ]
%77 = icmp eq i32 %47, 0
br i1 %77, label %86, label %78
78: ; preds = %73
%79 = icmp eq i32 %76, %43
br i1 %79, label %80, label %84
80: ; preds = %78
%81 = getelementptr inbounds double, double* %25, i64 %75
%82 = load double, double* %81
%83 = fadd double %82, 1.000000e+02
store double %83, double* %81
br label %84
84: ; preds = %80, %78
%85 = add nsw i64 %75, 1
br label %86
86: ; preds = %73, %84
%87 = phi i64 [ %74, %73 ], [ %85, %84 ]
%88 = add nuw nsw i32 %43, 1
%89 = add nuw i32 %42, 1
%90 = icmp eq i32 %88, 100
br i1 %90, label %91, label %41
91: ; preds = %86
store i32 1, i32* %9
%92 = call i32 @dspgeig(i32* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %3, double* %20, double* %25, double* %4, double* %5, i32* %6, i32* %7, i32* %8, double* %30, double* %35, i32* %10)
%93 = icmp eq i32 %92, 0
%94 = zext i1 %93 to i32
%95 = call i32 @assert(i32 %94)
%96 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%97 = call i32 @free(double* %20)
%98 = call i32 @free(double* %25)
%99 = call i32 @free(double* %35)
%100 = call i32 @free(double* %30)
ret i32 0
}