From 489a2884c22e8593ec47bfe7c84ab451b0c0d3d9 Mon Sep 17 00:00:00 2001
From: Julien Schueller <schueller@phimeca.com>
Date: Mon, 25 Nov 2019 19:41:16 +0100
Subject: [PATCH 1/2] Fix MinGW build error

With MinGW the build fails for some LAPACKE xgesvd routines with:
lapacke_cgesvdq.c:74:5: error: aggregate value used where an integer was expected
Seems the C2INT macro is useful there.
---
 LAPACKE/src/lapacke_cgesvdq.c | 2 +-
 LAPACKE/src/lapacke_zgesvdq.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/LAPACKE/src/lapacke_cgesvdq.c b/LAPACKE/src/lapacke_cgesvdq.c
index 801569453..6ecd06962 100644
--- a/LAPACKE/src/lapacke_cgesvdq.c
+++ b/LAPACKE/src/lapacke_cgesvdq.c
@@ -71,7 +71,7 @@ lapack_int LAPACKE_cgesvdq( int matrix_layout, char joba, char jobp,
         goto exit_level_0;
     }
     liwork = (lapack_int)iwork_query;
-    lcwork = (lapack_int)cwork_query;
+    lcwork = LAPACK_C2INT(cwork_query);
     lrwork = (lapack_int)rwork_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_zgesvdq.c b/LAPACKE/src/lapacke_zgesvdq.c
index 7c205dab3..1674138fc 100644
--- a/LAPACKE/src/lapacke_zgesvdq.c
+++ b/LAPACKE/src/lapacke_zgesvdq.c
@@ -71,7 +71,7 @@ lapack_int LAPACKE_zgesvdq( int matrix_layout, char joba, char jobp,
         goto exit_level_0;
     }
     liwork = (lapack_int)iwork_query;
-    lcwork = (lapack_int)cwork_query;
+    lcwork = LAPACK_C2INT(cwork_query);
     lrwork = (lapack_int)rwork_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );

From 74cecfb96ac5e541aaac88082851c6598f1cc0fd Mon Sep 17 00:00:00 2001
From: Julien Schueller <schueller@phimeca.com>
Date: Mon, 25 Nov 2019 20:21:50 +0100
Subject: [PATCH 2/2] Remove unnecessary lapack_int cast

