Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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: 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started