/*  

gcc -O2 -o factorial factorial.c

Assembler for the program can be produced by

gcc -O2 -S factorial.c

to execute with timing:

time ./factorial

*/


long fact (long x, long acc)
{
  if (x <= 1)
    return acc;
  else 
	return fact (x - 1, acc * x);
				  
}


#define N (1234567890)

int main ()
{
  printf("Factorial of %i calculates to (but isn't):  %i.\n", N, fact(N, 1));
}



/* 

The meat of the computation is in the instructions between labels L4 and L5.
There are 5 instructions in this section, and they're executed approximately
1,234,567,890 times in this example.  That's approximately 6,000,000,000
instructions executed over 6 seconds, which yields a result of 1,000 MIPs.

I would like a more precise explanation when you turn in the homework.

TODO: This number seems wrong, so check the process when you turn it in!

*/

