How to split module?

Hi, all.

My question is about how to split one module into N modules(N >= 2)?
For example, given the following code:

I'd suggest looking at bugpoint and the llvm-extract tool. Both slice and dice modules in various ways. Look at the ExtractFunction.cpp in tools/bugpoint for example.