bsoundra
bsoundra

Reputation: 970

Tool for removing all the loops in C code

Is there any tool available for converting a C code with loops (while , do-while, for) to a C code with goto statements instead of the looping statements?

I tried Clang. I changed the code to the IR and converted it back , but the code totally different (more lines, following the SSA format, ..) though logically meaning the same.

It would be better if the resultant code looks more alike the original source code. If not, I would like to know about the different other options available.

Upvotes: 1

Views: 192

Answers (1)

nmichaels
nmichaels

Reputation: 50941

It's called a compiler. Not only will it turn all those neat and orderly loop constructs in your code into jump instructions, but it lets the original code remain totally unchanged and easy to maintain.

Special added bonus: compilers have tricks for speeding up your code, so it will run even faster than if you had just naively converted your C to assembler. </snark>

Upvotes: 3

Related Questions