#include <stdio.h>
#include <stdlib.h>
#include <time.h>	/* time() */
#include <sys/time.h>	/* gettimeofday() */
#include <unistd.h>	/* getpid() */

int irandom(int lb, int ub)
{
  return lb + (random()%(ub - lb + 1));
}
int main(void)
{
  int i;
#if defined(UNSAFE)

  srandom((unsigned)time(NULL));
#else
  struct timeval tm;

  gettimeofday(&tm, NULL);
  srandom((unsigned)((tm.tv_sec|tm.tv_usec)*getpid()));
  /*srandomdev();*/	/* better */
#endif
  for (i=0; i<10; i++)
    printf("%d\n", irandom(0, 9));
  return 0;
}
