自分用のミニライブラリ#1
(1) popcnt64 (from bla/kp0024.c)
int popcnt64(unsigned long long b)
{
b -= b >> 1 & 0x5555555555555555ULL;
b = (b & 0x3333333333333333ULL) + (b >> 2 & 0x3333333333333333ULL);
b = (b + (b >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
return (b * 0x0101010101010101ULL) >> 56;
}
(2) popcnt32
int popcnt32(unsigned int b)
{
b -= b >> 1 & 0x55555555U;
b = (b & 0x33333333U) + (b >> 2 & 0x33333333U);
b = (b + (b >> 4)) & 0x0f0f0f0fU;
return (b * 0x01010101U) >> 24;
}
(3) cc.bat
c:\mingw\bin\gcc.exe -o %1.exe -Wall -Wextra -Wl,-s -O3 %1.c %2 %3 %4 %5 %6 %7 %8 %9