|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 /* Jenkins Small Fast -- "A small noncryptographic PRNG"  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
  * http://burtleburtle.net/bob/rand/smallprng.html  | 
| 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
  * https://www.pcg-random.org/posts/some-prng-implementations.html */  | 
| 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #include   | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #include "jsf.h"  | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #define rot32(x, k) (((x) << (k)) | ((x) >> (32 - (k))))  | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 struct ranctx {  | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     uint32_t a;  | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     uint32_t b;  | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     uint32_t c;  | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     uint32_t d;  | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 };  | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 struct ranctx ctx;  | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
20
 | 
106
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 void raninit(uint32_t seed) {  | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     uint32_t i;  | 
| 
22
 | 
106
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     ctx.a = 0xf1ea5eed, ctx.b = ctx.c = ctx.d = seed;  | 
| 
23
 | 
2226
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     for (i = 0; i < 20; ++i)  | 
| 
24
 | 
2120
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         ranval();  | 
| 
25
 | 
106
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
27
 | 
32525
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 uint32_t ranval(void) {  | 
| 
28
 | 
32525
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     uint32_t e = ctx.a - rot32(ctx.b, 27);  | 
| 
29
 | 
32525
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     ctx.a      = ctx.b ^ rot32(ctx.c, 17);  | 
| 
30
 | 
32525
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     ctx.b      = ctx.c + ctx.d;  | 
| 
31
 | 
32525
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     ctx.c      = ctx.d + e;  | 
| 
32
 | 
32525
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     ctx.d      = e + ctx.a;  | 
| 
33
 | 
32525
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     return ctx.d;  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  |