Left shifting 64-bit variable more than 30 bits in a function which gets inlined and is called inside a loop creates wrong results when build with x64 compiler and optimizations.
The problem disappears with any of the following changes:
1. Optimizations are removed.
2. Function() is declared with __declspec(noinline).
3. Comment away the line which prints LSHIFT so it is not used elsewhere than in the calculation.
4. The for-loop around Function() call is removed.
While the sample itself is meaningless it is derived from a more complex use case with your sample code which slightly modified exhibits the same problem.