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

Currently, this includes the preoptimizer, aka dce, as well
as the optimization via Closure.
Merge pull request #377 from sjrd/factor-out-tools

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