This patch refactors BAT to be testable as a library, so we
can have open-source tests on it. This further fixes an issue with
basic blocks that lack a valid input offset, making BAT omit those
when writing translation tables.
Test Plan: new testcases added, new testing tool added (llvm-bat-dump)
Unrelated to this patch: we need to iterate over the copy of BBs as we increase the size inside the loop potentially invalidating the iterator.