The statements are completely independent of each other, so I am worried that the compiler may not respect the ordering in the code.
No, it will. It's possible that other threads may observe the results of the operations out of order - but from the perspective of the executing thread, it will definitely execute in order.