#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 */
typedef int /*<<< orphan*/ time_t;

/* Variables and functions */
double RAND_MAX;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ dspeig(char *, char *, char *, int *, double *, double *,
                          double *, int *, int *, int *, double *, double *,
                          int *);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ printf(char *);
scalar_t__ rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  int n = 100;
  int ldz = n;
  int nz = n;
  int size = (n * (n + 1)) / 2;
  double *AP, *W, *Z;
  double vl, vu;
  int il, iu;
  int m, i;
  AP = (double *)malloc((size_t)size * sizeof(double));
  assert(AP != NULL);
  W = (double *)malloc((size_t)n * sizeof(double));
  assert(W != NULL);
  Z = (double *)malloc((size_t)n * nz * sizeof(double));
  assert(Z != NULL);
  srand((unsigned)time((time_t *)NULL));
  for (i = 0; i < size; i++)
    AP[i] = (double)rand() / RAND_MAX;
  dspeig("Vectors", "All", "Lower", &n, AP, &vl, &vu, &il, &iu, &m, W, Z, &ldz);
  printf("Successfully computed eigenpairs!\n");
  free(AP);
  free(W);
  free(Z);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x90,%rsp
movl   $0x0,-0x24(%rbp)
mov    %edi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
movl   $0x64,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x40(%rbp)
movslq -0x40(%rbp),%rdi
shl    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movslq -0x34(%rbp),%rdi
shl    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movslq -0x34(%rbp),%rdi
movslq -0x3c(%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   1060 <assert@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    1290 <main+0x110>
mov    $0x0,%al
call   1090 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2d77(%rip),%rax
divsd  (%rax),%xmm0
mov    -0x48(%rbp),%rax
movslq -0x78(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1252 <main+0xd2>
mov    -0x48(%rbp),%r8
mov    -0x50(%rbp),%r11
mov    -0x58(%rbp),%r10
lea    0xd5d(%rip),%rdi
lea    0xd5e(%rip),%rsi
lea    0xd5b(%rip),%rdx
lea    -0x34(%rbp),%rcx
lea    -0x60(%rbp),%r9
lea    -0x68(%rbp),%r12
lea    -0x6c(%rbp),%r15
lea    -0x70(%rbp),%r14
lea    -0x74(%rbp),%rbx
lea    -0x38(%rbp),%rax
mov    %r12,(%rsp)
mov    %r15,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   10a0 <dspeig@plt>
lea    0xd17(%rip),%rdi
call   1040 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
movl   $0x64,0x10(%rsp)
movl   $0x64,0xc(%rsp)
mov    $0x9dd0,%edi
call   1080 <malloc@plt>
mov    %rax,%r12
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
mov    $0x320,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
mov    $0x13880,%edi
call   1080 <malloc@plt>
mov    %rax,%r15
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    0x2de5(%rip),%r13
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1090 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  0x0(%r13),%xmm0
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    $0x13ba,%rbx
jne    1210 <main+0x90>
sub    $0x8,%rsp
lea    0x14(%rsp),%rax
lea    0x1c(%rsp),%rbx
lea    0x20(%rsp),%r10
lea    0x24(%rsp),%r11
lea    0x28(%rsp),%r13
lea    0xda4(%rip),%rdi
lea    0xda5(%rip),%rsi
lea    0xda2(%rip),%rdx
lea    0x18(%rsp),%rcx
lea    0x30(%rsp),%r9
mov    %r12,%r8
push   %rax
push   %r15
push   %r14
push   %rbx
push   %r10
push   %r11
push   %r13
call   10a0 <dspeig@plt>
add    $0x40,%rsp
lea    0xd7f(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
@.str = [8 x i8] c"Vectors\00"
@.str.1 = [4 x i8] c"All\00"
@.str.2 = [6 x i8] c"Lower\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 double
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = bitcast i32* %3 to i8*
store i32 100, i32* %3
%11 = bitcast i32* %4 to i8*
store i32 100, i32* %4
%12 = bitcast double* %5 to i8*
%13 = bitcast double* %6 to i8*
%14 = bitcast i32* %7 to i8*
%15 = bitcast i32* %8 to i8*
%16 = bitcast i32* %9 to i8*
%17 = tail call i64 @malloc(i64 40400)
%18 = inttoptr i64 %17 to double*
%19 = icmp ne i64 %17, 0
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = tail call i64 @malloc(i64 800)
%23 = icmp ne i64 %22, 0
%24 = zext i1 %23 to i32
%25 = tail call i32 @assert(i32 %24)
%26 = tail call i64 @malloc(i64 80000)
%27 = icmp ne i64 %26, 0
%28 = zext i1 %27 to i32
%29 = tail call i32 @assert(i32 %28)
%30 = tail call i64 @time(i32* null)
%31 = trunc i64 %30 to i32
%32 = tail call i32 @srand(i32 %31)
br label %33
33: ; preds = %2, %33
%34 = phi i64 [ 0, %2 ], [ %40, %33 ]
%35 = tail call i64 (...) @rand()
%36 = sitofp i64 %35 to double
%37 = load double, double* @RAND_MAX
%38 = fdiv double %36, %37
%39 = getelementptr inbounds double, double* %18, i64 %34
store double %38, double* %39
%40 = add nuw nsw i64 %34, 1
%41 = icmp eq i64 %40, 5050
br i1 %41, label %42, label %33
42: ; preds = %33
%43 = inttoptr i64 %22 to double*
%44 = inttoptr i64 %26 to double*
%45 = call i32 @dspeig(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* %18, double* %5, double* %6, i32* %7, i32* %8, i32* %9, double* %43, double* %44, i32* %4)
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%47 = call i32 @free(double* %18)
%48 = call i32 @free(double* %43)
%49 = call i32 @free(double* %44)
ret i32 0
}