warning-cleanup-20010414
[openafs.git] / src / des / make_ip.c
1 /*
2  * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
3  *
4  * For copying and distribution information, please see the file
5  * <mit-cpyright.h>.
6  *
7  * This routine generates source code implementing the initial
8  * permutation of the DES.
9  */
10
11 #include <mit-cpyright.h>
12 #include <stdio.h>
13 #include "des_internal.h"
14
15 #define WANT_IP_TABLE
16 #include "tables.h"
17
18 extern afs_int32 swap_bit_pos_0();
19 extern afs_int32 rev_swap_bit_pos_0();
20 extern void test_set PROTOTYPE((FILE *, char const *, int,
21                 char const *, int));
22 extern int swap_long_bytes_bit_number(int);
23 extern int swap_bit_pos_0_to_ansi(int);
24
25 #define SWAP(x) swap_long_bytes_bit_number(swap_bit_pos_0_to_ansi(x))
26
27 void gen(stream)
28     FILE *stream;
29 {
30     register int i;
31
32     /* clear the output */
33     fprintf(stream,"    L2 = 0; R2 = 0;\n");
34
35     /* first setup IP */
36     fprintf(stream,"/* IP operations */\n/* first left to left */\n");
37
38     /* first list mapping from left to left */
39     for (i = 0; i <= 31; i++)
40         if (IP[i] < 32)
41             test_set(stream, "L1", SWAP(IP[i]), "L2", i);
42
43     /* now mapping from right to left */
44     fprintf(stream,"\n/* now from right to left */\n");
45     for (i = 0; i <= 31; i++)
46         if (IP[i] >= 32)
47             test_set(stream, "R1", SWAP(IP[i]-32), "L2", i);
48
49     fprintf(stream,"\n/* now from left to right */\n");
50     /*  list mapping from left to right */
51     for (i = 32; i <= 63; i++)
52         if (IP[i] <32)
53             test_set(stream, "L1", SWAP(IP[i]), "R2", i-32);
54
55     /* now mapping from right to right */
56     fprintf(stream,"\n/* last from right to right */\n");
57     for (i = 32; i <= 63; i++)
58         if (IP[i] >= 32)
59             test_set(stream, "R1", SWAP(IP[i]-32), "R2", i-32);
60     exit(0);
61 }