Note that clang elides the loop and performs in constant time. Note also that changing the types of some of the variable signatures form long to int removes the optimization.
I'd like to see a programming environment that integrated something like this directly; this seems like it could, if done cleverly, do an enormous amount for the leaky-abstractions problem. Something that was designed such that you could easily work with and analyze your code in the high-level and low-level views. Not to mention, having the machine be right there next to your code, with their correspondences clearly marked, would do an enormous amount to demystify what your code's really doing on the lower levels.
(I think there's a glimmer of an idea in here for what a future programming system might look like, that allows us to use high-level abstractions and other ergonomic programming concepts AND actually think about the metal and how to use it directly at the same time. Something something interactive compilation...)
I used early versions of this before it was in GitHub. Glad to see it is progressing. It worked very well and have been in using it regularly. Can't wait to upgrade!
Funny how I seem to have misused godbolt all the time, only being interesting in the output of a piece of code or comparing some compilers, not really caring for the assembly code :P
As for this I'd have to a) install emacs (shush) and b) install all those compilers I don't have installed
Godbolt is pretty useful. It is a good idea to start by turning off compiler optimizations.