Decomposable searching problems and circuit optimization by retiming: two studies in general transformations of computational structures