-rw-r--r-- 551 saferewrite-20240620/src/uint16_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 uint16_ones_num(uint16_t x) { uint16_t y = x; return sum64(y); }