#include <std.h>
double EXP();
double SIN();
double difftime();
static int J {0};

VOID none5()
{
	J = 1;
}
VOID none4()
{
	none5();
}
VOID none3()
{
	none4();
}
VOID none2()
{
	none3();
}
VOID none1()
{
	none2();
}
VOID value5(I) int I;
{
	I = 1;
}
VOID value4(I) int I;
{
	value5(I);
}
VOID value3(I) int I;
{
	value4(I);
}
VOID value2(I) int I;
{
	value3(I);
}
VOID value1(I) int I;
{
	value2(I);
}

VOID refer5(I) int *I;
{
	*I = 1;
}
VOID refer4(I) int *I;
{
	refer5(I);
}
VOID refer3(I) int *I;
{
	refer4(I);
}
VOID refer2(I) int *I;
{
	refer3(I);
}
VOID refer1(I) int *I;
{
	refer2(I);
}

VOID main()
{
register int K,MYRIAD,TEN,L;
register double X,Y,t;
double t0;
int MATRIX[11];

	MYRIAD = 10000;
	TEN = 10;

	t = difftime(0.0);
	t0 = t;
	for (K = 1; K <= MYRIAD; K++)
	{
	}
	putfmt("\nMagnifier	%7.2f sec\n",difftime(t));

	t = difftime(0.0);
	for (K = 1 ; K <= MYRIAD; K++)
	{
	  for (J = 1; J <= TEN; J++)
	  {
	  }
	}
	putfmt("FOR loop	%7.2f sec\n",difftime(t));

	t = difftime(0.0);
	for (K = 1; K <= MYRIAD; K++)
	{
		J = 1;
		while (J < TEN)
			J = J + 1;
	}
	putfmt("WHILE loop	%7.2f sec\n",difftime(t));

	t = difftime(0.0);
	for (K = 1; K <= MYRIAD; K++)
	{
		J = 1;
		do	{
			J = J + 1;
			} while (!(TEN < J));
	}
	putfmt("REPEAT loop	%7.2f sec\n",difftime(t));

	t = difftime(0.0);
	for (K = 1; K <= MYRIAD; K++)
	{
	  for (J = 1; J <= TEN; J++)
	  {
		L = 0;
	  }
	}
	putfmt("Literal assign	%7.2f sec\n",difftime(t));

	t = difftime(0.0);
	for (K = 1; K <= MYRIAD; K++)
	{
	  for (J = 1 ; J <= TEN; J++)
	  {
		L = J;
	  }
	}
	putfmt("Memory access	%7.2f sec\n",difftime(t));

	t = difftime(0.0);
	for (K = 1 ; K <= MYRIAD; K++)
	{
		X = (double)K / 2.0 * 3.0 + 4.0 - 5.0;
	}
	putfmt("Real arithmetic	%7.2f sec\n",difftime(t));

	t = difftime(0.0);
	for (K = 1; K <= MYRIAD; K++)
	{
		X = (double)K / (double)K * (double)K + (double)K - (double)K;
	}
	putfmt("Real algebra	%7.2f sec\n",difftime(t));

	t = difftime(0.0);
	MATRIX[0] = 1;
	for (K = 1; K <= MYRIAD; K++)
	{
	  for (J = 1 ; J <= TEN; J++)
	  {
		MATRIX[J] = MATRIX[J - 1];
	  }
	}
	putfmt("Vector		%7.2f sec\n",difftime(t));

	t = difftime(0.0);
	for (K = 1; K <= MYRIAD; K++)
	{
	  for (J = 1; J <= TEN; J++)
	  {
		if (J < 6)
			L = 1;
		else
			L = 0;
	  }
	}
	putfmt("Equal IF	%7.2f sec\n",difftime(t));

	t = difftime(0.0);
	for (K = 1; K <= MYRIAD; K++)
	{
	  for (J = 1; J <= TEN; J++)
	  {
		if (J < 2)
			L = 1;
		else
			L = 0;
	  }
	}
	putfmt("Unequal IF	%7.2f sec\n",difftime(t));

	t = difftime(0.0);
	J = 0;
	for (K = 1 ; K <= MYRIAD; K++)
	{
		none1();
	}
	putfmt("No parameters	%7.2f sec\n",difftime(t));

	t = difftime(0.0);
	J = 0;
	for (K = 1; K <= MYRIAD; K++)
	{
		value1(J);
	}
	putfmt("Value		%7.2f sec\n",difftime(t));

	t = difftime(0.0);
	J = 0;
	for (K = 1; K <= MYRIAD; K++)
	{
		refer1(&J);
	}
	putfmt("Reference	%7.2f sec\n",difftime(t));

	t = difftime(0.0);
	for (K = 1; K <= MYRIAD; K++)
	{
		X = EXP(K / 1000.0);
		Y = SIN((double)K);
	}
	putfmt("Maths		%7.2f sec\n",difftime(t));

	putfmt("End of PCW benchmark. Total time %7.2f sec\n",difftime(t0));
}
