Question: Problem 2 : Consider the following C function. ( 1 ) Convert it into IR in a three - address code format ( using operations

Problem 2: Consider the following C function.
(1) Convert it into IR in a three-address code format (using operations similar to those mentioned in the slides; no need to cover parameter passing or variable declaration/allocation)
(2) Draw the control-flow graph (CFG) for your three-address code
int factorial(int n){
if (n ==0|| n ==1){
return 1;
} else {
int result =1;
for (int i =2; i <= n; ++i){
result *= i;
}
return result;
}
}

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!