+ 2
What is the purpose of this obfuscated C code?
Here is a snippet of some strange C code I found. Capital letters are int functions and lower case variables are ints. Assume they've all been defined. while(x&&D(x-1),(x/=2)%2&&(1)){ ... ... u/2&(x/=2)%2&&(c=P(t,c),u=S(4,13,-4,t),t=9) } Why x&&D(x-1)? Does the && operator change the operands? If not, it doesn't do anything... right? Why (x/=2)%2&&(1) instead of (x/=2)%2? I thought a&&1 is the same as a. Why does the last line update some vars but not assign the overall result to anything?
14 Respuestas
+ 5
In some cases we need to take short-circuiting into effect. For example 'x&&D(x-1)' is
if(x != 0) { D(x-1); }, or shorter
if(x) D(x-1);
Similarly for the last line of the loop body. That can be rewritten as
x /= 2;
if( (u/2 == 1) && (x % 2 == 1) ) {
c = P(t, c);
u = S(4, 13, -4, t);
t = 9;
}
The condition of the if-clause can, of course, be shortened.
But the &&(1) remains a mystery.
+ 3
Ani Jona 🕊
feels like &&(1) is redundant, since that part is always true.
+ 3
Bob_Li right, so why it is there I cannot explain :)
+ 3
A rather weak one, would it not be? 🤔
+ 3
Could also be a misspelling of
(x/=2)%2&(1)
I don't know if the above excerpt is free of bugs...
+ 2
hard to tell.
+ 1
obsfucation?
+ 1
Ani Jona 🕊 thank you for the answer! I forgot about short circuiting, but now it makes way more sense. I think the &&(1) is needed just because this code has many more copies of (x/=2)%2&&, which were all compressed into macros. The code is for something called Loader's number, for context: https://googology.fandom.com/wiki/Loader%27s_number
+ 1
Jacob Dreiling
https://googology.fandom.com/wiki/Loader%27s_number
are you sure it's not a spell for summoning ancient demons...😅
Ok, I will show myself out....
+ 1
Bob_Li it really does look like a dark summoning spell haha
+ 1
Jacob Dreiling
Ok, I think I found a more beginner friendly explanation for Loader's Number. Doesn't mean I totally get it, but if I squint my eyes, I can fool myself into thinking that I do...🤨
https://googology.fandom.com/wiki/User_blog:Upquark11111/An_Explanation_of_Loader%27s_Number
+ 1
Bob_Li that looks very helpful indeed. I'm going to try reading it over the next few days
+ 1
I skimmed that article and have a question. This is pretty heavy on the lambda calculus. Would using something like haskell or clojure be better suited for this task?
0
Hey