forked from macton/nintendo-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_00.c
56 lines (46 loc) · 1.03 KB
/
test_00.c
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "rand_ints.h"
void
encode( uint32_t* a, uint32_t* b, int size )
{
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
b[(i + j) / 32] ^= ( (a[i / 32] >> (i % 32)) & (a[j / 32 + size / 32] >> (j % 32)) & 1 ) << ((i + j) % 32); // Magic centaurian operation
}
}
}
void
print_32b( uint32_t a )
{
for (int i=31;i>=0;i--)
{
printf("%c",a&(1<<i)?'1':'0');
}
}
int
main( void )
{
int test_count = g_RandIntCount-1;
uint32_t* a = g_RandInts;
uint32_t* b = (uint32_t*)__builtin_alloca( test_count * 2 * sizeof(uint32_t) );
memset(b,0,test_count*2*sizeof(uint32_t));
for (int i=0;i<test_count;i++)
{
encode( &a[i],&b[i*2],32);
printf("a 0x%08x 0x%08x ",a[i],a[i+1]);
print_32b(a[i]);
printf(" ");
print_32b(a[i+1]);
printf("\n");
printf("b 0x%08x 0x%08x ",b[(i*2)+0], b[(i*2)+1]);
print_32b(b[(i*2)+0]);
printf(" ");
print_32b(b[(i*2)+1]);
printf("\n");
}
return 0;
}