// Remap sectors for Mindset. No error handling
#include <unistd.h>
#include <string.h>
int main()
{
   unsigned char b1[512*17];
   unsigned char b2[512*17];
   int sn[] = {13, 14, 15, 16, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
   int rc;
   int i;

   while (1) {
      rc = read(STDIN_FILENO, b1, sizeof(b1));
      if (rc < sizeof(b1)) {
         break;
      }
      for (i = 0; i < 17; i++) {
         memcpy(&b2[i*512], &b1[sn[i]*512], 512);
      }
     write(STDOUT_FILENO, b2, sizeof(b2));
   }
}

