I compiled a simple function in C with Optimizations:None and ran podump to see the generated assembly.
I need help understanding assembly of fx. I see there are two call ___sin but there is no call to cos. Any help appreciated.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double fx(double x)
{
return cos(x) + sin(x);
}
int main(void)
{
printf("%f\n", fx(M_PI_2));
}
podump /disasm main.obj
_fx:
[00000000] 55 push ebp
[00000001] 89E5 mov ebp,esp
[00000003] 83EC10 sub esp,10
[00000006] 6A01 push 1
[00000008] DD4508 fld qword ptr [ebp+8]
[0000000B] 83EC08 sub esp,8
[0000000E] DD1C24 fstp qword ptr [esp]
[00000011] E800000000 call ___sin
[00000016] 83C40C add esp,C
[00000019] DD5DF8 fstp qword ptr [ebp-8]
[0000001C] 6A00 push 0
[0000001E] DD4508 fld qword ptr [ebp+8]
[00000021] 83EC08 sub esp,8
[00000024] DD1C24 fstp qword ptr [esp]
[00000027] E800000000 call ___sin
[0000002C] 83C40C add esp,C
[0000002F] DD5DF0 fstp qword ptr [ebp-10]
[00000032] DD45F8 fld qword ptr [ebp-8]
[00000035] DC45F0 fadd qword ptr [ebp-10]
[00000038] 89EC mov esp,ebp
[0000003A] 5D pop ebp
[0000003B] C3 ret