What does the c++ code compile too?

Any chance you call the function with fixed values, so the multiply and addition are optimized away, making the function simply return a fixed number?