Intermediate Code
![Question 44, GATE 2015: Intermediate code:1 i=1; 2 j=1; 3 t1=5*i; 4 t2=t1+j; 5 t3=4*t2; 6 t4=t3; 7 a[t4]=−1; 8 j=j+1; 9 if j≤5 goto 3; 10 i=i+1; 11 if i<5 goto 2. CFG node/edge counts using entry/exit nodes: A5, 7; B6, 7; C5, 5; D7, 8.](../../assets/questions/CS-2015-S2-Q44-1.webp)
Answer & solution
Official answer: B
Our answer: B with explicit entry and exit nodes
Leaders split the code into blocks[1], [2], [3..9], [10..11]. Add separate entry and exit nodes: 6 nodes. Edges are entry→B1, B1→B2, B2→B3, B3→B3, B3→B4, B4→B2, B4→exit: 7. Thus B. Without explicit entry/exit nodes, counts differ; the official choice uses them.
Leaders are statement 1, start 2(target of 11), start 3(target of 9), and 10(after conditional 9). Group straight-line instructions until each branch: B1=[1], B2=[2], B3=[3…9], B4=[10…11]. B3 has a self-loop when j≤5 and a fallthrough to B4; B4 returns to B2 when i<5 and otherwise exits. Add entry→B1, B1→B2, B2→B3 and the two B4 edges: seven edges over four blocks plus entry/exit=6 nodes. State the node-count convention rather than hiding these extra nodes.