4 unsigned char popCount[] = {
5 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,
6 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
7 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
8 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
9 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
10 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
11 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
12 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
13 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
14 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
15 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
16 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
17 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
18 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
19 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
20 4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
25 static size_t allocated = 0;
27 void * bp_malloc(size_t n)
29 void * res = malloc(n);
31 fprintf(stderr, __FILE__ ": failure to allocate %lu bytes\n", (long unsigned int) n);
38 void bp_free(void * p)
42 size_t bp_get_alloc_stats(void)
46 void bp_reset_alloc_states(void)
51 int bp_setbit(unsigned int *B, int i,int x)
57 if (x==0) B[j] &= (~(1<<(D-1-l)));
58 else if (x==1) B[j] |= (1<<(D-1-l));
60 printf("error setbit x=%d\n",x);
66 int bp_setbits(unsigned int *B, int i, int d, int x)
71 bp_setbit(B,i+j,(x>>(d-j-1))&1);