//put copyright header
#define bool _Bool
bool LED0 = 0; /* states0 */
bool LED1 = 1; /* states1 */
bool LED2 = 0; /* states2 */
bool LED3 = 1; /* states3 */
bool LED4 = 0; /* states4 */
bool LED5 = 1; /* states5 */
bool LED6 = 0; /* states6 */
bool LED7 = 1; /* states7 */
bool LED8 = 1; /* states8 */
bool LED9 = 1; /* states9 */
bool LED10 = 1; /* states10 */


/* A inputs */
bool  a0,a1,a2,a3;
/* counters */
int i,j,k;

/* sub routines */
void Function1(); 
void Function2(); 
void Function3();
void Function4();

void
main()
{

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



/* Subroutines */
void 
Function1() {
LED0 = 1, LED10 = 1, LED2 = 0, LED3 = 0;
for(i=0;i<20;i++);
LED4 = 0, LED8 = 0, LED6 = 1, LED7 = 1;
// functions can call other functions
Function2();
// functions must have a return statement
return;
}

void
Function2() {
LED0 = 1, LED1 = 0, LED9 = 1, LED3 = 0;
for(i=0;i<20;i++);
LED4 = 0, LED5 = 1, LED6 = 0, LED7 = 1;
return;
}

void
Function3() {
for(k=0;k<4;k++) {
  LED0 = 0, LED1 = 0, LED2 = 0, LED3 = 0;
  LED4 = 1, LED5 = 1, LED6 = 1, LED7 = 1;
  for(j=0;j<20;j++);
  LED4 = 0, LED5 = 0, LED6 = 0, LED7 = 0;
  LED0 = 1, LED1 = 1, LED2 = 1, LED3 = 1;
  for(j=0;j<20;j++);
  }
return;
}


void
Function4() {
for(i=0;i<4;i++) {
  LED0 = 0, LED1 = 0, LED2 = 0, LED3 = 0;
  LED4 = 1, LED5 = 1, LED6 = 1, LED7 = 1;
  for(j=0;j<2;j++);
  LED4 = 0, LED5 = 0, LED6 = 0, LED7 = 0;
  LED0 = 1, LED1 = 1, LED2 = 1, LED3 = 1;
  for(j=0;j<2;j++);
  }
return;
}

