Any unitary operation in quantum information processing can be implemented via a sequence of simpler steps - quantum gates. However, actual implementation of a quantum gate is always imperfect and takes a finite time. Therefore, searching for a short sequence of gates - efficient quantum circuit for a given operation, is an important task. We contribute to this issue by proposing optimization of the well-known universal procedure proposed by Barenco et al. [Phys. Rev. A 52, 3457 (1995)]. We also created a computer program which realizes both Barenco’s decomposition and the proposed optimization. Furthermore, our optimization can be applied to any quantum circuit containing generalized Toffoli gates, including basic quantum gate circuits.