Copied from lapack https://github.com/Reference-LAPACK/lapack/pull/127 by vladimir-ch (with earlier changes from echeresh's PR 115 "lapacke_*ormlq_work: move declarations under if" there as they touched some of the same files)