Physical optimization of quantum error correction circuits