#include <stdint.h>
#include <stdio.h>
#include <sys/stat.h>
#include "include/libmyprng.h"

int main(void){
  const unsigned int LFSR_FILESIZE = (2 << 18);
  const unsigned int LCG_FILESIZE = (2 << 16);
  uint16_t cylinder = 0xaac8;
  uint16_t b = lfsr(&cylinder);
  struct stat dirstat;
  if(stat("samples", &dirstat)){
    mkdir("samples",0755);
  }
  FILE* fp = fopen("samples/lfsr_test.bin","w");
  if(!fp){
    perror("samples");
    return -1;
  }
  for(int i = 0; i < LFSR_FILESIZE; i++){
    fwrite(&b, sizeof(uint16_t), 1, fp);
    b = lfsr(&cylinder);
  }
  printf("Completed the LFSR test\n");
  fclose(fp);
  fp = fopen("samples/lcg_test.bin","w");
  lcg_t gen;
  uint64_t a;
  init_lcg(25565, &gen);
  for(int i = 0; i < LCG_FILESIZE; i++){
    a = lcg(&gen);
    fwrite(&a, sizeof(uint32_t), 1, fp);
  }
  printf("Completed the LCG test\n");
  fclose(fp);
  return (int)b;
}
