Quantum circuit synthesis and optimisation