rand, rand_r, srand - pseudo-random number generator
int rand_r(unsigned int *seedp);
void srand(unsigned int seed);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
rand_r(): _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
The rand() function returns a pseudo-random integer in the range 0 to RAND_MAX inclusive (i.e., the mathematical range [0, RAND_MAX]).
The srand() function sets its argument as the seed for a new sequence of pseudo-random integers to be returned by rand(). These sequences are repeat-
able by calling srand() with the same seed value.
If no seed value is provided, the rand() function is automatically seeded with a value of 1.
The function rand() is not reentrant or thread-safe, since it uses hidden state that is modified on each call. This might just be the seed value to be
used by the next call, or it might be something more elaborate. In order to get reproducible behavior in a threaded application, this state must be
made explicit; this can be done using the reentrant function rand_r().