#include <stdint.h>

uint16_t lfsr(uint16_t* cylinder){
  uint16_t ret = 0x00;
  for(int i = 0; i < 16; i++){
    uint16_t bit = (*cylinder >> 15) & 1;
    ret |= (bit << i); 
    uint16_t bit2 = 
    ( *cylinder >> 0 ^
      *cylinder >> 2 ^ 
      *cylinder >> 3 ^ 
      *cylinder >> 5) & 1;
    *cylinder = *cylinder >> 1; 
    *cylinder |= (bit2 << 15);
  }
  return ret;
}
