with some difficulty , he extracted the rifle from his trousers , and reaching into his pocket pulled out the magazine , and clipped it to the rifle , with a small click , as it went smoothly into position .