Assume I have a function like this :
int recursivefunction (int n) {
if (n>10) return n; /* terminal case */
elseif (n>5) return n*recursivefunction(n-1); /* non tail call*/
else return recursivefunction(n-1); /* tail call
Will the third recursive call be optimized as a tail call ? If not why not ? We could replace this third return statement by an assembly code that clears the current function stack frame, except for local variables passed to the next call, and a goto to the adress of the function, this way no space on the stack is reserved.