A new algorithm for producing quantum circuits using KAK decompositions