Well I am aware of the XOR operation. However, the case is some operation is returning me the ANDed value and I have to extract the first operand and all I know is the result of ANDing and the second operand for AND.
If you do come up with an answer, however, please post, as prime numbers show some interesting behaviour in logic arithmetic, so being able to undo logical operations could be a really powerful thing to do.....
Unfortunately, that is impossible in the general case. If any bit of y is 0, then you cannot reverse the operation. And if all bits of y are 1, then x & y == x, so an algorythm that finds the inverse of the bitwise (or logical) and operation is basically useless.