1#include <stdlib.h>
2
3static unsigned temper(unsigned x) {
4    x ^= x >> 11;
5    x ^= x << 7 & 0x9D2C5680;
6    x ^= x << 15 & 0xEFC60000;
7    x ^= x >> 18;
8    return x;
9}
10
11int rand_r(unsigned* seed) {
12    return temper(*seed = *seed * 1103515245 + 12345) / 2;
13}
14