 This program writes size optimized state machines 
 Written by Dan Williams aug 21 2006 
Enter a factor name or press enter when done
Enter a factor name or press enter when done
Enter a factor name or press enter when done
Enter a factor name or press enter when done
Enter a factor name or press enter when done
Enter a state name for factor leftLegs or press enter for next
Enter a state name for factor leftLegs or press enter for next
Enter a state name for factor leftLegs or press enter for next
Enter a state name for factor leftLegs or press enter for next
Enter a state name for factor rightLegs or press enter for next
Enter a state name for factor rightLegs or press enter for next
Enter a state name for factor rightLegs or press enter for next
Enter a state name for factor rightLegs or press enter for next
Enter a state name for factor middleLegs or press enter for next
Enter a state name for factor middleLegs or press enter for next
Enter a state name for factor middleLegs or press enter for next
Enter a state name for factor middleLegs or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
typedef struct FSM_State_s { 
  unsigned leftLegs : 2;
  unsigned rightLegs : 2;
  unsigned middleLegs : 2;
  unsigned direction : 4;
} FSM_State_t;
 
typedef unsigned int  PTRType; 
    
typedef struct stateEntry_s {  
    PTRType       next;            
    FSM_State_t   state;           
 } stateEntry_t;                   
 
//----------| leftLegs |----------
  #define forward 0
  #define center  1
  #define back    2
//----------| rightLegs |----------
  #define forward 0
  #define center  1
  #define back    2
//----------| middleLegs |----------
  #define left   0
  #define center 1
  #define right  2
//----------| direction |----------
  #define stopped      0
  #define forward      1
  #define forwardRight 2
  #define spinRight    3
  #define backRight    4
  #define backward     5
  #define backLeft     6
  #define spinLeft     7
  #define forwardLeft  8
//------------
  //    leftLegs  ,  rightLegs  ,  middleLegs  ,  direction  ,
