I have been told that x ^ ROR(x, 13) = 0x936f2a8247534566
^ is the XOR operator, like in C, and ROR() is a function that rotates-right the bits of the input by the specified number of positions, like the Intel processor instruction.
The question is how do I find x. It seems a lot of possibilities to try every 64-bit combination, maybe there is a better way?
This algorithm
unsigned long long res = 0;
int bit = 1;
for (int k = 0, shift = 0; k < 64; k++, shift = (shift + 13) % 64)
{
if (bit)
res |= 1ull << shift;
if (0x936f2a8247534566 & (1ull << shift))
bit = 1 - bit;
}
gives the answer
0x1337b33fdeadb00b
And if we start start with bit = 0, the answer is
0xecc84cc021524ff4
The idea is the following. If the last bit of 0x936f2a8247534566 is 0, it means that bit[13] ^ bit[0] == 0, hence bits are equal. Otherwise bit[0] and bit[13] are different.
The same logic applies to bit[13] and bit[26], etc. So basically the number 0x936f2a8247534566 tells us which bits of the original number are equal to each other and which are not.
Since with step 13 we get all possible positions between 0 and 63(inclusive), we need just one loop.