There may be an assumption that since it *pis volatile access, its value may differ during each assessment, and therefore you should evaluate it only once:
int q = *p;
return q * q;
This, of course, is a stupid design; the function must be valid int square(int), and the caller must say square(*p).
source
share