/* example blinks lights on Krie board 
   Steve Casselman */

//#define bool _Bool

// output states
bool LED0 = 0; /* states0 */
bool LED1 = 1; /* states1 */
bool LED2 = 0; /* states2 */

//input variables
bool  a0,a1,a2;


// sub routines 

void Function1(); 
void Function2(); 
void Function3();


void
main()
{

/* main loop */
 while(1) {
 if(a0 == 0)
Function1();
  if(a1 == 0)
    Function2();
  if(a2 == 0)
    Function3();
 } /* end while */
}


/* Subroutines */
void 
Function1() {
if(a0 ^ a1)
LED0 = 1, LED1 = 1, LED2 = 0;
//call functions from other functions
Function2();
LED0 = 0, LED1 = 0, LED2 = 1;
// functions must have a return statement
return;
}

void
Function2() {
if(a0 == 1)
LED0 = 1, LED1 = 0, LED2 = 1;
Function3();
LED0 = 0, LED1 = 1, LED2 = 1;
return;
}

void
Function3() {
if(a2 & a0==1)
  LED0 = 0, LED1 = 0, LED2 = 0;
  LED0 = 1, LED1 = 1, LED2 = 1;
return;
}

