Ab initio crystal structure prediction. II. Flexible molecules