<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Hello, <br clear="all"></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">To distinguish loops from if statements, I am doing the following steps:</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">1. I am using LoopFinder to find all the loops in a file and storing them in a list. </div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">2. If I encounter an 'if' statement, I check if it is the head of any of the loops in my list.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">3. If it is, then its a loop, otherwise its an 'if' statement.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">But, the above method does not accomodate the case when the loop head is not the predicate statement but some preparatory statement. For example, this loop: <i><span style="font-family:Arial,Helvetica,sans-serif">for(int i = 0; i<Sample.f3; i++) {}</span> </i>is converted into the following:</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><i>label7:<br>        i = i + 1;<br><br>     label8:<br>        $i2 = <Sample: int f3>;<br><br>        if i < $i2 goto label7;<br></i></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">and the loop head is not a predicate statement. How do I handle such cases? If I start going inside loop bodies to check for the predicate statements, the analysis might encounter a genuine 'if' statement inside the loop and classify as a loop. </div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Is it okay if I check only the first statement of the loop body if the loop header is not a predicate statement?</div><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font size="1" color="#9900ff" face="arial, helvetica, sans-serif">Regards</font><div><font size="1" color="#9900ff" face="arial, helvetica, sans-serif">Dhriti Khanna</font></div><div><font size="1" color="#9900ff" face="arial, helvetica, sans-serif">PhD Scholar</font></div><div><font size="1" color="#9900ff" face="arial, helvetica, sans-serif">IIIT Delhi</font></div></div></div></div></div></div></div></div></div></div></div></div></div></div>