File: bdz_gen_lookup_table.c

package info (click to toggle)
glib2.0 2.84.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 66,144 kB
  • sloc: ansic: 538,877; python: 9,624; sh: 1,572; xml: 1,482; perl: 1,222; cpp: 535; makefile: 316; javascript: 11
file content (33 lines) | stat: -rw-r--r-- 636 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void help(char * prname)
{
	fprintf(stderr, "USE: %s <n><wordsizeinbits>\n", prname);
	exit(1);
}

int main(int argc, char ** argv)
{
	if(argc != 3) help(argv[0]);
	int n = atoi(argv[1]);
	int wordsize = (atoi(argv[2]) >> 1);
	int i, j, n_assigned;
	for(i = 0; i < n; i++)
	{
		int num = i;
		n_assigned = 0;
		for(j = 0; j < wordsize; j++)
		{			
			if ((num & 0x0003) != 3) 
			{
				n_assigned++;
				//fprintf(stderr, "num:%d\n", num);
			}
			num = num >> 2;
		}
		if(i%16 == 0) fprintf(stderr, "\n");
		fprintf(stderr, "%d, ", n_assigned);	
	} 
	fprintf(stderr, "\n");
}