Question: I need you to generate both the unoptimized and optimized assembly code from the C source code, which I ve provided to you in both

I need you to generate both the unoptimized and optimized assembly code from the C source code, which Ive provided to you in both image form and text form just in case to avoid any indenting errors from the text version down below. I need the assembly code for both the unoptimized and optimized versions. I repeat I am asking for the ACTUAL CODE of both the unoptimized and optimized versions, not how to do it. I have had this problem already where the person that tried to solve this didn't actually give me the code for both unoptimized and optimized. Please make sure to give me the actual code for both.
If you're somehow unsure how to generate these files, I believe you can use the following commands:
For unoptimized assembly:
gcc -Wa,-adhln -g -masm=intel -m32"Project 2.c">"Project 2-g.asm"
For optimized assembly:
gcc -Wa,-adhln -O -masm=intel -m32"Project 2.c">"Project 2-o.asm"
Once you generate these, please send both the codes of the unoptimized and optimized and let me know which one is which. Thank you!
/*GCC */
/*gcc -Wa,-adhln -g -masm=intel -m32"Project 2.c">"Project 2-g.asm" */
/*gcc -Wa,-adhln -O -masm=intel -m32"Project 2.c">"Project 2-o.asm" */
#include
#define NOINLINE __attribute__((noinline))
static NOINLINE int function1(int x,int y)
{
int i;
int sum;
int values[10];
sum =0;
for (i =0; i 10; i++){
values[i]=10+i +2*x *y;
sum +=values[i];
}
return (sum);
}
static int NOINLINE function2(int *values,int valuesLen)
{
int i;
int sum1;
int sum2;
int v;
sum1=0;
sum2=0;
for (i =0; i valuesLen; i++){
v =values[i];
if (v >0)
sum1+=v;
else
sum2+=v;
}
return (sum1+sum2);
}
static NOINLINE int function3(int x)
{
int y;
y =x /10;
return (y);
}
static NOINLINE int function4(int a,int b,int c,int d)
{
int r;
if (a >b)
r =b;
else if (a >c)
r =4*a;
else if (a >d)
r =8*a;
else
r =-1;
return (r);
}
static NOINLINE unsigned int function5(unsigned int x)
{
unsigned int x1;
unsigned int x2;
unsigned int x3;
x1=x *32;
x2=x /16;
x3=x %8;
return (x1+x2+x3);
}
int main(int argc, char **argv)
{
int i;
int j;
int k;
int values[10];
i =5;
j =8;
k =function1(i,j);
printf("function1: i =%d,j =%d,k =%d
",i,j,k);
for (i =0; i 10; i++){
values[i]=i +j;
}
k =function2(values,10);
printf("function2: k =%d
",k);
k =function3(100);
printf("function3: k =%d
",k);
k =function4(1,2,3,4);
printf("function4: k =%d
",k);
k =function5(100);
printf("function5: k =%d
",k);
return (0);
}
I need you to generate both the unoptimized and

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 Programming Questions!