-rw-r--r-- 551 saferewrite-20240807/src/uint32_ones_num/ref/ones_num.c raw
#include <inttypes.h>
int sum1(unsigned long long x) { return 1 & x; }
int sum2(unsigned long long x) { return sum1(x) + sum1(x >> 1); }
int sum4(unsigned long long x) { return sum2(x) + sum2(x >> 2); }
int sum8(unsigned long long x) { return sum4(x) + sum4(x >> 4); }
int sum16(unsigned long long x) { return sum8(x) + sum8(x >> 8); }
int sum32(unsigned long long x) { return sum16(x) + sum16(x >> 16); }
int sum64(unsigned long long x) { return sum32(x) + sum32(x >> 32); }
int uint32_ones_num(uint32_t x)
{
uint32_t y = x;
return sum64(y);
}