Question: The following C code sets the diagonal elements of one of our fixed-size arrays to val: When compiled with optimization level -01, GCC generates the
The following C code sets the diagonal elements of one of our fixed-size arrays to val:

When compiled with optimization level -01, GCC generates the following assembly code:

Create a C code program fix_set_diag_opt that uses optimizations similar to those in the assembly code, in the same style as the code in Figure 3.37(b). Use expressions involving the parameter N rather than integer constants, so that your code will work correctly if N is redefined.
Figure 3.37(b)

/* Set all diagonal elements to val */ void fix_set_diag(fix_matrix A, int val) { } long i; for (i 0; i < N; i++) A [i] [i] = val;
Step by Step Solution
There are 3 Steps involved in it
This exercise requires that you be able to study compilergenerated assembly code to understand what ... View full answer
Get step-by-step solutions from verified subject matter experts
