I'm reversing an embedded code, and faced with this "while" loop in while decompiling:

A while loop that I need to be shown as "for" loop

It's more readable for me if a "for" loop be shown instead a "while", i.e.:

while (1)                  -->            for (i = 0; i < 2; i ++) 
{                          -->            {
  "SOME EXPRESSION"        -->              "SOME EXPRESSION"
  if (++i >= 2) return;    -->            
}                          -->            }

Is it possible to ask IDA Decompiler to show this loop in my own way?

1 Answer 1


If you write a Hex-Rays plugin to change the while loop to a for loop yourself, then yes, you can do it. If you're looking for something more like the ability to right-click on the loop and click Display as for loop, nothing like that is built in.

  • @ Rolf Rolles Thanks for your answer Rolf. Do you know any plugin for that purpose or or any"like but not exact" sample or some python/IDC APIs to help me write my own?
    – E.A
    Commented Apr 17, 2023 at 4:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.