Double, XOR and do it again We define the function g as g(n) = n XOR (n * 2) for any integer n &gt; 0.
Given x &gt; 0, find the smallest integer y &gt; 0 such that gk(y) = x for some k &gt; 0.
Example
x = 549

549 = 483 XOR (483 * 2)     (as binary: 1000100101 = 111100011 XOR 1111000110)
483 = 161 XOR (161 * 2)     (as binary:  111100011 =  10100001 XOR  101000010)

Which means that g2(161) = 549. We can't go any further, as there is no n such that g(n) = 161. So, the expected output for x = 549 is y = 161.
Rules

You are not supposed to support invalid entries. A pair (y, k) is guaranteed to exist for the input value x.
This is code-golf, so the shortest answer in bytes wins!

Test cases
     3 --&gt;     1
     5 --&gt;     1
     6 --&gt;     2
     9 --&gt;     7
    10 --&gt;     2
    23 --&gt;    13
    85 --&gt;     1
   549 --&gt;   161
   960 --&gt;    64
  1023 --&gt;   341
  1155 --&gt;   213
  1542 --&gt;     2
  9999 --&gt;  2819
 57308 --&gt; 19124
 57311 --&gt;   223
983055 --&gt;     1
Java 8, 68 57 53 52 bytes

n-&gt;{for(int i=0;i&lt;n;)i-=(i*2^i)==n?n=i:-1;return n;}

-5 bytes thanks to @OlivierGrégoire.
Try it online.
Explanation:
n-&gt;{                 // Method with integer as both parameter and return-type
  for(int i=0;i&lt;n;)  //  Loop `i` in the range (1,n)
    i-=(i*2^i)==n?   //   If `i*2` XOR-ed with `i` equals `n`
        n=i          //    Set `n` to `i`, and set `i` to 0 to reset the loop
       :             //   Else:
        -1;          //    Increase `i` by 1 to go to the next iteration
  return n;}         //  Return `n` after the entire loop