b2bf357fdff5f820ac589ec9b4d9ef4d53eee2d4
[gcc.git] / gcc / testsuite / gcc.dg / pr55150-1.c
1 /* PR middle-end/55150 */
2 /* { dg-do compile } */
3 /* { dg-options "-Os -g" } */
4
5 typedef unsigned int KEY_TABLE_TYPE[(272 / 4)];
6 typedef unsigned int u32;
7 typedef unsigned char u8;
8 static const u32 Camellia_SBOX[][256] = {
9 };
10 static const u32 SIGMA[] = {
11 0xa09e667f, 0x3bcc908b, 0xb67ae858, 0x4caa73b2, 0xc6ef372f, 0xe94f82be, 0x54ff53a5, 0xf1d36f1c, 0x10e527fa, 0xde682d1d, 0xb05688c2, 0xb3e6c1fd };
12 int Camellia_Ekeygen (int keyBitLength, const u8 * rawKey, KEY_TABLE_TYPE k) {
13 register u32 s0, s1, s2, s3;
14 k[0] = s0 = ( {
15 u32 r = *(const u32 *) (rawKey);
16 r;
17 }
18 );
19 k[2] = s2 = ( {
20 u32 r = *(const u32 *) (rawKey + 8);
21 r;
22 }
23 );
24 k[3] = s3 = ( {
25 u32 r = *(const u32 *) (rawKey + 12);
26 r;
27 }
28 );
29 if (keyBitLength != 128) {
30 k[8] = s0 = ( {
31 u32 r = *(const u32 *) (rawKey + 16);
32 r;
33 }
34 );
35 if (keyBitLength == 192) {
36 k[10] = s2 = ~s0;
37 k[11] = s3 = ~s1;
38 }
39 }
40 s0 ^= k[0], s1 ^= k[1], s2 ^= k[2], s3 ^= k[3];
41 if (keyBitLength == 128) {
42 k[4] = s0, k[5] = s1, k[6] = s2, k[7] = s3;
43 }
44 else {
45 k[12] = s0, k[13] = s1, k[14] = s2, k[15] = s3;
46 s0 ^= k[8], s1 ^= k[9], s2 ^= k[10], s3 ^= k[11];
47 do {
48 register u32 _t0, _t1, _t2, _t3;
49 _t0 = s2 ^ ((SIGMA + 10))[0];
50 _t3 ^= Camellia_SBOX[3][(_t0 >> 8) & 0xff];
51 s1 ^= _t3;
52 }
53 while (0);
54 do {
55 u32 _t0 = s0 >> (32 - 30);
56 s2 = (s2 << 30) | (s3 >> (32 - 30));
57 s3 = (s3 << 30) | _t0;
58 }
59 while (0);
60 k[40] = s0, k[41] = s1, k[42] = s2, k[43] = s3;
61 k[64] = s1, k[65] = s2, k[66] = s3, k[67] = s0;
62 s0 = k[8], s1 = k[9], s2 = k[10], s3 = k[11];
63 k[36] = s0, k[37] = s1, k[38] = s2, k[39] = s3;
64 s0 = k[12], s1 = k[13], s2 = k[14], s3 = k[15];
65 do {
66 s1 = (s1 << 15) | (s2 >> (32 - 15));
67 }
68 while (0);
69 k[12] = s0, k[13] = s1, k[14] = s2, k[15] = s3;
70 k[44] = s1, k[45] = s2, k[46] = s3, k[47] = s0;
71 }
72 }