```
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
typedef struct {
float x;
float y;
} FPoint;
void testMultiplySquared(void) {
register double counter, counterSquared;
for (counter = 0.0; counter <= 10000000000.0; counter += 1.0) {
counterSquared = counter * counter;
}
}
void testPowSquared(void) {
register double counter, counterSquared;
for (counter = 0.0; counter <= 10000000000.0; counter += 1.0) {
counterSquared = pow(counter, 2.0);
}
}
FPoint calculateHypotenuseWithTrig( FPoint origin, float TB, float TH, float LH ){
float tAngleOfShift = atan( TB / TH );
float tMidpointX = TB / 2;
float tMidpointY = TH / 2;
float tAngularShiftX = cos( tAngleOfShift ) * (LH / 2);
float tAngularShiftY = sin( tAngleOfShift ) * (LH / 2);
float tTotalXShiftValue = tMidpointX + tAngularShiftX;
float tTotalYShiftValue = tMidpointY + tAngularShiftY;
FPoint nHypotenuseLayerAnchorPoint;
nHypotenuseLayerAnchorPoint.x = origin.x + tTotalXShiftValue;
nHypotenuseLayerAnchorPoint.y = origin.y + tTotalYShiftValue;
return nHypotenuseLayerAnchorPoint;
}
FPoint calculateHypotenuseWithTriangles( FPoint origin, float TB, float TH, float LH ){
float ratio = (LH/2.0f)/sqrtf(powf(TB, 2.0f)+powf(TH, 2.0f));
FPoint nHypotenuseLayerAnchorPoint;
nHypotenuseLayerAnchorPoint.x = origin.x+(TB/2.0f)+(TH*ratio);
nHypotenuseLayerAnchorPoint.y = origin.y+(TH/2.0f)+(TB*ratio);
return nHypotenuseLayerAnchorPoint;
}
void testTrig(void) {
register int counter;
float factorFloat;
FPoint o;
o.x = 1.0f;
o.y = 1.0f;
int factor;
for (counter = 0 ; counter < 1000000000; counter++) {
factor = rand()%100000;
factorFloat = (float)factor/10000.0f;
o.x *= factorFloat;
o.y *= factorFloat;
o = calculateHypotenuseWithTrig(o, 5.0f*factorFloat, 3.0f*factorFloat, 6.0f*factorFloat);
}
}
void testTriangles(void) {
register int counter;
float factorFloat;
FPoint o;
o.x = 1.0f;
o.y = 1.0f;
int factor;
for (counter = 0 ; counter < 1000000000; counter++) {
factor = rand()%100000;
factorFloat = (float)factor/10000.0f;
o.x *= factorFloat;
o.y *= factorFloat;
o = calculateHypotenuseWithTriangles(o, 5.0f*factorFloat, 3.0f*factorFloat, 6.0f*factorFloat);
}
}
int main (int argc, const char * argv[]) {
//register double counter, counterSquared;
time_t t0;
t0 = time(NULL);
time_t tMultiply, tPow;
testMultiplySquared();
tMultiply = time(NULL);
testPowSquared();
tPow = time(NULL);
printf("multiply time %ld\n", (long)(tMultiply-t0));
printf("pow time %ld\n", (long)(tPow-tMultiply));
t0 = time(NULL);
time_t tTrig, tTriangle;
srand(1);
testTrig();
tTrig = time(NULL);
srand(1);
testTriangles();
tTriangle = time(NULL);
printf("trig time %ld\n", (long)(tTrig-t0));
printf("similar Triangle time %ld\n", (long)(tTriangle-tTrig));
return 0;
}
```