Rebase D2176 onto modern LLVM.
"This commit adds most of functions needed for introspection of the IR through the C API. It was inspired by additional functions defined in the llvm-general Haskell bindings, which can convert the IR losslessly into Haskell datatypes and vice versa."