-rw-r--r-- 546 saferewrite-20240622/src/int8_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 int8_ones_num(int8_t x) { uint8_t y = x; return sum64(y); }