stateEntry_t stateTable[] = {   
  { 0, { forward  , forward  , left    , stopped       , }},  /*   index: 0   */
  { 0, { forward  , forward  , left    , forward       , }},  /*   index: 1   */
  { 0, { forward  , forward  , left    , forwardRight  , }},  /*   index: 2   */
  { 0, { forward  , forward  , left    , spinRight     , }},  /*   index: 3   */
  { 0, { forward  , forward  , left    , backRight     , }},  /*   index: 4   */
  { 0, { forward  , forward  , left    , backward      , }},  /*   index: 5   */
  { 0, { forward  , forward  , left    , backLeft      , }},  /*   index: 6   */
  { 0, { forward  , forward  , left    , spinLeft      , }},  /*   index: 7   */
  { 0, { forward  , forward  , left    , forwardLeft   , }},  /*   index: 8   */
  { 0, { forward  , forward  , center  , stopped       , }},  /*   index: 9   */
  { 0, { forward  , forward  , center  , forward       , }},  /*   index: 10   */
  { 0, { forward  , forward  , center  , forwardRight  , }},  /*   index: 11   */
  { 0, { forward  , forward  , center  , spinRight     , }},  /*   index: 12   */
  { 0, { forward  , forward  , center  , backRight     , }},  /*   index: 13   */
  { 0, { forward  , forward  , center  , backward      , }},  /*   index: 14   */
  { 0, { forward  , forward  , center  , backLeft      , }},  /*   index: 15   */
  { 0, { forward  , forward  , center  , spinLeft      , }},  /*   index: 16   */
  { 0, { forward  , forward  , center  , forwardLeft   , }},  /*   index: 17   */
  { 0, { forward  , forward  , right   , stopped       , }},  /*   index: 18   */
  { 0, { forward  , forward  , right   , forward       , }},  /*   index: 19   */
  { 0, { forward  , forward  , right   , forwardRight  , }},  /*   index: 20   */
  { 0, { forward  , forward  , right   , spinRight     , }},  /*   index: 21   */
  { 0, { forward  , forward  , right   , backRight     , }},  /*   index: 22   */
  { 0, { forward  , forward  , right   , backward      , }},  /*   index: 23   */
  { 0, { forward  , forward  , right   , backLeft      , }},  /*   index: 24   */
  { 0, { forward  , forward  , right   , spinLeft      , }},  /*   index: 25   */
  { 0, { forward  , forward  , right   , forwardLeft   , }},  /*   index: 26   */
  { 0, { forward  , center   , left    , stopped       , }},  /*   index: 27   */
  { 0, { forward  , center   , left    , forward       , }},  /*   index: 28   */
  { 0, { forward  , center   , left    , forwardRight  , }},  /*   index: 29   */
  { 0, { forward  , center   , left    , spinRight     , }},  /*   index: 30   */
  { 0, { forward  , center   , left    , backRight     , }},  /*   index: 31   */
  { 0, { forward  , center   , left    , backward      , }},  /*   index: 32   */
  { 0, { forward  , center   , left    , backLeft      , }},  /*   index: 33   */
  { 0, { forward  , center   , left    , spinLeft      , }},  /*   index: 34   */
  { 0, { forward  , center   , left    , forwardLeft   , }},  /*   index: 35   */
  { 0, { forward  , center   , center  , stopped       , }},  /*   index: 36   */
  { 0, { forward  , center   , center  , forward       , }},  /*   index: 37   */
  { 0, { forward  , center   , center  , forwardRight  , }},  /*   index: 38   */
  { 0, { forward  , center   , center  , spinRight     , }},  /*   index: 39   */
  { 0, { forward  , center   , center  , backRight     , }},  /*   index: 40   */
  { 0, { forward  , center   , center  , backward      , }},  /*   index: 41   */
  { 0, { forward  , center   , center  , backLeft      , }},  /*   index: 42   */
  { 0, { forward  , center   , center  , spinLeft      , }},  /*   index: 43   */
  { 0, { forward  , center   , center  , forwardLeft   , }},  /*   index: 44   */
  { 0, { forward  , center   , right   , stopped       , }},  /*   index: 45   */
  { 0, { forward  , center   , right   , forward       , }},  /*   index: 46   */
  { 0, { forward  , center   , right   , forwardRight  , }},  /*   index: 47   */
  { 0, { forward  , center   , right   , spinRight     , }},  /*   index: 48   */
  { 0, { forward  , center   , right   , backRight     , }},  /*   index: 49   */
  { 0, { forward  , center   , right   , backward      , }},  /*   index: 50   */
  { 0, { forward  , center   , right   , backLeft      , }},  /*   index: 51   */
  { 0, { forward  , center   , right   , spinLeft      , }},  /*   index: 52   */
  { 0, { forward  , center   , right   , forwardLeft   , }},  /*   index: 53   */
  { 0, { forward  , back     , left    , stopped       , }},  /*   index: 54   */
  { 0, { forward  , back     , left    , forward       , }},  /*   index: 55   */
  { 0, { forward  , back     , left    , forwardRight  , }},  /*   index: 56   */
  { 0, { forward  , back     , left    , spinRight     , }},  /*   index: 57   */
  { 0, { forward  , back     , left    , backRight     , }},  /*   index: 58   */
  { 0, { forward  , back     , left    , backward      , }},  /*   index: 59   */
  { 0, { forward  , back     , left    , backLeft      , }},  /*   index: 60   */
  { 0, { forward  , back     , left    , spinLeft      , }},  /*   index: 61   */
  { 0, { forward  , back     , left    , forwardLeft   , }},  /*   index: 62   */
  { 0, { forward  , back     , center  , stopped       , }},  /*   index: 63   */
  { 0, { forward  , back     , center  , forward       , }},  /*   index: 64   */
  { 0, { forward  , back     , center  , forwardRight  , }},  /*   index: 65   */
  { 0, { forward  , back     , center  , spinRight     , }},  /*   index: 66   */
  { 0, { forward  , back     , center  , backRight     , }},  /*   index: 67   */
  { 0, { forward  , back     , center  , backward      , }},  /*   index: 68   */
  { 0, { forward  , back     , center  , backLeft      , }},  /*   index: 69   */
  { 0, { forward  , back     , center  , spinLeft      , }},  /*   index: 70   */
  { 0, { forward  , back     , center  , forwardLeft   , }},  /*   index: 71   */
  { 0, { forward  , back     , right   , stopped       , }},  /*   index: 72   */
  { 0, { forward  , back     , right   , forward       , }},  /*   index: 73   */
  { 0, { forward  , back     , right   , forwardRight  , }},  /*   index: 74   */
  { 0, { forward  , back     , right   , spinRight     , }},  /*   index: 75   */
  { 0, { forward  , back     , right   , backRight     , }},  /*   index: 76   */
  { 0, { forward  , back     , right   , backward      , }},  /*   index: 77   */
  { 0, { forward  , back     , right   , backLeft      , }},  /*   index: 78   */
  { 0, { forward  , back     , right   , spinLeft      , }},  /*   index: 79   */
  { 0, { forward  , back     , right   , forwardLeft   , }},  /*   index: 80   */
  { 0, { center   , forward  , left    , stopped       , }},  /*   index: 81   */
  { 0, { center   , forward  , left    , forward       , }},  /*   index: 82   */
  { 0, { center   , forward  , left    , forwardRight  , }},  /*   index: 83   */
  { 0, { center   , forward  , left    , spinRight     , }},  /*   index: 84   */
  { 0, { center   , forward  , left    , backRight     , }},  /*   index: 85   */
  { 0, { center   , forward  , left    , backward      , }},  /*   index: 86   */
  { 0, { center   , forward  , left    , backLeft      , }},  /*   index: 87   */
  { 0, { center   , forward  , left    , spinLeft      , }},  /*   index: 88   */
  { 0, { center   , forward  , left    , forwardLeft   , }},  /*   index: 89   */
  { 0, { center   , forward  , center  , stopped       , }},  /*   index: 90   */
  { 0, { center   , forward  , center  , forward       , }},  /*   index: 91   */
  { 0, { center   , forward  , center  , forwardRight  , }},  /*   index: 92   */
  { 0, { center   , forward  , center  , spinRight     , }},  /*   index: 93   */
  { 0, { center   , forward  , center  , backRight     , }},  /*   index: 94   */
  { 0, { center   , forward  , center  , backward      , }},  /*   index: 95   */
  { 0, { center   , forward  , center  , backLeft      , }},  /*   index: 96   */
  { 0, { center   , forward  , center  , spinLeft      , }},  /*   index: 97   */
  { 0, { center   , forward  , center  , forwardLeft   , }},  /*   index: 98   */
  { 0, { center   , forward  , right   , stopped       , }},  /*   index: 99   */
  { 0, { center   , forward  , right   , forward       , }},  /*   index: 100   */
  { 0, { center   , forward  , right   , forwardRight  , }},  /*   index: 101   */
  { 0, { center   , forward  , right   , spinRight     , }},  /*   index: 102   */
  { 0, { center   , forward  , right   , backRight     , }},  /*   index: 103   */
  { 0, { center   , forward  , right   , backward      , }},  /*   index: 104   */
  { 0, { center   , forward  , right   , backLeft      , }},  /*   index: 105   */
  { 0, { center   , forward  , right   , spinLeft      , }},  /*   index: 106   */
  { 0, { center   , forward  , right   , forwardLeft   , }},  /*   index: 107   */
  { 0, { center   , center   , left    , stopped       , }},  /*   index: 108   */
  { 0, { center   , center   , left    , forward       , }},  /*   index: 109   */
  { 0, { center   , center   , left    , forwardRight  , }},  /*   index: 110   */
  { 0, { center   , center   , left    , spinRight     , }},  /*   index: 111   */
  { 0, { center   , center   , left    , backRight     , }},  /*   index: 112   */
  { 0, { center   , center   , left    , backward      , }},  /*   index: 113   */
  { 0, { center   , center   , left    , backLeft      , }},  /*   index: 114   */
  { 0, { center   , center   , left    , spinLeft      , }},  /*   index: 115   */
  { 0, { center   , center   , left    , forwardLeft   , }},  /*   index: 116   */
  { 0, { center   , center   , center  , stopped       , }},  /*   index: 117   */
  { 0, { center   , center   , center  , forward       , }},  /*   index: 118   */
  { 0, { center   , center   , center  , forwardRight  , }},  /*   index: 119   */
  { 0, { center   , center   , center  , spinRight     , }},  /*   index: 120   */
  { 0, { center   , center   , center  , backRight     , }},  /*   index: 121   */
  { 0, { center   , center   , center  , backward      , }},  /*   index: 122   */
  { 0, { center   , center   , center  , backLeft      , }},  /*   index: 123   */
  { 0, { center   , center   , center  , spinLeft      , }},  /*   index: 124   */
  { 0, { center   , center   , center  , forwardLeft   , }},  /*   index: 125   */
  { 0, { center   , center   , right   , stopped       , }},  /*   index: 126   */
  { 0, { center   , center   , right   , forward       , }},  /*   index: 127   */
  { 0, { center   , center   , right   , forwardRight  , }},  /*   index: 128   */
  { 0, { center   , center   , right   , spinRight     , }},  /*   index: 129   */
  { 0, { center   , center   , right   , backRight     , }},  /*   index: 130   */
  { 0, { center   , center   , right   , backward      , }},  /*   index: 131   */
  { 0, { center   , center   , right   , backLeft      , }},  /*   index: 132   */
  { 0, { center   , center   , right   , spinLeft      , }},  /*   index: 133   */
  { 0, { center   , center   , right   , forwardLeft   , }},  /*   index: 134   */
  { 0, { center   , back     , left    , stopped       , }},  /*   index: 135   */
  { 0, { center   , back     , left    , forward       , }},  /*   index: 136   */
  { 0, { center   , back     , left    , forwardRight  , }},  /*   index: 137   */
  { 0, { center   , back     , left    , spinRight     , }},  /*   index: 138   */
  { 0, { center   , back     , left    , backRight     , }},  /*   index: 139   */
  { 0, { center   , back     , left    , backward      , }},  /*   index: 140   */
  { 0, { center   , back     , left    , backLeft      , }},  /*   index: 141   */
  { 0, { center   , back     , left    , spinLeft      , }},  /*   index: 142   */
  { 0, { center   , back     , left    , forwardLeft   , }},  /*   index: 143   */
  { 0, { center   , back     , center  , stopped       , }},  /*   index: 144   */
  { 0, { center   , back     , center  , forward       , }},  /*   index: 145   */
  { 0, { center   , back     , center  , forwardRight  , }},  /*   index: 146   */
  { 0, { center   , back     , center  , spinRight     , }},  /*   index: 147   */
  { 0, { center   , back     , center  , backRight     , }},  /*   index: 148   */
  { 0, { center   , back     , center  , backward      , }},  /*   index: 149   */
  { 0, { center   , back     , center  , backLeft      , }},  /*   index: 150   */
  { 0, { center   , back     , center  , spinLeft      , }},  /*   index: 151   */
  { 0, { center   , back     , center  , forwardLeft   , }},  /*   index: 152   */
  { 0, { center   , back     , right   , stopped       , }},  /*   index: 153   */
  { 0, { center   , back     , right   , forward       , }},  /*   index: 154   */
  { 0, { center   , back     , right   , forwardRight  , }},  /*   index: 155   */
  { 0, { center   , back     , right   , spinRight     , }},  /*   index: 156   */
  { 0, { center   , back     , right   , backRight     , }},  /*   index: 157   */
  { 0, { center   , back     , right   , backward      , }},  /*   index: 158   */
  { 0, { center   , back     , right   , backLeft      , }},  /*   index: 159   */
  { 0, { center   , back     , right   , spinLeft      , }},  /*   index: 160   */
  { 0, { center   , back     , right   , forwardLeft   , }},  /*   index: 161   */
  { 0, { back     , forward  , left    , stopped       , }},  /*   index: 162   */
  { 0, { back     , forward  , left    , forward       , }},  /*   index: 163   */
  { 0, { back     , forward  , left    , forwardRight  , }},  /*   index: 164   */
  { 0, { back     , forward  , left    , spinRight     , }},  /*   index: 165   */
  { 0, { back     , forward  , left    , backRight     , }},  /*   index: 166   */
  { 0, { back     , forward  , left    , backward      , }},  /*   index: 167   */
  { 0, { back     , forward  , left    , backLeft      , }},  /*   index: 168   */
  { 0, { back     , forward  , left    , spinLeft      , }},  /*   index: 169   */
  { 0, { back     , forward  , left    , forwardLeft   , }},  /*   index: 170   */
  { 0, { back     , forward  , center  , stopped       , }},  /*   index: 171   */
  { 0, { back     , forward  , center  , forward       , }},  /*   index: 172   */
  { 0, { back     , forward  , center  , forwardRight  , }},  /*   index: 173   */
  { 0, { back     , forward  , center  , spinRight     , }},  /*   index: 174   */
  { 0, { back     , forward  , center  , backRight     , }},  /*   index: 175   */
  { 0, { back     , forward  , center  , backward      , }},  /*   index: 176   */
  { 0, { back     , forward  , center  , backLeft      , }},  /*   index: 177   */
  { 0, { back     , forward  , center  , spinLeft      , }},  /*   index: 178   */
  { 0, { back     , forward  , center  , forwardLeft   , }},  /*   index: 179   */
  { 0, { back     , forward  , right   , stopped       , }},  /*   index: 180   */
  { 0, { back     , forward  , right   , forward       , }},  /*   index: 181   */
  { 0, { back     , forward  , right   , forwardRight  , }},  /*   index: 182   */
  { 0, { back     , forward  , right   , spinRight     , }},  /*   index: 183   */
  { 0, { back     , forward  , right   , backRight     , }},  /*   index: 184   */
  { 0, { back     , forward  , right   , backward      , }},  /*   index: 185   */
  { 0, { back     , forward  , right   , backLeft      , }},  /*   index: 186   */
  { 0, { back     , forward  , right   , spinLeft      , }},  /*   index: 187   */
  { 0, { back     , forward  , right   , forwardLeft   , }},  /*   index: 188   */
  { 0, { back     , center   , left    , stopped       , }},  /*   index: 189   */
  { 0, { back     , center   , left    , forward       , }},  /*   index: 190   */
  { 0, { back     , center   , left    , forwardRight  , }},  /*   index: 191   */
  { 0, { back     , center   , left    , spinRight     , }},  /*   index: 192   */
  { 0, { back     , center   , left    , backRight     , }},  /*   index: 193   */
  { 0, { back     , center   , left    , backward      , }},  /*   index: 194   */
  { 0, { back     , center   , left    , backLeft      , }},  /*   index: 195   */
  { 0, { back     , center   , left    , spinLeft      , }},  /*   index: 196   */
  { 0, { back     , center   , left    , forwardLeft   , }},  /*   index: 197   */
  { 0, { back     , center   , center  , stopped       , }},  /*   index: 198   */
  { 0, { back     , center   , center  , forward       , }},  /*   index: 199   */
  { 0, { back     , center   , center  , forwardRight  , }},  /*   index: 200   */
  { 0, { back     , center   , center  , spinRight     , }},  /*   index: 201   */
  { 0, { back     , center   , center  , backRight     , }},  /*   index: 202   */
  { 0, { back     , center   , center  , backward      , }},  /*   index: 203   */
  { 0, { back     , center   , center  , backLeft      , }},  /*   index: 204   */
  { 0, { back     , center   , center  , spinLeft      , }},  /*   index: 205   */
  { 0, { back     , center   , center  , forwardLeft   , }},  /*   index: 206   */
  { 0, { back     , center   , right   , stopped       , }},  /*   index: 207   */
  { 0, { back     , center   , right   , forward       , }},  /*   index: 208   */
  { 0, { back     , center   , right   , forwardRight  , }},  /*   index: 209   */
  { 0, { back     , center   , right   , spinRight     , }},  /*   index: 210   */
  { 0, { back     , center   , right   , backRight     , }},  /*   index: 211   */
  { 0, { back     , center   , right   , backward      , }},  /*   index: 212   */
  { 0, { back     , center   , right   , backLeft      , }},  /*   index: 213   */
  { 0, { back     , center   , right   , spinLeft      , }},  /*   index: 214   */
  { 0, { back     , center   , right   , forwardLeft   , }},  /*   index: 215   */
  { 0, { back     , back     , left    , stopped       , }},  /*   index: 216   */
  { 0, { back     , back     , left    , forward       , }},  /*   index: 217   */
  { 0, { back     , back     , left    , forwardRight  , }},  /*   index: 218   */
  { 0, { back     , back     , left    , spinRight     , }},  /*   index: 219   */
  { 0, { back     , back     , left    , backRight     , }},  /*   index: 220   */
  { 0, { back     , back     , left    , backward      , }},  /*   index: 221   */
  { 0, { back     , back     , left    , backLeft      , }},  /*   index: 222   */
  { 0, { back     , back     , left    , spinLeft      , }},  /*   index: 223   */
  { 0, { back     , back     , left    , forwardLeft   , }},  /*   index: 224   */
  { 0, { back     , back     , center  , stopped       , }},  /*   index: 225   */
  { 0, { back     , back     , center  , forward       , }},  /*   index: 226   */
  { 0, { back     , back     , center  , forwardRight  , }},  /*   index: 227   */
  { 0, { back     , back     , center  , spinRight     , }},  /*   index: 228   */
  { 0, { back     , back     , center  , backRight     , }},  /*   index: 229   */
  { 0, { back     , back     , center  , backward      , }},  /*   index: 230   */
  { 0, { back     , back     , center  , backLeft      , }},  /*   index: 231   */
  { 0, { back     , back     , center  , spinLeft      , }},  /*   index: 232   */
  { 0, { back     , back     , center  , forwardLeft   , }},  /*   index: 233   */
  { 0, { back     , back     , right   , stopped       , }},  /*   index: 234   */
  { 0, { back     , back     , right   , forward       , }},  /*   index: 235   */
  { 0, { back     , back     , right   , forwardRight  , }},  /*   index: 236   */
  { 0, { back     , back     , right   , spinRight     , }},  /*   index: 237   */
  { 0, { back     , back     , right   , backRight     , }},  /*   index: 238   */
  { 0, { back     , back     , right   , backward      , }},  /*   index: 239   */
  { 0, { back     , back     , right   , backLeft      , }},  /*   index: 240   */
  { 0, { back     , back     , right   , spinLeft      , }},  /*   index: 241   */
  { 0, { back     , back     , right   , forwardLeft   , }},  /*   index: 242   */
};