'Loop Unrolling from C to C [closed]

I need to build a tool which can unroll loops of programs written in C. The only catch is that the target language has still to be C.

I thought about using llvm compiler to compile C to llvm-IR and to do the loop unrolling. Then I would use this llvm-C-backend to translate the unrolled code in llvm-IR back to C.

Does somebody have other Ideas?
Is there a tool that performs loop unrolling directly on an AST representation of C?
If there is no such tool how would I go about implementing it myself?

(I need to do this to extend a special tool which translates C code with "normal" arithmetic to C code with interval arithmetic. It should perform better when first unrolling loops)

Unfortunately my google search efforts did not turn up much, and I have come to the realization that what I want to do is a very niche thing.

I'd be very grateful if somebody could point me in the right direction.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source