#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;
  il = 1;
  iu = n / 2 + 1;
  m = iu - il + 1;
  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 * m * 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", "Index", "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)
movl   $0x1,-0x84(%rbp)
mov    -0x4c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
mov    -0x88(%rbp),%eax
sub    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%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 -0x8c(%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    1305 <main+0x1a5>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x40(%rbp),%eax
jg     12f2 <main+0x192>
mov    -0x3c(%rbp),%eax
cmp    -0x40(%rbp),%eax
jne    12db <main+0x17b>
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    12ac <main+0x14c>
jmp    12f7 <main+0x197>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1299 <main+0x139>
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    0xccc(%rip),%rsi
lea    0xccd(%rip),%rdx
lea    0xccc(%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    0xc49(%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,0x14(%rsp)
movl   $0x64,(%rsp)
movl   $0x1,0x10(%rsp)
movl   $0x33,0xc(%rsp)
movl   $0x33,0x8(%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    $0x9f60,%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  0xdd5(%rip),%xmm0
xor    %edx,%edx
jmp    1244 <main+0xe4>
nop
add    $0x1,%rdx
add    $0x1,%eax
add    $0x1,%r8d
cmp    $0x64,%eax
je     12d7 <main+0x177>
movslq %edx,%rdx
test   %eax,%eax
je     12b0 <main+0x150>
mov    %r8d,%edi
and    $0xfffffffe,%edi
xor    %ecx,%ecx
jmp    126b <main+0x10b>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x2,%rdx
add    $0x1,%ecx
cmp    %edi,%ecx
je     12a0 <main+0x140>
mov    %ecx,%esi
cmp    %ecx,%eax
jne    127f <main+0x11f>
movsd  (%rbx,%rdx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx,%rdx,8)
lea    0x1(%rsi),%ecx
cmp    %eax,%ecx
jne    1260 <main+0x100>
movsd  0x8(%rbx,%rdx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rbx,%rdx,8)
jmp    1260 <main+0x100>
nopl   0x0(%rax,%rax,1)
add    $0x2,%esi
test   $0x1,%r8b
je     1234 <main+0xd4>
jmp    12bc <main+0x15c>
nopl   0x0(%rax,%rax,1)
xor    %esi,%esi
test   $0x1,%r8b
je     1234 <main+0xd4>
cmp    %eax,%esi
jne    1230 <main+0xd0>
movsd  (%rbx,%rdx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx,%rdx,8)
jmp    1230 <main+0xd0>
movl   $0x1,0x4(%rsp)
sub    $0x8,%rsp
lea    0x8(%rsp),%rax
lea    0x10(%rsp),%r10
lea    0x14(%rsp),%r11
lea    0x18(%rsp),%r13
lea    0x20(%rsp),%rbp
lea    0xd05(%rip),%rsi
lea    0xd06(%rip),%rdx
lea    0xd05(%rip),%rcx
lea    0xc(%rsp),%rdi
lea    0x1c(%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    0xcce(%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 = [6 x i8] c"Index\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
store i32 1, i32* %18
%29 = load i32, i32* %10
%30 = sdiv i32 %29, 2
%31 = add nsw i32 %30, 1
store i32 %31, i32* %19
%32 = load i32, i32* %19
%33 = load i32, i32* %18
%34 = sub nsw i32 %32, %33
%35 = add nsw i32 %34, 1
store i32 %35, i32* %20
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = mul i64 %37, 8
%39 = call i64 @malloc(i64 %38)
%40 = inttoptr i64 %39 to double*
store double* %40, double** %12
%41 = load double*, double** %12
%42 = icmp ne double* %41, null
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = load i32, i32* %11
%46 = sext i32 %45 to i64
%47 = mul i64 %46, 8
%48 = call i64 @malloc(i64 %47)
%49 = inttoptr i64 %48 to double*
store double* %49, double** %13
%50 = load double*, double** %13
%51 = icmp ne double* %50, null
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = mul i64 %55, 8
%57 = call i64 @malloc(i64 %56)
%58 = inttoptr i64 %57 to double*
store double* %58, double** %14
%59 = load double*, double** %14
%60 = icmp ne double* %59, null
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
%63 = load i32, i32* %10
%64 = sext i32 %63 to i64
%65 = load i32, i32* %20
%66 = sext i32 %65 to i64
%67 = mul i64 %64, %66
%68 = mul i64 %67, 8
%69 = call i64 @malloc(i64 %68)
%70 = inttoptr i64 %69 to double*
store double* %70, double** %15
%71 = load double*, double** %15
%72 = icmp ne double* %71, null
%73 = zext i1 %72 to i32
%74 = call i32 @assert(i32 %73)
%75 = load double*, double** %12
%76 = load i32, i32* %10
%77 = call i32 @init_sym_matrix_packed(double* %75, i32 %76)
%78 = load double*, double** %13
%79 = load i32, i32* %10
%80 = call i32 @init_sym_matrix_packed(double* %78, i32 %79)
store i32 0, i32* %8
store i32 0, i32* %7
br label %81
81: ; preds = %110, %2
%82 = load i32, i32* %7
%83 = load i32, i32* %10
%84 = icmp slt i32 %82, %83
br i1 %84, label %85, label %113
85: ; preds = %81
store i32 0, i32* %6
br label %86
86: ; preds = %106, %85
%87 = load i32, i32* %6
%88 = load i32, i32* %7
%89 = icmp sle i32 %87, %88
br i1 %89, label %90, label %109
90: ; preds = %86
%91 = load i32, i32* %6
%92 = load i32, i32* %7
%93 = icmp eq i32 %91, %92
br i1 %93, label %94, label %103
94: ; preds = %90
%95 = load i32, i32* %10
%96 = sitofp i32 %95 to double
%97 = load double*, double** %13
%98 = load i32, i32* %8
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds double, double* %97, i64 %99
%101 = load double, double* %100
%102 = fadd double %101, %96
store double %102, double* %100
br label %103
103: ; preds = %94, %90
%104 = load i32, i32* %8
%105 = add nsw i32 %104, 1
store i32 %105, i32* %8
br label %106
106: ; preds = %103
%107 = load i32, i32* %6
%108 = add nsw i32 %107, 1
store i32 %108, i32* %6
br label %86
109: ; preds = %86
br label %110
110: ; preds = %109
%111 = load i32, i32* %7
%112 = add nsw i32 %111, 1
store i32 %112, i32* %7
br label %81
113: ; preds = %81
store i32 1, i32* %21
%114 = load double*, double** %12
%115 = load double*, double** %13
%116 = load double*, double** %14
%117 = load double*, double** %15
%118 = call i32 @dspgeig(i32* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 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* %114, double* %115, double* %16, double* %17, i32* %18, i32* %19, i32* %20, double* %116, double* %117, i32* %22)
store i32 %118, i32* %9
%119 = load i32, i32* %9
%120 = icmp eq i32 %119, 0
%121 = zext i1 %120 to i32
%122 = call i32 @assert(i32 %121)
%123 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%124 = load double*, double** %12
%125 = call i32 @free(double* %124)
%126 = load double*, double** %13
%127 = call i32 @free(double* %126)
%128 = load double*, double** %15
%129 = call i32 @free(double* %128)
%130 = load double*, double** %14
%131 = call i32 @free(double* %130)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"Vectors\00"
@.str.1 = [6 x i8] c"Index\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
store i32 1, i32* %6
store i32 51, i32* %7
store i32 51, i32* %8
%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 40800)
%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 ([6 x i8], [6 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
}