#ifdef _MSC_VER
    #include <nmmintrin.h>
#else
    #include <popcntintrin.h>
#endif

#include <stdlib.h>

int main(void)
{
    long long a = 0;
    int b;
    
    a = random();
    b = random();
      
#ifdef _MSC_VER
    #ifdef _M_X64
    a = _mm_popcnt_u64(a);
    #endif
    b = _mm_popcnt_u32(b);
#else
    #ifdef __x86_64__
    a = __builtin_popcountll(a);
    #endif
    b = __builtin_popcount(b);
#endif
    return (int)a + b;
}

#ifdef _MSC_VER
    #include <nmmintrin.h>
#else
    #include <popcntintrin.h>
#endif

int main(void)
{
    long long a = 0;
    int b;
#ifdef _MSC_VER
    #ifdef _M_X64
    a = _mm_popcnt_u64(1);
    #endif
    b = _mm_popcnt_u32(1);
#else
    #ifdef __x86_64__
    a = __builtin_popcountll(1);
    #endif
    b = __builtin_popcount(1);
#endif
    return (int)a + b;
}

--- 
+++ 
@@ -4,20 +4,26 @@
     #include <popcntintrin.h>
 #endif
 
+#include <stdlib.h>
+
 int main(void)
 {
     long long a = 0;
     int b;
+    
+    a = random();
+    b = random();
+      
 #ifdef _MSC_VER
     #ifdef _M_X64
-    a = _mm_popcnt_u64(1);
+    a = _mm_popcnt_u64(a);
     #endif
-    b = _mm_popcnt_u32(1);
+    b = _mm_popcnt_u32(b);
 #else
     #ifdef __x86_64__
-    a = __builtin_popcountll(1);
+    a = __builtin_popcountll(a);
     #endif
-    b = __builtin_popcount(1);
+    b = __builtin_popcount(b);
 #endif
     return (int)a + b;
 }
Fix compile-time test of POPCNT

The compile-time test of POPCNT, cpu_popcnt.c produced code that would
execute without error even if the machine didn't support the popcnt
instruction. This patch attempts to use popcnt on random numbers so the
compiler can't substitute the answer at compile time.
