Used regular expressions to convert do to opt whenever possible.
For example,
if\s*\(\s*(.*)\s*!= NULL\) \{\s*\n(\s*)(?:\1\n?\s*= )?FREEdoFreeTree\s*\(\s*\1\);\n\s*\}
to
$1 = FREEoptFreeTree ($1);
And similarly for FREEdoFreeNode
and TRAVdo
, and for slight variations.
Thanks to Michiel for providing this regex.