I think I can elaborate in simple words.
Firstly the upper limits of both L and R is in range of 10^15 , which hints it might be a pattern finding problem.
below is index , binary & values of XOR[i] where i is from 0 to 32
Index 
Binary 
Value 
0 
000000 
0 
1 
000001 
1 
2 
000011 
3 
3 
000000 
0 
4 
000100 
4 
5 
000001 
1 
6 
000111 
7 
7 
000000 
0 
8 
001000 
8 
9 
000001 
1 
10 
001011 
11 
11 
000000 
0 
12 
001100 
12 
13 
000001 
1 
14 
001111 
15 
15 
000000 
0 
16 
010000 
16 
17 
000001 
1 
18 
010011 
19 
19 
000000 
0 
20 
010100 
20 
21 
000001 
1 
22 
010111 
23 
23 
000000 
0 
24 
011000 
24 
25 
000001 
1 
26 
011011 
27 
27 
000000 
0 
28 
011100 
28 
29 
000001 
1 
30 
011111 
31 
31 
000000 
0 
32 
100000 
32 
We can make 2 important deductions from this

There is 0 at 3 , 7 , 11 , 15 , 19… i.e at 4n1th term ( where n starts from 1 )

XOR of range of every 4 elements is 2. i.e. XOR(0 , 3) = 2 , XOR(4,7) = 2 , XOR(8,11) = 2
Hence using above two deductions we our required range XOR.
eg. L = 2 R = 16
we know that, XOR (4,7) = (8,11) = (12,15) = 2
Therefore 2 ^ 2 ^2 = 2
if number of twos in given range is even, then their XOR wil be 0 , else XOR will be 2
now using 1st property can find XOR(2,4).
now using the total result, go XORING till R = 16 to get final answer.
If you understood till 2 deductions, you can use any approach to apply that.