Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Enter the C program in Listing 13.2.1. Using the -S compiler option, compile it with differing levels of optimization, i.e., -O1, -O2, -O3, and discuss

Enter the C program in Listing 13.2.1. Using the -S compiler option, compile it with differing levels of optimization, i.e., -O1, -O2, -O3, and discuss the assembly language that is generated. Compare the results with my solution in Listing 13.2.6. Is the optimized code easier or more difficult to read?

Listing 13.2.1 Code:

/* nineInts1.c

* Declares and adds nine integers.

* 2017-09-29: Bob Plantz

*/

#include

#include "sumNine1.h"

int main(void)

{

int total;

int a = 1;

int b = 2;

int c = 3;

int d = 4;

int e = 5;

int f = 6;

int g = 7;

int h = 8;

int i = 9;

total = sumNine(a, b, c, d, e, f, g, h, i);

printf("The sum is %i ", total);

return 0;

}

Listing 13.2.1 Sum the digits 0-9

Calls the function sumNine, showing the passing of nine arguments in C

Code in Listing 13.2.6.

/* sumNine1.c

* Computes sum of nine integers.

* 2017-09-29: Bob Plantz

*/

#include

#include "sumNine1.h"

int sumNine(int one, int two, int three, int four, int five,

int six, int seven, int eight, int nine)

{

int x;

x = one + two + three + four + five + six

+ seven + eight + nine;

return x;

}

Listing 13.2.3 Implementation file for sumNine function, which computes the integer sum of its nine arguments. (C)

Please explain thorougly and explain the differences between the code. Also is the code easier to read or more difficult and explain the answer.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions