Another possibility is to develop your own plugin for GCC, or to develop a GCC MELT extension to do your task. But extending GCC (or Clang) requires understanding the internal representations of these compilers (Gimple & Tree for GCC) and this require some work. MELT is a high-level domain specific language to extend GCC.