Bifunctional resistive switching behavior in an organolead halide perovskite based Ag/CH3NH3PbI3−xClx/FTO structure