test_xoroshi256ss.c
text/x-csrc
Filename: test_xoroshi256ss.c
Type: text/x-csrc
Part: 1
// XOROSHI256**
#include <stdio.h>
#include <stdint.h>
static inline uint64_t rotl(const uint64_t x, int k) {
return (x << k) | (x >> (64 - k));
}
static uint64_t s[4];
uint64_t next(void) {
const uint64_t result_starstar = rotl(s[1] * 5, 7) * 9;
const uint64_t t = s[1] << 17;
s[2] ^= s[0];
s[3] ^= s[1];
s[1] ^= s[2];
s[0] ^= s[3];
s[2] ^= t;
s[3] = rotl(s[3], 45);
return result_starstar;
}
int main(void)
{
uint64_t l;
s[0] = 0xdeadbeefdeadbeefLL;
s[1] = 0xdeadbeefdeadbeefLL;
s[2] = 0xdeadbeefdeadbeefLL;
s[3] = 0xdeadbeefdeadbeefLL;
// loop 1 billion times
for (int i = 0; i < 1000000000; i++)
l = next();
fprintf(stdout, "%lu\n", l);
return 0;
}