Too lazy to write something long and well thought now
Just a bit disappointed by how bad Clojure’s performance are (but hey, immutability is not free!) and by how damn difficult it is to improve them.
I found out that the timing of the C version goes down to ~2ms if I just declare the variables as int and not unsigned int. That’s amazing!
Half I year later I finally know why the version with signed integers actually takes less than the version with unsigned ints.
It’s caused by C compiler’s optimizations: for signed integers it doesn’t need to generate assembly code to handle overflows (because it’s declared undefined behaviour in the standard) while it has to do it for unsigned integers (that are defined to wrap).
Check The Value of Undefined Behavior for more info about this topic.