maximise BITWISE AND find an integer in range [L,R]


Given an integer x
find y in range L<=y<=R so that x & y is maximum & is Bitwise AND where 0< L, R <10^12 I had tried to iterate and solve but it is resulting in TLE