Fix #375: Factor out tools in a reusable library.

Currently, this includes the preoptimizer, aka dce, as well
as the optimization via Closure.