Question: Q1. Sopts [Exercise 16.2] Consider the program given below: 1: 2: 3: 4: 5: 6: void test Fn (int *x, int flag) { while (flag

 Q1. Sopts [Exercise 16.2] Consider the program given below: 1: 2:

Q1. Sopts [Exercise 16.2] Consider the program given below: 1: 2: 3: 4: 5: 6: void test Fn (int *x, int flag) { while (flag != 1) { flag = 1; *x = flag; // *x: value pointed by the pointer x (dereferenced) } if (*x >0) *x += 2; return; } 7: 8: 9: In answering the questions below, assume that x is not NULL. (a) Draw the control-flow graph (CFG) of this program. Identify the basic blocks with unique IDs starting with 1. Note that we have added a dummy source node, numbered 0, to represent the entry to the function. For convenience, we have also introduced a dummy sink node, although this is not strictly required (refer to the figure below). 0 Dummy source node 16 Your CFG to be completed n Dummy sink node (b) Is there a bound on the number of iterations of the while loop? Justify your answer. (c) How many total paths does this program have? How many of them are feasible, and why? (d) Write down the system of flow constraints (i.e., X0, X1, ...), including any logical flow constraints (e.g., dab + dcd = f), for the control-flow graph of this program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!