---
 LAPACKE/src/lapacke_cgelsd.c        | 2 +-
 LAPACKE/src/lapacke_cgesvdq.c       | 2 +-
 LAPACKE/src/lapacke_cggesx.c        | 2 +-
 LAPACKE/src/lapacke_chbevd.c        | 2 +-
 LAPACKE/src/lapacke_chbevd_2stage.c | 2 +-
 LAPACKE/src/lapacke_chbgvd.c        | 2 +-
 LAPACKE/src/lapacke_cheevd.c        | 2 +-
 LAPACKE/src/lapacke_cheevd_2stage.c | 2 +-
 LAPACKE/src/lapacke_cheevr.c        | 2 +-
 LAPACKE/src/lapacke_cheevr_2stage.c | 2 +-
 LAPACKE/src/lapacke_chegvd.c        | 2 +-
 LAPACKE/src/lapacke_chpevd.c        | 2 +-
 LAPACKE/src/lapacke_chpgvd.c        | 2 +-
 LAPACKE/src/lapacke_cstedc.c        | 2 +-
 LAPACKE/src/lapacke_cstegr.c        | 2 +-
 LAPACKE/src/lapacke_cstemr.c        | 2 +-
 LAPACKE/src/lapacke_ctgsen.c        | 2 +-
 LAPACKE/src/lapacke_dgeesx.c        | 2 +-
 LAPACKE/src/lapacke_dgelsd.c        | 2 +-
 LAPACKE/src/lapacke_dgesvdq.c       | 2 +-
 LAPACKE/src/lapacke_dggesx.c        | 2 +-
 LAPACKE/src/lapacke_dsbevd.c        | 2 +-
 LAPACKE/src/lapacke_dsbevd_2stage.c | 2 +-
 LAPACKE/src/lapacke_dsbgvd.c        | 2 +-
 LAPACKE/src/lapacke_dspevd.c        | 2 +-
 LAPACKE/src/lapacke_dspgvd.c        | 2 +-
 LAPACKE/src/lapacke_dstedc.c        | 2 +-
 LAPACKE/src/lapacke_dstegr.c        | 2 +-
 LAPACKE/src/lapacke_dstemr.c        | 2 +-
 LAPACKE/src/lapacke_dstevd.c        | 2 +-
 LAPACKE/src/lapacke_dstevr.c        | 2 +-
 LAPACKE/src/lapacke_dsyevd.c        | 2 +-
 LAPACKE/src/lapacke_dsyevd_2stage.c | 2 +-
 LAPACKE/src/lapacke_dsyevr.c        | 2 +-
 LAPACKE/src/lapacke_dsyevr_2stage.c | 2 +-
 LAPACKE/src/lapacke_dsygvd.c        | 2 +-
 LAPACKE/src/lapacke_dtgsen.c        | 2 +-
 LAPACKE/src/lapacke_dtrsen.c        | 2 +-
 LAPACKE/src/lapacke_sgeesx.c        | 2 +-
 LAPACKE/src/lapacke_sgelsd.c        | 2 +-
 LAPACKE/src/lapacke_sgesvdq.c       | 2 +-
 LAPACKE/src/lapacke_sggesx.c        | 2 +-
 LAPACKE/src/lapacke_ssbevd.c        | 2 +-
 LAPACKE/src/lapacke_ssbevd_2stage.c | 2 +-
 LAPACKE/src/lapacke_ssbgvd.c        | 2 +-
 LAPACKE/src/lapacke_sspevd.c        | 2 +-
 LAPACKE/src/lapacke_sspgvd.c        | 2 +-
 LAPACKE/src/lapacke_sstedc.c        | 2 +-
 LAPACKE/src/lapacke_sstegr.c        | 2 +-
 LAPACKE/src/lapacke_sstemr.c        | 2 +-
 LAPACKE/src/lapacke_sstevd.c        | 2 +-
 LAPACKE/src/lapacke_sstevr.c        | 2 +-
 LAPACKE/src/lapacke_ssyevd.c        | 2 +-
 LAPACKE/src/lapacke_ssyevd_2stage.c | 2 +-
 LAPACKE/src/lapacke_ssyevr.c        | 2 +-
 LAPACKE/src/lapacke_ssyevr_2stage.c | 2 +-
 LAPACKE/src/lapacke_ssygvd.c        | 2 +-
 LAPACKE/src/lapacke_stgsen.c        | 2 +-
 LAPACKE/src/lapacke_strsen.c        | 2 +-
 LAPACKE/src/lapacke_zgelsd.c        | 2 +-
 LAPACKE/src/lapacke_zgesvdq.c       | 2 +-
 LAPACKE/src/lapacke_zggesx.c        | 2 +-
 LAPACKE/src/lapacke_zhbevd.c        | 2 +-
 LAPACKE/src/lapacke_zhbevd_2stage.c | 2 +-
 LAPACKE/src/lapacke_zhbgvd.c        | 2 +-
 LAPACKE/src/lapacke_zheevd.c        | 2 +-
 LAPACKE/src/lapacke_zheevd_2stage.c | 2 +-
 LAPACKE/src/lapacke_zheevr.c        | 2 +-
 LAPACKE/src/lapacke_zheevr_2stage.c | 2 +-
 LAPACKE/src/lapacke_zhegvd.c        | 2 +-
 LAPACKE/src/lapacke_zhpevd.c        | 2 +-
 LAPACKE/src/lapacke_zhpgvd.c        | 2 +-
 LAPACKE/src/lapacke_zstedc.c        | 2 +-
 LAPACKE/src/lapacke_zstegr.c        | 2 +-
 LAPACKE/src/lapacke_zstemr.c        | 2 +-
 LAPACKE/src/lapacke_ztgsen.c        | 2 +-
 76 files changed, 76 insertions(+), 76 deletions(-)

