Intermediate Code

Answer & solution
Official answer: C
A branch target may not be known when its branch instruction is first generated. Backpatching emits the instruction with a placeholder target and records its location on a list. Later, when the target's instruction address becomes known, the compiler fills that field without rereading the source.
For a Boolean expression such as a<b && c<d, the compiler can keep true and false lists. A true branch from the first comparison is patched to the start of the second comparison; the final true/false branches are patched to the enclosing statement's destinations. This supports short-circuit Boolean code in one pass, so I is true.
For an if, while, or similar statement, next lists and branch lists are patched when the following block, loop test, or exit becomes known. Thus flow-of-control code can also be generated in one pass, making II true. “One pass” does not prohibit editing previously emitted target fields; that editing is precisely the role of backpatching. Answer: C.
![Question 43, GATE 2024: Expression x[i]=(p+r)*−s[i]+u/w has triples (0) + p r; (1) missing; (2) uminus (1); (3) missing; (4) / u w; (5) + (3) (4); (6) missing; (7) = (6) (5). A fills (1) =[] s i, (3) * (0) (2), (6) []= x i. B uses []= s i, subtraction, =[] x (5). C agrees with A except []= x (5). D uses []= s i, subtraction, =[] x i.](../../../assets/questions/CS-2024-S2-Q43-1.webp)


![Question 43, GATE 2017: Grammar: stmt→if expr then expr else expr; stmt | δ; expr→term relop term | term; term→id | number; id→a|b|c; number→[0–9]. δ is the empty statement and relop a relational operator. A program contains ten if terminals. Find its number of control-flow paths, counting the two branches of one if as two paths.](../../../assets/questions/CS-2017-S1-Q53-1.webp)



![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)
![Question 34, GATE 2014: A compiler accesses X[i][j][k] using byte-offset code t0=i*1024; t1=j*32; t2=k*4; t3=t1+t0; t4=t3+t2; t5=X[t4]. Integers are 32 bits, characters 8 bits. Which declaration matches? A int X[32][32][8]; B int X[4][1024][32]; C char X[4][32][8]; D char X[32][16][2].](../../../assets/questions/CS-2014-S2-Q44-1.webp)




