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

int irand(int lb, int ub)
{
#if defined(UNSAFE)
  return lb + (rand()%(ub - lb + 1));
#else
  return lb + (int)((double)(ub - lb + 1)*rand()/(RAND_MAX+1.0));
#endif
}
int main(void)
{
  int i;
#if defined(UNSAFE)

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

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