diff --git a/LAPACKE/src/lapacke_cgelsd.c b/LAPACKE/src/lapacke_cgelsd.c
index 2ee891977..9d022dae6 100644
--- a/LAPACKE/src/lapacke_cgelsd.c
+++ b/LAPACKE/src/lapacke_cgelsd.c
@@ -75,7 +75,7 @@ lapack_int LAPACKE_cgelsd( int matrix_layout, lapack_int m, lapack_int n,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_C2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_cgesvdq.c b/LAPACKE/src/lapacke_cgesvdq.c
index 6ecd06962..91458136c 100644
--- a/LAPACKE/src/lapacke_cgesvdq.c
+++ b/LAPACKE/src/lapacke_cgesvdq.c
@@ -70,7 +70,7 @@ lapack_int LAPACKE_cgesvdq( int matrix_layout, char joba, char jobp,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lcwork = LAPACK_C2INT(cwork_query);
     lrwork = (lapack_int)rwork_query;
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_cggesx.c b/LAPACKE/src/lapacke_cggesx.c
index fc939a314..9581691c6 100644
--- a/LAPACKE/src/lapacke_cggesx.c
+++ b/LAPACKE/src/lapacke_cggesx.c
@@ -91,7 +91,7 @@ lapack_int LAPACKE_cggesx( int matrix_layout, char jobvsl, char jobvsr,
     if( info != 0 ) {
         goto exit_level_2;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = LAPACK_C2INT( work_query );
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_chbevd.c b/LAPACKE/src/lapacke_chbevd.c
index 024cf2585..b4af255a9 100644
--- a/LAPACKE/src/lapacke_chbevd.c
+++ b/LAPACKE/src/lapacke_chbevd.c
@@ -67,7 +67,7 @@ lapack_int LAPACKE_chbevd( int matrix_layout, char jobz, char uplo, lapack_int n
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_C2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_chbevd_2stage.c b/LAPACKE/src/lapacke_chbevd_2stage.c
index 63f7d8ccb..e8e9a6830 100644
--- a/LAPACKE/src/lapacke_chbevd_2stage.c
+++ b/LAPACKE/src/lapacke_chbevd_2stage.c
@@ -67,7 +67,7 @@ lapack_int LAPACKE_chbevd_2stage( int matrix_layout, char jobz, char uplo, lapac
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_C2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_chbgvd.c b/LAPACKE/src/lapacke_chbgvd.c
index d44f6c622..5a7331d87 100644
--- a/LAPACKE/src/lapacke_chbgvd.c
+++ b/LAPACKE/src/lapacke_chbgvd.c
@@ -71,7 +71,7 @@ lapack_int LAPACKE_chbgvd( int matrix_layout, char jobz, char uplo, lapack_int n
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_C2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_cheevd.c b/LAPACKE/src/lapacke_cheevd.c
index 3531f3eab..75fa47915 100644
--- a/LAPACKE/src/lapacke_cheevd.c
+++ b/LAPACKE/src/lapacke_cheevd.c
@@ -65,7 +65,7 @@ lapack_int LAPACKE_cheevd( int matrix_layout, char jobz, char uplo, lapack_int n
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_C2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_cheevd_2stage.c b/LAPACKE/src/lapacke_cheevd_2stage.c
index f5ec6d757..cb4d34a09 100644
--- a/LAPACKE/src/lapacke_cheevd_2stage.c
+++ b/LAPACKE/src/lapacke_cheevd_2stage.c
@@ -65,7 +65,7 @@ lapack_int LAPACKE_cheevd_2stage( int matrix_layout, char jobz, char uplo, lapac
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_C2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_cheevr.c b/LAPACKE/src/lapacke_cheevr.c
index 6fe261624..f277e7f70 100644
--- a/LAPACKE/src/lapacke_cheevr.c
+++ b/LAPACKE/src/lapacke_cheevr.c
@@ -83,7 +83,7 @@ lapack_int LAPACKE_cheevr( int matrix_layout, char jobz, char range, char uplo,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_C2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_cheevr_2stage.c b/LAPACKE/src/lapacke_cheevr_2stage.c
index 5b3f5c77a..a09eac1bd 100644
--- a/LAPACKE/src/lapacke_cheevr_2stage.c
+++ b/LAPACKE/src/lapacke_cheevr_2stage.c
@@ -83,7 +83,7 @@ lapack_int LAPACKE_cheevr_2stage( int matrix_layout, char jobz, char range, char
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_C2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_chegvd.c b/LAPACKE/src/lapacke_chegvd.c
index 2959cb0dc..98c901982 100644
--- a/LAPACKE/src/lapacke_chegvd.c
+++ b/LAPACKE/src/lapacke_chegvd.c
@@ -70,7 +70,7 @@ lapack_int LAPACKE_chegvd( int matrix_layout, lapack_int itype, char jobz,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_C2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_chpevd.c b/LAPACKE/src/lapacke_chpevd.c
index 47c7bbe23..fbdb73802 100644
--- a/LAPACKE/src/lapacke_chpevd.c
+++ b/LAPACKE/src/lapacke_chpevd.c
@@ -66,7 +66,7 @@ lapack_int LAPACKE_chpevd( int matrix_layout, char jobz, char uplo, lapack_int n
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_C2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_chpgvd.c b/LAPACKE/src/lapacke_chpgvd.c
index 568882ec9..587d1509a 100644
--- a/LAPACKE/src/lapacke_chpgvd.c
+++ b/LAPACKE/src/lapacke_chpgvd.c
@@ -70,7 +70,7 @@ lapack_int LAPACKE_chpgvd( int matrix_layout, lapack_int itype, char jobz,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_C2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_cstedc.c b/LAPACKE/src/lapacke_cstedc.c
index 5be3cec70..3c0be27d5 100644
--- a/LAPACKE/src/lapacke_cstedc.c
+++ b/LAPACKE/src/lapacke_cstedc.c
@@ -73,7 +73,7 @@ lapack_int LAPACKE_cstedc( int matrix_layout, char compz, lapack_int n, float* d
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_C2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_cstegr.c b/LAPACKE/src/lapacke_cstegr.c
index 986702e62..86a0cd72d 100644
--- a/LAPACKE/src/lapacke_cstegr.c
+++ b/LAPACKE/src/lapacke_cstegr.c
@@ -81,7 +81,7 @@ lapack_int LAPACKE_cstegr( int matrix_layout, char jobz, char range,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_cstemr.c b/LAPACKE/src/lapacke_cstemr.c
index 9b9b84e49..51e63c675 100644
--- a/LAPACKE/src/lapacke_cstemr.c
+++ b/LAPACKE/src/lapacke_cstemr.c
@@ -75,7 +75,7 @@ lapack_int LAPACKE_cstemr( int matrix_layout, char jobz, char range,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_ctgsen.c b/LAPACKE/src/lapacke_ctgsen.c
index e2f38c87b..6bfcdc996 100644
--- a/LAPACKE/src/lapacke_ctgsen.c
+++ b/LAPACKE/src/lapacke_ctgsen.c
@@ -84,7 +84,7 @@ lapack_int LAPACKE_ctgsen( int matrix_layout, lapack_int ijob,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = LAPACK_C2INT( work_query );
     /* Allocate memory for work arrays */
     if( ijob != 0 ) {
diff --git a/LAPACKE/src/lapacke_dgeesx.c b/LAPACKE/src/lapacke_dgeesx.c
index 27647954b..193d65737 100644
--- a/LAPACKE/src/lapacke_dgeesx.c
+++ b/LAPACKE/src/lapacke_dgeesx.c
@@ -76,7 +76,7 @@ lapack_int LAPACKE_dgeesx( int matrix_layout, char jobvs, char sort,
     if( info != 0 ) {
         goto exit_level_1;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     if( LAPACKE_lsame( sense, 'b' ) || LAPACKE_lsame( sense, 'v' ) ) {
diff --git a/LAPACKE/src/lapacke_dgelsd.c b/LAPACKE/src/lapacke_dgelsd.c
index 6750597bb..790119596 100644
--- a/LAPACKE/src/lapacke_dgelsd.c
+++ b/LAPACKE/src/lapacke_dgelsd.c
@@ -70,7 +70,7 @@ lapack_int LAPACKE_dgelsd( int matrix_layout, lapack_int m, lapack_int n,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dgesvdq.c b/LAPACKE/src/lapacke_dgesvdq.c
index b0f923297..7bf831f8b 100644
--- a/LAPACKE/src/lapacke_dgesvdq.c
+++ b/LAPACKE/src/lapacke_dgesvdq.c
@@ -70,7 +70,7 @@ lapack_int LAPACKE_dgesvdq( int matrix_layout, char joba, char jobp,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     lrwork = (lapack_int)rwork_query;
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_dggesx.c b/LAPACKE/src/lapacke_dggesx.c
index 36addda74..91eb7bf8c 100644
--- a/LAPACKE/src/lapacke_dggesx.c
+++ b/LAPACKE/src/lapacke_dggesx.c
@@ -82,7 +82,7 @@ lapack_int LAPACKE_dggesx( int matrix_layout, char jobvsl, char jobvsr,
     if( info != 0 ) {
         goto exit_level_1;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dsbevd.c b/LAPACKE/src/lapacke_dsbevd.c
index 4ecd1b522..3a9abbbe1 100644
--- a/LAPACKE/src/lapacke_dsbevd.c
+++ b/LAPACKE/src/lapacke_dsbevd.c
@@ -62,7 +62,7 @@ lapack_int LAPACKE_dsbevd( int matrix_layout, char jobz, char uplo, lapack_int n
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dsbevd_2stage.c b/LAPACKE/src/lapacke_dsbevd_2stage.c
index b0ccc0b1e..4d42b6208 100644
--- a/LAPACKE/src/lapacke_dsbevd_2stage.c
+++ b/LAPACKE/src/lapacke_dsbevd_2stage.c
@@ -62,7 +62,7 @@ lapack_int LAPACKE_dsbevd_2stage( int matrix_layout, char jobz, char uplo, lapac
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dsbgvd.c b/LAPACKE/src/lapacke_dsbgvd.c
index 36f912ee5..cab2a64bb 100644
--- a/LAPACKE/src/lapacke_dsbgvd.c
+++ b/LAPACKE/src/lapacke_dsbgvd.c
@@ -67,7 +67,7 @@ lapack_int LAPACKE_dsbgvd( int matrix_layout, char jobz, char uplo, lapack_int n
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dspevd.c b/LAPACKE/src/lapacke_dspevd.c
index 3b6b25d5e..c7d93b6b3 100644
--- a/LAPACKE/src/lapacke_dspevd.c
+++ b/LAPACKE/src/lapacke_dspevd.c
@@ -61,7 +61,7 @@ lapack_int LAPACKE_dspevd( int matrix_layout, char jobz, char uplo, lapack_int n
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dspgvd.c b/LAPACKE/src/lapacke_dspgvd.c
index 8ca478ed1..b49ce95ec 100644
--- a/LAPACKE/src/lapacke_dspgvd.c
+++ b/LAPACKE/src/lapacke_dspgvd.c
@@ -66,7 +66,7 @@ lapack_int LAPACKE_dspgvd( int matrix_layout, lapack_int itype, char jobz,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dstedc.c b/LAPACKE/src/lapacke_dstedc.c
index 4f88a04c4..16e308450 100644
--- a/LAPACKE/src/lapacke_dstedc.c
+++ b/LAPACKE/src/lapacke_dstedc.c
@@ -69,7 +69,7 @@ lapack_int LAPACKE_dstedc( int matrix_layout, char compz, lapack_int n,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dstegr.c b/LAPACKE/src/lapacke_dstegr.c
index 9191f0a9f..7e4f9d694 100644
--- a/LAPACKE/src/lapacke_dstegr.c
+++ b/LAPACKE/src/lapacke_dstegr.c
@@ -81,7 +81,7 @@ lapack_int LAPACKE_dstegr( int matrix_layout, char jobz, char range,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dstemr.c b/LAPACKE/src/lapacke_dstemr.c
index 8dc2bd237..1a3b0ac7b 100644
--- a/LAPACKE/src/lapacke_dstemr.c
+++ b/LAPACKE/src/lapacke_dstemr.c
@@ -75,7 +75,7 @@ lapack_int LAPACKE_dstemr( int matrix_layout, char jobz, char range,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dstevd.c b/LAPACKE/src/lapacke_dstevd.c
index e824a164b..251a2ae2e 100644
--- a/LAPACKE/src/lapacke_dstevd.c
+++ b/LAPACKE/src/lapacke_dstevd.c
@@ -64,7 +64,7 @@ lapack_int LAPACKE_dstevd( int matrix_layout, char jobz, lapack_int n, double* d
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dstevr.c b/LAPACKE/src/lapacke_dstevr.c
index fd53e0ac0..d49e0ff1c 100644
--- a/LAPACKE/src/lapacke_dstevr.c
+++ b/LAPACKE/src/lapacke_dstevr.c
@@ -81,7 +81,7 @@ lapack_int LAPACKE_dstevr( int matrix_layout, char jobz, char range,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dsyevd.c b/LAPACKE/src/lapacke_dsyevd.c
index 8989f9cfa..d6772ea01 100644
--- a/LAPACKE/src/lapacke_dsyevd.c
+++ b/LAPACKE/src/lapacke_dsyevd.c
@@ -61,7 +61,7 @@ lapack_int LAPACKE_dsyevd( int matrix_layout, char jobz, char uplo, lapack_int n
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dsyevd_2stage.c b/LAPACKE/src/lapacke_dsyevd_2stage.c
index 996306574..e866451a5 100644
--- a/LAPACKE/src/lapacke_dsyevd_2stage.c
+++ b/LAPACKE/src/lapacke_dsyevd_2stage.c
@@ -61,7 +61,7 @@ lapack_int LAPACKE_dsyevd_2stage( int matrix_layout, char jobz, char uplo, lapac
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dsyevr.c b/LAPACKE/src/lapacke_dsyevr.c
index bae72f6c3..290ae0bd4 100644
--- a/LAPACKE/src/lapacke_dsyevr.c
+++ b/LAPACKE/src/lapacke_dsyevr.c
@@ -78,7 +78,7 @@ lapack_int LAPACKE_dsyevr( int matrix_layout, char jobz, char range, char uplo,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dsyevr_2stage.c b/LAPACKE/src/lapacke_dsyevr_2stage.c
index dad20209e..7ee7dbc0b 100644
--- a/LAPACKE/src/lapacke_dsyevr_2stage.c
+++ b/LAPACKE/src/lapacke_dsyevr_2stage.c
@@ -78,7 +78,7 @@ lapack_int LAPACKE_dsyevr_2stage( int matrix_layout, char jobz, char range, char
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dsygvd.c b/LAPACKE/src/lapacke_dsygvd.c
index 907ad50bd..51f333359 100644
--- a/LAPACKE/src/lapacke_dsygvd.c
+++ b/LAPACKE/src/lapacke_dsygvd.c
@@ -66,7 +66,7 @@ lapack_int LAPACKE_dsygvd( int matrix_layout, lapack_int itype, char jobz,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_dtgsen.c b/LAPACKE/src/lapacke_dtgsen.c
index 2cb7fce4b..baa63abe7 100644
--- a/LAPACKE/src/lapacke_dtgsen.c
+++ b/LAPACKE/src/lapacke_dtgsen.c
@@ -81,7 +81,7 @@ lapack_int LAPACKE_dtgsen( int matrix_layout, lapack_int ijob,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     if( ijob != 0 ) {
diff --git a/LAPACKE/src/lapacke_dtrsen.c b/LAPACKE/src/lapacke_dtrsen.c
index 521bc2701..67932fd98 100644
--- a/LAPACKE/src/lapacke_dtrsen.c
+++ b/LAPACKE/src/lapacke_dtrsen.c
@@ -70,7 +70,7 @@ lapack_int LAPACKE_dtrsen( int matrix_layout, char job, char compq,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'v' ) ) {
diff --git a/LAPACKE/src/lapacke_sgeesx.c b/LAPACKE/src/lapacke_sgeesx.c
index 91cfc4fa5..0bc14b33e 100644
--- a/LAPACKE/src/lapacke_sgeesx.c
+++ b/LAPACKE/src/lapacke_sgeesx.c
@@ -76,7 +76,7 @@ lapack_int LAPACKE_sgeesx( int matrix_layout, char jobvs, char sort,
     if( info != 0 ) {
         goto exit_level_1;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     if( LAPACKE_lsame( sense, 'b' ) || LAPACKE_lsame( sense, 'v' ) ) {
diff --git a/LAPACKE/src/lapacke_sgelsd.c b/LAPACKE/src/lapacke_sgelsd.c
index fc42b1eec..9d00ded10 100644
--- a/LAPACKE/src/lapacke_sgelsd.c
+++ b/LAPACKE/src/lapacke_sgelsd.c
@@ -70,7 +70,7 @@ lapack_int LAPACKE_sgelsd( int matrix_layout, lapack_int m, lapack_int n,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_sgesvdq.c b/LAPACKE/src/lapacke_sgesvdq.c
index 8330a6d0d..5ff543d10 100644
--- a/LAPACKE/src/lapacke_sgesvdq.c
+++ b/LAPACKE/src/lapacke_sgesvdq.c
@@ -70,7 +70,7 @@ lapack_int LAPACKE_sgesvdq( int matrix_layout, char joba, char jobp,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     lrwork = (lapack_int)rwork_query;
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_sggesx.c b/LAPACKE/src/lapacke_sggesx.c
index f0acb70a4..d552a2010 100644
--- a/LAPACKE/src/lapacke_sggesx.c
+++ b/LAPACKE/src/lapacke_sggesx.c
@@ -82,7 +82,7 @@ lapack_int LAPACKE_sggesx( int matrix_layout, char jobvsl, char jobvsr,
     if( info != 0 ) {
         goto exit_level_1;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_ssbevd.c b/LAPACKE/src/lapacke_ssbevd.c
index 3acdeb95d..b41e5b156 100644
--- a/LAPACKE/src/lapacke_ssbevd.c
+++ b/LAPACKE/src/lapacke_ssbevd.c
@@ -62,7 +62,7 @@ lapack_int LAPACKE_ssbevd( int matrix_layout, char jobz, char uplo, lapack_int n
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_ssbevd_2stage.c b/LAPACKE/src/lapacke_ssbevd_2stage.c
index 2eda9cde9..a76d92c71 100644
--- a/LAPACKE/src/lapacke_ssbevd_2stage.c
+++ b/LAPACKE/src/lapacke_ssbevd_2stage.c
@@ -62,7 +62,7 @@ lapack_int LAPACKE_ssbevd_2stage( int matrix_layout, char jobz, char uplo, lapac
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_ssbgvd.c b/LAPACKE/src/lapacke_ssbgvd.c
index a6c036846..b40ccb9e5 100644
--- a/LAPACKE/src/lapacke_ssbgvd.c
+++ b/LAPACKE/src/lapacke_ssbgvd.c
@@ -67,7 +67,7 @@ lapack_int LAPACKE_ssbgvd( int matrix_layout, char jobz, char uplo, lapack_int n
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_sspevd.c b/LAPACKE/src/lapacke_sspevd.c
index bd06a8ba6..9b518751b 100644
--- a/LAPACKE/src/lapacke_sspevd.c
+++ b/LAPACKE/src/lapacke_sspevd.c
@@ -61,7 +61,7 @@ lapack_int LAPACKE_sspevd( int matrix_layout, char jobz, char uplo, lapack_int n
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_sspgvd.c b/LAPACKE/src/lapacke_sspgvd.c
index 749abb0b1..e80e24647 100644
--- a/LAPACKE/src/lapacke_sspgvd.c
+++ b/LAPACKE/src/lapacke_sspgvd.c
@@ -66,7 +66,7 @@ lapack_int LAPACKE_sspgvd( int matrix_layout, lapack_int itype, char jobz,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_sstedc.c b/LAPACKE/src/lapacke_sstedc.c
index 157874668..f902e8c30 100644
--- a/LAPACKE/src/lapacke_sstedc.c
+++ b/LAPACKE/src/lapacke_sstedc.c
@@ -69,7 +69,7 @@ lapack_int LAPACKE_sstedc( int matrix_layout, char compz, lapack_int n, float* d
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_sstegr.c b/LAPACKE/src/lapacke_sstegr.c
index c6a73b2b4..c02372ba2 100644
--- a/LAPACKE/src/lapacke_sstegr.c
+++ b/LAPACKE/src/lapacke_sstegr.c
@@ -81,7 +81,7 @@ lapack_int LAPACKE_sstegr( int matrix_layout, char jobz, char range,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_sstemr.c b/LAPACKE/src/lapacke_sstemr.c
index 4229819ab..65dcc9170 100644
--- a/LAPACKE/src/lapacke_sstemr.c
+++ b/LAPACKE/src/lapacke_sstemr.c
@@ -74,7 +74,7 @@ lapack_int LAPACKE_sstemr( int matrix_layout, char jobz, char range,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_sstevd.c b/LAPACKE/src/lapacke_sstevd.c
index 9f9e2e79e..c5db5d79d 100644
--- a/LAPACKE/src/lapacke_sstevd.c
+++ b/LAPACKE/src/lapacke_sstevd.c
@@ -64,7 +64,7 @@ lapack_int LAPACKE_sstevd( int matrix_layout, char jobz, lapack_int n, float* d,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_sstevr.c b/LAPACKE/src/lapacke_sstevr.c
index f45c49087..4043e3090 100644
--- a/LAPACKE/src/lapacke_sstevr.c
+++ b/LAPACKE/src/lapacke_sstevr.c
@@ -81,7 +81,7 @@ lapack_int LAPACKE_sstevr( int matrix_layout, char jobz, char range,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_ssyevd.c b/LAPACKE/src/lapacke_ssyevd.c
index cc28b6467..f5924bd94 100644
--- a/LAPACKE/src/lapacke_ssyevd.c
+++ b/LAPACKE/src/lapacke_ssyevd.c
@@ -61,7 +61,7 @@ lapack_int LAPACKE_ssyevd( int matrix_layout, char jobz, char uplo, lapack_int n
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_ssyevd_2stage.c b/LAPACKE/src/lapacke_ssyevd_2stage.c
index 4251d4b08..40ef1bcc2 100644
--- a/LAPACKE/src/lapacke_ssyevd_2stage.c
+++ b/LAPACKE/src/lapacke_ssyevd_2stage.c
@@ -61,7 +61,7 @@ lapack_int LAPACKE_ssyevd_2stage( int matrix_layout, char jobz, char uplo, lapac
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_ssyevr.c b/LAPACKE/src/lapacke_ssyevr.c
index d7e050143..3274f6bab 100644
--- a/LAPACKE/src/lapacke_ssyevr.c
+++ b/LAPACKE/src/lapacke_ssyevr.c
@@ -78,7 +78,7 @@ lapack_int LAPACKE_ssyevr( int matrix_layout, char jobz, char range, char uplo,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_ssyevr_2stage.c b/LAPACKE/src/lapacke_ssyevr_2stage.c
index cbc3014e9..8958be31d 100644
--- a/LAPACKE/src/lapacke_ssyevr_2stage.c
+++ b/LAPACKE/src/lapacke_ssyevr_2stage.c
@@ -78,7 +78,7 @@ lapack_int LAPACKE_ssyevr_2stage( int matrix_layout, char jobz, char range, char
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_ssygvd.c b/LAPACKE/src/lapacke_ssygvd.c
index 2a1c62aef..5afe8d2de 100644
--- a/LAPACKE/src/lapacke_ssygvd.c
+++ b/LAPACKE/src/lapacke_ssygvd.c
@@ -66,7 +66,7 @@ lapack_int LAPACKE_ssygvd( int matrix_layout, lapack_int itype, char jobz,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_stgsen.c b/LAPACKE/src/lapacke_stgsen.c
index 5464fd22b..d0250eb63 100644
--- a/LAPACKE/src/lapacke_stgsen.c
+++ b/LAPACKE/src/lapacke_stgsen.c
@@ -81,7 +81,7 @@ lapack_int LAPACKE_stgsen( int matrix_layout, lapack_int ijob,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     if( ijob != 0 ) {
diff --git a/LAPACKE/src/lapacke_strsen.c b/LAPACKE/src/lapacke_strsen.c
index efba91af8..0ec3ee907 100644
--- a/LAPACKE/src/lapacke_strsen.c
+++ b/LAPACKE/src/lapacke_strsen.c
@@ -69,7 +69,7 @@ lapack_int LAPACKE_strsen( int matrix_layout, char job, char compq,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'v' ) ) {
diff --git a/LAPACKE/src/lapacke_zgelsd.c b/LAPACKE/src/lapacke_zgelsd.c
index 6d111c69f..eca145090 100644
--- a/LAPACKE/src/lapacke_zgelsd.c
+++ b/LAPACKE/src/lapacke_zgelsd.c
@@ -75,7 +75,7 @@ lapack_int LAPACKE_zgelsd( int matrix_layout, lapack_int m, lapack_int n,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_Z2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_zgesvdq.c b/LAPACKE/src/lapacke_zgesvdq.c
index 1674138fc..f58a5c4e9 100644
--- a/LAPACKE/src/lapacke_zgesvdq.c
+++ b/LAPACKE/src/lapacke_zgesvdq.c
@@ -70,7 +70,7 @@ lapack_int LAPACKE_zgesvdq( int matrix_layout, char joba, char jobp,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lcwork = LAPACK_C2INT(cwork_query);
     lrwork = (lapack_int)rwork_query;
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_zggesx.c b/LAPACKE/src/lapacke_zggesx.c
index 6b4d27045..53e086753 100644
--- a/LAPACKE/src/lapacke_zggesx.c
+++ b/LAPACKE/src/lapacke_zggesx.c
@@ -91,7 +91,7 @@ lapack_int LAPACKE_zggesx( int matrix_layout, char jobvsl, char jobvsr,
     if( info != 0 ) {
         goto exit_level_2;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = LAPACK_Z2INT( work_query );
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_zhbevd.c b/LAPACKE/src/lapacke_zhbevd.c
index 95c6d3a54..ac9467496 100644
--- a/LAPACKE/src/lapacke_zhbevd.c
+++ b/LAPACKE/src/lapacke_zhbevd.c
@@ -67,7 +67,7 @@ lapack_int LAPACKE_zhbevd( int matrix_layout, char jobz, char uplo, lapack_int n
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_Z2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_zhbevd_2stage.c b/LAPACKE/src/lapacke_zhbevd_2stage.c
index eca867b28..9b6005b2d 100644
--- a/LAPACKE/src/lapacke_zhbevd_2stage.c
+++ b/LAPACKE/src/lapacke_zhbevd_2stage.c
@@ -67,7 +67,7 @@ lapack_int LAPACKE_zhbevd_2stage( int matrix_layout, char jobz, char uplo, lapac
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_Z2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_zhbgvd.c b/LAPACKE/src/lapacke_zhbgvd.c
index 91bfc0a73..76c3bac3a 100644
--- a/LAPACKE/src/lapacke_zhbgvd.c
+++ b/LAPACKE/src/lapacke_zhbgvd.c
@@ -71,7 +71,7 @@ lapack_int LAPACKE_zhbgvd( int matrix_layout, char jobz, char uplo, lapack_int n
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_Z2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_zheevd.c b/LAPACKE/src/lapacke_zheevd.c
index bc2f9d358..1305ebfb3 100644
--- a/LAPACKE/src/lapacke_zheevd.c
+++ b/LAPACKE/src/lapacke_zheevd.c
@@ -65,7 +65,7 @@ lapack_int LAPACKE_zheevd( int matrix_layout, char jobz, char uplo, lapack_int n
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_Z2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_zheevd_2stage.c b/LAPACKE/src/lapacke_zheevd_2stage.c
index 8e110df8b..63f139435 100644
--- a/LAPACKE/src/lapacke_zheevd_2stage.c
+++ b/LAPACKE/src/lapacke_zheevd_2stage.c
@@ -65,7 +65,7 @@ lapack_int LAPACKE_zheevd_2stage( int matrix_layout, char jobz, char uplo, lapac
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_Z2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_zheevr.c b/LAPACKE/src/lapacke_zheevr.c
index 52e7a5bee..0d26dc2f9 100644
--- a/LAPACKE/src/lapacke_zheevr.c
+++ b/LAPACKE/src/lapacke_zheevr.c
@@ -83,7 +83,7 @@ lapack_int LAPACKE_zheevr( int matrix_layout, char jobz, char range, char uplo,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_Z2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_zheevr_2stage.c b/LAPACKE/src/lapacke_zheevr_2stage.c
index faf949aef..6fa69c44b 100644
--- a/LAPACKE/src/lapacke_zheevr_2stage.c
+++ b/LAPACKE/src/lapacke_zheevr_2stage.c
@@ -83,7 +83,7 @@ lapack_int LAPACKE_zheevr_2stage( int matrix_layout, char jobz, char range, char
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_Z2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_zhegvd.c b/LAPACKE/src/lapacke_zhegvd.c
index 81c3d29b4..1242a0eda 100644
--- a/LAPACKE/src/lapacke_zhegvd.c
+++ b/LAPACKE/src/lapacke_zhegvd.c
@@ -70,7 +70,7 @@ lapack_int LAPACKE_zhegvd( int matrix_layout, lapack_int itype, char jobz,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_Z2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_zhpevd.c b/LAPACKE/src/lapacke_zhpevd.c
index 948bb9c10..a470ca3bb 100644
--- a/LAPACKE/src/lapacke_zhpevd.c
+++ b/LAPACKE/src/lapacke_zhpevd.c
@@ -66,7 +66,7 @@ lapack_int LAPACKE_zhpevd( int matrix_layout, char jobz, char uplo, lapack_int n
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_Z2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_zhpgvd.c b/LAPACKE/src/lapacke_zhpgvd.c
index be18d3313..91fa26443 100644
--- a/LAPACKE/src/lapacke_zhpgvd.c
+++ b/LAPACKE/src/lapacke_zhpgvd.c
@@ -70,7 +70,7 @@ lapack_int LAPACKE_zhpgvd( int matrix_layout, lapack_int itype, char jobz,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_Z2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_zstedc.c b/LAPACKE/src/lapacke_zstedc.c
index 1bd7274c1..665c4414f 100644
--- a/LAPACKE/src/lapacke_zstedc.c
+++ b/LAPACKE/src/lapacke_zstedc.c
@@ -74,7 +74,7 @@ lapack_int LAPACKE_zstedc( int matrix_layout, char compz, lapack_int n,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lrwork = (lapack_int)rwork_query;
     lwork = LAPACK_Z2INT( work_query );
     /* Allocate memory for work arrays */
diff --git a/LAPACKE/src/lapacke_zstegr.c b/LAPACKE/src/lapacke_zstegr.c
index 2a65dcc4d..07b5ce81d 100644
--- a/LAPACKE/src/lapacke_zstegr.c
+++ b/LAPACKE/src/lapacke_zstegr.c
@@ -82,7 +82,7 @@ lapack_int LAPACKE_zstegr( int matrix_layout, char jobz, char range,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_zstemr.c b/LAPACKE/src/lapacke_zstemr.c
index c1144488e..d1d1d5692 100644
--- a/LAPACKE/src/lapacke_zstemr.c
+++ b/LAPACKE/src/lapacke_zstemr.c
@@ -75,7 +75,7 @@ lapack_int LAPACKE_zstemr( int matrix_layout, char jobz, char range,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = (lapack_int)work_query;
     /* Allocate memory for work arrays */
     iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
diff --git a/LAPACKE/src/lapacke_ztgsen.c b/LAPACKE/src/lapacke_ztgsen.c
index 60f48ba8f..f6f58becd 100644
--- a/LAPACKE/src/lapacke_ztgsen.c
+++ b/LAPACKE/src/lapacke_ztgsen.c
@@ -84,7 +84,7 @@ lapack_int LAPACKE_ztgsen( int matrix_layout, lapack_int ijob,
     if( info != 0 ) {
         goto exit_level_0;
     }
-    liwork = (lapack_int)iwork_query;
+    liwork = iwork_query;
     lwork = LAPACK_Z2INT( work_query );
     /* Allocate memory for work arrays */
     if( ijob != 0 ) {
