News for hackers. Stuff that matters.
Re:GodBolt: Enter C, get Assembly by 0x6c6f6c on Thursday December 15, 2016 @09:06AM (#13184602)
Alright maybe I'm stupid but I could have sworn that more than

    square(int):                             # @square(int)
        xor     eax, eax
        ret
is required to perform this, what's going on?
Re:GodBolt: Enter C, get Assembly by akeruu on Thursday December 15, 2016 @09:12AM (#13184635)
X can always by devided by 2, meaning the condition will always be false thus returning "a" unchanged. "xor eax, eax" is a shortcut to "mov eax, 0".
Re:GodBolt: Enter C, get Assembly by syncsynchalt on Thursday December 15, 2016 @05:44PM (#13189358)
"xor r,r" is intel-ese for "set r to zero". For various reasons it's faster and smaller than the more obvious "mov r,0".

From this we can see that gcc and clang have figured out that the "if" can never be true, then they elided the loop, then optimized out the variable, ending in the equivalent of "return 0;".