16 and 5345344 are the same answers clang gets for both C and C++, for all CPU types I tried. It's an interesting question why gcc and g++ would get different answers.
Another AMAZING change of value (which the concept is very likely to be how you described, where it is changes in order of the calculations, has a big impact on the final answers), is when you leave the source code unchanged.
Except for where the integer variable i, is declared. Between before main(), and declaring it within the main() {} codeblocks.
When it is before main(), the value changes to (as detailed in a much earlier post of mine, in this thread):
Demo1 = i = 0
Demo2 = i = -1554387584
EDIT: Unable to reproduce these strange values, using the online compiler, as it comes up with the same values as before. But I can still reproduce these values by using my local Linux machines GCC version:
gcc --version
gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0
So it is probably because the online version uses strange memory models,
or my local GCC has bug(s), applicable to this issue or some other explanation.
End of EDIT.
I'm amazed, that just changing where/how an integer is declared, changes its calculated value, like that.
Usually, such a change in allocation, would be invisible to the C/C++ code. Unless other C/C++ files attempt to access the variable and/or its operations are timed extremely carefully. I've seen slight (tiny) timing variations, because it is on the stack, heap, somewhere in memory or in registers, depending on the compiler, cpu, implementation, optimisation level, etc.
Maybe it is a "race hazard", between different initialisation sections of the C/C++ code, or other peculiarities ?
But there are many other possible explanations.
If I get the inclination, I may spend time, and try and find out why this happens.