#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 dsygeig(int *, char *, char *, char *, int *, double *, int *, double *,
            int *, double *, double *, int *, int *, int *, double *);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ init_symmetric_matrix(double *, int, int);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  int i, info;
  int n = 100;
  int lda = n;
  int ldb = n;
  double *A, *B, *W;
  double vl, vu;
  int il, iu;
  int m;
  int itype;
  A = (double *)malloc((size_t)n * n * sizeof(double));
  assert(A != NULL);
  B = (double *)malloc((size_t)n * n * sizeof(double));
  assert(B != NULL);
  W = (double *)malloc((size_t)n * sizeof(double));
  assert(W != NULL);
  init_symmetric_matrix(A, n, lda);
  init_symmetric_matrix(B, n, ldb);
  for (i = 0; i < n; i++)
    B[i + i * ldb] += n;
  itype = 1;
  il = 1;
  iu = n / 2 + 1;
  info = dsygeig(&itype, "Vectors", "Index", "Low", &n, A, &lda, B, &ldb, &vl,
                 &vu, &il, &iu, &m, W);
  assert(info == 0);
  printf("Successfully computed eigenpairs!\n");
  free(A);
  free(B);
  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    $0xb8,%rsp
movl   $0x0,-0x2c(%rbp)
mov    %edi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
movl   $0x64,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movslq -0x44(%rbp),%rdi
movslq -0x44(%rbp),%rax
imul   %rax,%rdi
shl    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
movslq -0x44(%rbp),%rdi
movslq -0x44(%rbp),%rax
imul   %rax,%rdi
shl    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
movslq -0x44(%rbp),%rdi
shl    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x58(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    -0x48(%rbp),%edx
call   1060 <init_symmetric_matrix@plt>
mov    -0x60(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    -0x4c(%rbp),%edx
call   1060 <init_symmetric_matrix@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    126f <main+0x10f>
cvtsi2sdl -0x44(%rbp),%xmm0
mov    -0x60(%rbp),%rax
mov    -0x3c(%rbp),%ecx
mov    -0x3c(%rbp),%edx
imul   -0x4c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1233 <main+0xd3>
movl   $0x1,-0x88(%rbp)
movl   $0x1,-0x7c(%rbp)
mov    -0x44(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
mov    -0x58(%rbp),%r9
mov    -0x60(%rbp),%r13
mov    -0x68(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    -0x88(%rbp),%rdi
lea    0xd4e(%rip),%rsi
lea    0xd4f(%rip),%rdx
lea    0xd4e(%rip),%rcx
lea    -0x44(%rbp),%r8
lea    -0x48(%rbp),%rax
lea    -0x4c(%rbp),%r12
lea    -0x70(%rbp),%r15
lea    -0x78(%rbp),%r14
lea    -0x7c(%rbp),%rbx
lea    -0x80(%rbp),%r11
lea    -0x84(%rbp),%r10
mov    %rax,(%rsp)
mov    -0x90(%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   1040 <dsygeig@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xcdc(%rip),%rdi
call   1050 <printf@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0xb8,%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    $0x38,%rsp
movl   $0x64,0x20(%rsp)
movl   $0x64,0x1c(%rsp)
movl   $0x64,0x18(%rsp)
mov    $0x13880,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1070 <assert@plt>
mov    $0x13880,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1070 <assert@plt>
mov    $0x320,%edi
call   1080 <malloc@plt>
mov    %rax,%r15
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1070 <assert@plt>
mov    %r14,%rdi
mov    $0x64,%esi
mov    $0x64,%edx
call   1060 <init_symmetric_matrix@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
mov    $0x64,%edx
call   1060 <init_symmetric_matrix@plt>
mov    $0x1,%eax
movsd  0xdf8(%rip),%xmm0
mov    %rbx,%rcx
nopl   0x0(%rax,%rax,1)
movsd  (%rcx),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rcx)
movsd  0x328(%rcx),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x328(%rcx)
add    $0x650,%rcx
add    $0x2,%rax
cmp    $0x65,%rax
jne    1210 <main+0xb0>
movl   $0x1,0xc(%rsp)
movl   $0x1,0x14(%rsp)
movl   $0x33,0x10(%rsp)
sub    $0x8,%rsp
lea    0x2c(%rsp),%rax
lea    0x18(%rsp),%r10
lea    0x1c(%rsp),%r11
lea    0x30(%rsp),%r12
lea    0x38(%rsp),%r13
lea    0x20(%rsp),%rbp
lea    0xd86(%rip),%rsi
lea    0xd87(%rip),%rdx
lea    0xd86(%rip),%rcx
lea    0x14(%rsp),%rdi
lea    0x28(%rsp),%r8
mov    %r14,%r9
push   %r15
push   %rax
push   %r10
push   %r11
push   %r12
push   %r13
push   %rbp
push   %rbx
lea    0x64(%rsp),%rax
push   %rax
call   1050 <dsygeig@plt>
add    $0x50,%rsp
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
lea    0xd4d(%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>
xor    %eax,%eax
add    $0x38,%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 = [4 x i8] c"Low\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 double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double
%15 = alloca double
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 100, i32* %8
%20 = load i32, i32* %8
store i32 %20, i32* %9
%21 = load i32, i32* %8
store i32 %21, i32* %10
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = mul i64 %23, %25
%27 = mul i64 %26, 8
%28 = call i64 @malloc(i64 %27)
%29 = inttoptr i64 %28 to double*
store double* %29, double** %11
%30 = load double*, double** %11
%31 = icmp ne double* %30, null
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = mul i64 %35, %37
%39 = mul i64 %38, 8
%40 = call i64 @malloc(i64 %39)
%41 = inttoptr i64 %40 to double*
store double* %41, double** %12
%42 = load double*, double** %12
%43 = icmp ne double* %42, null
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
%46 = load i32, i32* %8
%47 = sext i32 %46 to i64
%48 = mul i64 %47, 8
%49 = call i64 @malloc(i64 %48)
%50 = inttoptr i64 %49 to double*
store double* %50, double** %13
%51 = load double*, double** %13
%52 = icmp ne double* %51, null
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = load double*, double** %11
%56 = load i32, i32* %8
%57 = load i32, i32* %9
%58 = call i32 @init_symmetric_matrix(double* %55, i32 %56, i32 %57)
%59 = load double*, double** %12
%60 = load i32, i32* %8
%61 = load i32, i32* %10
%62 = call i32 @init_symmetric_matrix(double* %59, i32 %60, i32 %61)
store i32 0, i32* %6
br label %63
63: ; preds = %80, %2
%64 = load i32, i32* %6
%65 = load i32, i32* %8
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %83
67: ; preds = %63
%68 = load i32, i32* %8
%69 = sitofp i32 %68 to double
%70 = load double*, double** %12
%71 = load i32, i32* %6
%72 = load i32, i32* %6
%73 = load i32, i32* %10
%74 = mul nsw i32 %72, %73
%75 = add nsw i32 %71, %74
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double, double* %70, i64 %76
%78 = load double, double* %77
%79 = fadd double %78, %69
store double %79, double* %77
br label %80
80: ; preds = %67
%81 = load i32, i32* %6
%82 = add nsw i32 %81, 1
store i32 %82, i32* %6
br label %63
83: ; preds = %63
store i32 1, i32* %19
store i32 1, i32* %16
%84 = load i32, i32* %8
%85 = sdiv i32 %84, 2
%86 = add nsw i32 %85, 1
store i32 %86, i32* %17
%87 = load double*, double** %11
%88 = load double*, double** %12
%89 = load double*, double** %13
%90 = call i32 @dsygeig(i32* %19, 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 ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %8, double* %87, i32* %9, double* %88, i32* %10, double* %14, double* %15, i32* %16, i32* %17, i32* %18, double* %89)
store i32 %90, i32* %7
%91 = load i32, i32* %7
%92 = icmp eq i32 %91, 0
%93 = zext i1 %92 to i32
%94 = call i32 @assert(i32 %93)
%95 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%96 = load double*, double** %11
%97 = call i32 @free(double* %96)
%98 = load double*, double** %12
%99 = call i32 @free(double* %98)
%100 = load double*, double** %13
%101 = call i32 @free(double* %100)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"Vectors\00"
@.str.1 = [6 x i8] c"Index\00"
@.str.2 = [4 x i8] c"Low\00"
@str = [34 x i8] c"Successfully computed eigenpairs!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = bitcast i32* %3 to i8*
store i32 100, i32* %3
%13 = bitcast i32* %4 to i8*
store i32 100, i32* %4
%14 = bitcast i32* %5 to i8*
store i32 100, i32* %5
%15 = bitcast double* %6 to i8*
%16 = bitcast double* %7 to i8*
%17 = bitcast i32* %8 to i8*
%18 = bitcast i32* %9 to i8*
%19 = bitcast i32* %10 to i8*
%20 = bitcast i32* %11 to i8*
%21 = tail call i64 @malloc(i64 80000)
%22 = inttoptr i64 %21 to double*
%23 = icmp ne i64 %21, 0
%24 = zext i1 %23 to i32
%25 = tail call i32 @assert(i32 %24)
%26 = tail call i64 @malloc(i64 80000)
%27 = inttoptr i64 %26 to double*
%28 = icmp ne i64 %26, 0
%29 = zext i1 %28 to i32
%30 = tail call i32 @assert(i32 %29)
%31 = tail call i64 @malloc(i64 800)
%32 = inttoptr i64 %31 to double*
%33 = icmp ne i64 %31, 0
%34 = zext i1 %33 to i32
%35 = tail call i32 @assert(i32 %34)
%36 = tail call i32 @init_symmetric_matrix(double* %22, i32 100, i32 100)
%37 = tail call i32 @init_symmetric_matrix(double* %27, i32 100, i32 100)
br label %38
38: ; preds = %38, %2
%39 = phi i64 [ 0, %2 ], [ %53, %38 ]
%40 = mul nuw nsw i64 %39, 429496729600
%41 = lshr exact i64 %40, 32
%42 = add nuw nsw i64 %41, %39
%43 = getelementptr inbounds double, double* %27, i64 %42
%44 = load double, double* %43
%45 = fadd double %44, 1.000000e+02
store double %45, double* %43
%46 = or i64 %39, 1
%47 = mul nuw nsw i64 %46, 429496729600
%48 = lshr exact i64 %47, 32
%49 = add nuw nsw i64 %48, %46
%50 = getelementptr inbounds double, double* %27, i64 %49
%51 = load double, double* %50
%52 = fadd double %51, 1.000000e+02
store double %52, double* %50
%53 = add nuw nsw i64 %39, 2
%54 = icmp eq i64 %53, 100
br i1 %54, label %55, label %38
55: ; preds = %38
store i32 1, i32* %11
store i32 1, i32* %8
store i32 51, i32* %9
%56 = call i32 @dsygeig(i32* %11, 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 ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %3, double* %22, i32* %4, double* %27, i32* %5, double* %6, double* %7, i32* %8, i32* %9, i32* %10, double* %32)
%57 = icmp eq i32 %56, 0
%58 = zext i1 %57 to i32
%59 = call i32 @assert(i32 %58)
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%61 = call i32 @free(double* %22)
%62 = call i32 @free(double* %27)
%63 = call i32 @free(double* %32)
ret i32 0
}