/* Quickie to convert eexec format from stdin to postscript on stdout */

#include <stdio.h>

/* Written by Carsten Wiethoff 1989 */
/* You may do what you want with this code, 
   as long as this notice stays in it */

static unsigned short buffer = 0xd971;

main()
{
  unsigned int input;
  char output;
  int ignore = 4;
  int result;

  do
    {
      result = scanf(" %2x",&input);
      if ( (result == EOF) || (result == 0) )
        break;
      output = input ^ (buffer>>8);
      buffer = (input + buffer) * 0xce6d + 0x58bf;
      if ( ignore > 0 ) 
        {
          ignore--;
        }
      else
        {
          printf("%c",output);
        }
    } while (1);
}
