why time limit exceeds for this problem ?? I am unable to understand

#include<stdio.h>
int count(unsigned long long x)
{
unsigned long long m1=0x5555555555555555ULL;
unsigned long long m2=0x3333333333333333ULL;
unsigned long long m4=0x0f0f0f0f0f0f0f0fULL;
unsigned long long m8=0x00ff00ff00ff00ffULL;
unsigned long long m16=0x0000ffff0000ffffULL;
unsigned long long m32=0x00000000ffffffffULL;
unsigned long long h01=0x0101010101010101ULL;

x-= (x>>1)& m1;
x=(x& m2) +((x>>2)& m2);
x=(x+(x>>4)) & m4;
return (x*h01)>>56;

}
int main()
{
unsigned long long n,q;
int c,l,u,diff;
scanf("%lld %lld",&n,&q);
unsigned long long a=0;
while(q>0)
{
unsigned long long int x;
scanf("%d %d %d",&c,&l,&u);
diff=u-l+1;x=0;
while(diff–){ x=(x<<1)+1;}
x=x<<(n-u-1);
if(c==0) {a=a^x;}
else printf("%d\n",count(a&x));
q–;
}
return 0;
}

Here is a link to the solution…somebody please help me to find out which statement is causing time limit to exceed 2 seconds…

http://www.codechef.com/viewsolution/2815802