Mechanism of the decomposition of ammonium perchlorate