void clapack_dsyevd_simple(char jobz, char uplo, int n, double *a, int lda,
                           double *w, int *info) {
  double fwork;
  int liwork, lwork;
  clapack_dsyevd(jobz, uplo, n, a, lda, w, &fwork, -1, &liwork, -1, info);
  lwork = fwork + 1;
  double *work = (double *)malloc(sizeof(double) * lwork);
  int *iwork = (int *)malloc(sizeof(int) * liwork);
  clapack_dsyevd(jobz, uplo, n, a, lda, w, work, lwork, iwork, liwork, info);
  free(work);
  free(iwork);
}


x86 assembly (clang, -O0):
<clapack_dsyevd_simple>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %sil,%al
mov    %dil,%sil
mov    0x10(%rbp),%rdi
mov    %sil,-0x11(%rbp)
mov    %al,-0x12(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
movsbl -0x11(%rbp),%edi
movsbl -0x12(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x30(%rbp),%r9
mov    0x10(%rbp),%rax
lea    -0x38(%rbp),%r11
lea    -0x3c(%rbp),%r10
mov    %r11,(%rsp)
movl   $0xffffffff,0x8(%rsp)
ff
mov    %r10,0x10(%rsp)
movl   $0xffffffff,0x18(%rsp)
ff
mov    %rax,0x20(%rsp)
mov    $0x0,%al
call   1050 <clapack_dsyevd@plt>
movsd  0xe55(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x40(%rbp)
movslq -0x40(%rbp),%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x48(%rbp)
movslq -0x3c(%rbp),%rdi
shl    $0x2,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x50(%rbp)
movsbl -0x11(%rbp),%edi
movsbl -0x12(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x30(%rbp),%r9
mov    -0x48(%rbp),%r14
mov    -0x40(%rbp),%ebx
mov    -0x50(%rbp),%r11
mov    -0x3c(%rbp),%r10d
mov    0x10(%rbp),%rax
mov    %r14,(%rsp)
mov    %ebx,0x8(%rsp)
mov    %r11,0x10(%rsp)
mov    %r10d,0x18(%rsp)
mov    %rax,0x20(%rsp)
mov    $0x0,%al
call   1050 <clapack_dsyevd@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<clapack_dsyevd_simple>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x18(%rsp)
mov    %r8d,0x8(%rsp)
mov    %rcx,0x10(%rsp)
mov    %edx,0x4(%rsp)
mov    %esi,%ebx
mov    %edi,%ebp
sub    $0x8,%rsp
lea    0x14(%rsp),%r10
lea    0x28(%rsp),%r11
xor    %eax,%eax
push   0x68(%rsp)
push   $0xffffffffffffffff
push   %r10
push   $0xffffffffffffffff
push   %r11
call   1050 <clapack_dsyevd@plt>
add    $0x30,%rsp
movsd  0x20(%rsp),%xmm0
addsd  0xe78(%rip),%xmm0
cvttsd2si %xmm0,%eax
movslq %eax,%r12
lea    0x0(,%r12,8),%rdi
call   1040 <malloc@plt>
mov    %rax,%r14
movslq 0xc(%rsp),%r13
mov    %r13,%rdi
shl    $0x2,%rdi
call   1040 <malloc@plt>
mov    %rax,%r15
sub    $0x8,%rsp
mov    %ebp,%edi
mov    %ebx,%esi
mov    0xc(%rsp),%edx
mov    0x18(%rsp),%rcx
mov    0x10(%rsp),%r8d
mov    0x20(%rsp),%r9
xor    %eax,%eax
push   0x68(%rsp)
push   %r13
push   %r15
push   %r12
push   %r14
call   1050 <clapack_dsyevd@plt>
add    $0x30,%rsp
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @clapack_dsyevd_simple(i8 signext %0, i8 signext %1, i32 %2, double* %3, i32 %4, double* %5, i32* %6) {
%8 = alloca i8
%9 = alloca i8
%10 = alloca i32
%11 = alloca double*
%12 = alloca i32
%13 = alloca double*
%14 = alloca i32*
%15 = alloca double
%16 = alloca i32
%17 = alloca i32
%18 = alloca double*
%19 = alloca i32*
store i8 %0, i8* %8
store i8 %1, i8* %9
store i32 %2, i32* %10
store double* %3, double** %11
store i32 %4, i32* %12
store double* %5, double** %13
store i32* %6, i32** %14
%20 = load i8, i8* %8
%21 = sext i8 %20 to i32
%22 = load i8, i8* %9
%23 = sext i8 %22 to i32
%24 = load i32, i32* %10
%25 = load double*, double** %11
%26 = load i32, i32* %12
%27 = load double*, double** %13
%28 = load i32*, i32** %14
%29 = call i32 (i32, i32, i32, double*, i32, double*, double*, i32, i32*, i32, i32*, ...) bitcast (i32 (...)* @clapack_dsyevd to i32 (i32, i32, i32, double*, i32, double*, double*, i32, i32*, i32, i32*, ...)*)(i32 %21, i32 %23, i32 %24, double* %25, i32 %26, double* %27, double* %15, i32 -1, i32* %16, i32 -1, i32* %28)
%30 = load double, double* %15
%31 = fadd double %30, 1.000000e+00
%32 = fptosi double %31 to i32
store i32 %32, i32* %17
%33 = load i32, i32* %17
%34 = sext i32 %33 to i64
%35 = mul i64 8, %34
%36 = call i8* @malloc(i64 %35)
%37 = bitcast i8* %36 to double*
store double* %37, double** %18
%38 = load i32, i32* %16
%39 = sext i32 %38 to i64
%40 = mul i64 4, %39
%41 = call i8* @malloc(i64 %40)
%42 = bitcast i8* %41 to i32*
store i32* %42, i32** %19
%43 = load i8, i8* %8
%44 = sext i8 %43 to i32
%45 = load i8, i8* %9
%46 = sext i8 %45 to i32
%47 = load i32, i32* %10
%48 = load double*, double** %11
%49 = load i32, i32* %12
%50 = load double*, double** %13
%51 = load double*, double** %18
%52 = load i32, i32* %17
%53 = load i32*, i32** %19
%54 = load i32, i32* %16
%55 = load i32*, i32** %14
%56 = call i32 (i32, i32, i32, double*, i32, double*, double*, i32, i32*, i32, i32*, ...) bitcast (i32 (...)* @clapack_dsyevd to i32 (i32, i32, i32, double*, i32, double*, double*, i32, i32*, i32, i32*, ...)*)(i32 %44, i32 %46, i32 %47, double* %48, i32 %49, double* %50, double* %51, i32 %52, i32* %53, i32 %54, i32* %55)
%57 = load double*, double** %18
%58 = bitcast double* %57 to i8*
%59 = load i32*, i32** %19
%60 = bitcast i32* %59 to i8*
ret void
}

LLVM IR (-O2):
define void @clapack_dsyevd_simple(i8 signext %0, i8 signext %1, i32 %2, double* %3, i32 %4, double* %5, i32* %6) {
%8 = alloca double
%9 = alloca i32
%10 = bitcast double* %8 to i8*
%11 = bitcast i32* %9 to i8*
%12 = sext i8 %0 to i32
%13 = sext i8 %1 to i32
%14 = call i32 (i32, i32, i32, double*, i32, double*, double*, i32, i32*, i32, i32*, ...) bitcast (i32 (...)* @clapack_dsyevd to i32 (i32, i32, i32, double*, i32, double*, double*, i32, i32*, i32, i32*, ...)*)(i32 %12, i32 %13, i32 %2, double* %3, i32 %4, double* %5, double* %8, i32 -1, i32* %9, i32 -1, i32* %6)
%15 = load double, double* %8
%16 = fadd double %15, 1.000000e+00
%17 = fptosi double %16 to i32
%18 = sext i32 %17 to i64
%19 = shl nsw i64 %18, 3
%20 = call i8* @malloc(i64 %19)
%21 = bitcast i8* %20 to double*
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = shl nsw i64 %23, 2
%25 = call i8* @malloc(i64 %24)
%26 = bitcast i8* %25 to i32*
%27 = call i32 (i32, i32, i32, double*, i32, double*, double*, i32, i32*, i32, i32*, ...) bitcast (i32 (...)* @clapack_dsyevd to i32 (i32, i32, i32, double*, i32, double*, double*, i32, i32*, i32, i32*, ...)*)(i32 %12, i32 %13, i32 %2, double* %3, i32 %4, double* %5, double* %21, i32 %17, i32* %26, i32 %22, i32* %6)
ret void
}