/* occ : C CODE OF AUTOMATON REFLEX_GAME */

/* AUXILIARY DECLARATIONS */

#ifndef STRLEN 
#define STRLEN 81 
#endif 
#define _COND(A,B,C) ((A)?(B):(C)) 
#ifdef TRACE_ACTION 
#include <stdio.h> 
#endif 
#ifndef NULL 
#define NULL ((char*)0) 
#endif 

#ifndef __EXEC_STATUS_H_LOADED 
#define __EXEC_STATUS_H_LOADED 

typedef struct {
unsigned int start:1;
unsigned int kill:1;
unsigned int active:1;
unsigned int suspended:1;
unsigned int prev_active:1;
unsigned int prev_suspended:1;
unsigned int exec_index;
unsigned int task_exec_index;
void (*pStart)();
void (*pRet)();
} __ExecStatus;

#endif 
#define __ResetExecStatus(status) {\ 
   status.prev_active = status.active; \
   status.prev_suspended = status.suspended; \
   status.start = status.kill = status.active = status.suspended = 0; }
#define __DSZ(V) (--(V)<=0) 
static int __REFLEX_GAME_engine();
#define __BASIC_ACT(i) (*__REFLEX_GAME_PActionArray[i])() 
#ifdef TRACE_ACTION 
#define __ACT(i) fprintf(stderr, "__REFLEX_GAME_A%d\n", i);__BASIC_ACT(i) 
#else 
#define __ACT(i) __BASIC_ACT(i) 
#endif 
#define BASIC_TYPES_DEFINED 
typedef int boolean;
typedef int integer;
typedef char* string;
#define _true 1 
#define _false 0 
#define __REFLEX_GAME_GENERIC_TEST(TEST) {if (TEST) __REFLEX_GAME_cp++; else __REFLEX_GAME_cp += *__REFLEX_GAME_cp;} 
typedef unsigned char  __REFLEX_GAME_indextype;
typedef void (*__REFLEX_GAME_APF)();
static __REFLEX_GAME_APF *__REFLEX_GAME_PActionArray;

#include "reflex_game.h" 

/* EXTERN DECLARATIONS */

#ifndef _NO_EXTERN_DEFINITIONS 
#ifndef _NO_CONSTANT_DEFINITIONS 
#ifndef _LIMIT_TIME_DEFINED 
#ifndef LIMIT_TIME 
extern integer LIMIT_TIME;
#endif 
#endif 
#ifndef _MEASURE_NUMBER_DEFINED 
#ifndef MEASURE_NUMBER 
extern integer MEASURE_NUMBER;
#endif 
#endif 
#ifndef _PAUSE_LENGTH_DEFINED 
#ifndef PAUSE_LENGTH 
extern integer PAUSE_LENGTH;
#endif 
#endif 
#endif 
#ifndef _NO_FUNCTION_DEFINITIONS 
#ifndef _RANDOM_DEFINED 
#ifndef RANDOM 
extern integer RANDOM();
#endif 
#endif 
#endif 
#endif 

/* INITIALIZED CONSTANTS */

/* MEMORY ALLOCATION */

static boolean __REFLEX_GAME_V0;
static boolean __REFLEX_GAME_V1;
static boolean __REFLEX_GAME_V2;
static boolean __REFLEX_GAME_V3;
static integer __REFLEX_GAME_V4;
static integer __REFLEX_GAME_V5;
static integer __REFLEX_GAME_V6;
static integer __REFLEX_GAME_V7;
static integer __REFLEX_GAME_V8;
static integer __REFLEX_GAME_V9;
static integer __REFLEX_GAME_V10;
static integer __REFLEX_GAME_V11;
static integer __REFLEX_GAME_V12;
static integer __REFLEX_GAME_V13;
static integer __REFLEX_GAME_V14;


/* INPUT FUNCTIONS */

void REFLEX_GAME_I_MS () {
__REFLEX_GAME_V0 = _true;
}
void REFLEX_GAME_I_COIN () {
__REFLEX_GAME_V1 = _true;
}
void REFLEX_GAME_I_READY () {
__REFLEX_GAME_V2 = _true;
}
void REFLEX_GAME_I_STOP () {
__REFLEX_GAME_V3 = _true;
}

/* FUNCTIONS RETURNING NUMBER OF EXEC */

int REFLEX_GAME_number_of_execs () {
return (0);
}


/* AUTOMATON (STATE ACTION-TREES) */

static __REFLEX_GAME_indextype __REFLEX_GAME_sct0 [] = {
0,0
};
static __REFLEX_GAME_indextype __REFLEX_GAME_sct1 [] = {
20,10,11,14,8,0,2
};
static __REFLEX_GAME_indextype __REFLEX_GAME_sct2 [] = {
5,17,21,8,10,12,14,22,32,33,37,4,23,0,3,30,0,4,
0,2
};
static __REFLEX_GAME_indextype __REFLEX_GAME_sct3 [] = {
5,17,21,8,10,12,14,22,32,33,37,4,23,0,3,30,0,4,
4,13,39,6,10,13,11,0,2,7,2,15,0,3,7,4,15,0,3,
6,4,24,0,5,0,3
};
static __REFLEX_GAME_indextype __REFLEX_GAME_sct4 [] = {
5,17,21,8,10,12,14,22,32,33,37,4,23,0,3,30,0,4,
4,10,42,6,31,8,11,0,2,0,4,0,4
};
static __REFLEX_GAME_indextype __REFLEX_GAME_sct5 [] = {
5,17,21,8,10,12,14,22,32,33,37,4,23,0,3,30,0,4,
4,17,7,6,10,13,11,0,2,40,6,9,29,25,0,6,0,5,
7,6,10,13,11,0,2,6,2,15,0,5
};
static __REFLEX_GAME_indextype __REFLEX_GAME_sct6 [] = {
5,17,21,8,10,12,14,22,32,33,37,4,23,0,3,30,0,4,
4,28,41,6,10,13,11,0,2,7,16,27,8,28,34,35,36,10,
38,4,30,0,4,23,0,3,26,0,6,6,4,15,0,6,7,16,
27,8,28,34,35,36,10,38,4,30,0,4,23,0,3,0,6
};
static __REFLEX_GAME_indextype* __REFLEX_GAME_dct [] = {
(__REFLEX_GAME_indextype*)0 /* no-sub-dags */
};
static __REFLEX_GAME_indextype* __REFLEX_GAME_sct [] = {
__REFLEX_GAME_sct0,
 __REFLEX_GAME_sct1,
 __REFLEX_GAME_sct2,
 __REFLEX_GAME_sct3,
 __REFLEX_GAME_sct4,
 __REFLEX_GAME_sct5,
 __REFLEX_GAME_sct6
};

static __REFLEX_GAME_indextype* __REFLEX_GAME_cp = __REFLEX_GAME_sct1;

/* ACTIONS */

/* PREDEFINED ACTIONS */

static void __REFLEX_GAME_A1 () {
extern __REFLEX_GAME_indextype* __REFLEX_GAME_dct[];
__REFLEX_GAME_indextype* old_cp = __REFLEX_GAME_cp + 1;
__REFLEX_GAME_cp = __REFLEX_GAME_dct[*__REFLEX_GAME_cp];
__REFLEX_GAME_engine();
__REFLEX_GAME_cp = old_cp;
}
static void __REFLEX_GAME_A2 () {
extern __REFLEX_GAME_indextype* __REFLEX_GAME_dct[];
__REFLEX_GAME_cp = __REFLEX_GAME_dct[*__REFLEX_GAME_cp];
}
static void __REFLEX_GAME_A3 () {
__REFLEX_GAME_GENERIC_TEST(_false);
}

/* PRESENT SIGNAL TESTS */

static void __REFLEX_GAME_A4 () {
__REFLEX_GAME_GENERIC_TEST(__REFLEX_GAME_V0);
}
static void __REFLEX_GAME_A5 () {
__REFLEX_GAME_GENERIC_TEST(__REFLEX_GAME_V1);
}
static void __REFLEX_GAME_A6 () {
__REFLEX_GAME_GENERIC_TEST(__REFLEX_GAME_V2);
}
static void __REFLEX_GAME_A7 () {
__REFLEX_GAME_GENERIC_TEST(__REFLEX_GAME_V3);
}

/* OUTPUT ACTIONS */

static void __REFLEX_GAME_A8 () {
REFLEX_GAME_O_DISPLAY(__REFLEX_GAME_V4);
}
static void __REFLEX_GAME_A9 () {
REFLEX_GAME_O_GO_ON();
}
static void __REFLEX_GAME_A10 () {
REFLEX_GAME_O_GO_OFF();
}
static void __REFLEX_GAME_A11 () {
REFLEX_GAME_O_GAME_OVER_ON();
}
static void __REFLEX_GAME_A12 () {
REFLEX_GAME_O_GAME_OVER_OFF();
}
static void __REFLEX_GAME_A13 () {
REFLEX_GAME_O_TILT_ON();
}
static void __REFLEX_GAME_A14 () {
REFLEX_GAME_O_TILT_OFF();
}
static void __REFLEX_GAME_A15 () {
REFLEX_GAME_O_RING_BELL();
}

/* ASSIGNMENTS */

static void __REFLEX_GAME_A16 () {
__REFLEX_GAME_V0 = _false;
}
static void __REFLEX_GAME_A17 () {
__REFLEX_GAME_V1 = _false;
}
static void __REFLEX_GAME_A18 () {
__REFLEX_GAME_V2 = _false;
}
static void __REFLEX_GAME_A19 () {
__REFLEX_GAME_V3 = _false;
}
static void __REFLEX_GAME_A20 () {
__REFLEX_GAME_V4 = 0;
}
static void __REFLEX_GAME_A21 () {
__REFLEX_GAME_V4 = 0;
}
static void __REFLEX_GAME_A22 () {
__REFLEX_GAME_V7 = MEASURE_NUMBER;
}
static void __REFLEX_GAME_A23 () {
__REFLEX_GAME_V8 = LIMIT_TIME;
}
static void __REFLEX_GAME_A24 () {
__REFLEX_GAME_V9 = RANDOM();
}
static void __REFLEX_GAME_A25 () {
__REFLEX_GAME_V10 = 0;
}
static void __REFLEX_GAME_A26 () {
__REFLEX_GAME_V10 = __REFLEX_GAME_V10+1;
}
static void __REFLEX_GAME_A27 () {
__REFLEX_GAME_V4 = __REFLEX_GAME_V10;
}
static void __REFLEX_GAME_A28 () {
__REFLEX_GAME_V5 = __REFLEX_GAME_V10;
}
static void __REFLEX_GAME_A29 () {
__REFLEX_GAME_V11 = LIMIT_TIME;
}
static void __REFLEX_GAME_A30 () {
__REFLEX_GAME_V12 = PAUSE_LENGTH;
}
static void __REFLEX_GAME_A31 () {
__REFLEX_GAME_V4 = __REFLEX_GAME_V6;
}
static void __REFLEX_GAME_A32 () {
__REFLEX_GAME_V13 = 0;
}
static void __REFLEX_GAME_A33 () {
__REFLEX_GAME_V14 = 0;
}
static void __REFLEX_GAME_A34 () {
__REFLEX_GAME_V13 = __REFLEX_GAME_V13+__REFLEX_GAME_V5;
}
static void __REFLEX_GAME_A35 () {
__REFLEX_GAME_V14 = __REFLEX_GAME_V14+1;
}
static void __REFLEX_GAME_A36 () {
__REFLEX_GAME_V6 = __REFLEX_GAME_V13/__REFLEX_GAME_V14;
}

/* PROCEDURE CALLS */

/* CONDITIONS */

static void __REFLEX_GAME_A37 () {
__REFLEX_GAME_GENERIC_TEST(__REFLEX_GAME_V7>0);
}

/* DECREMENTS */

static void __REFLEX_GAME_A38 () {
__REFLEX_GAME_GENERIC_TEST(__DSZ(__REFLEX_GAME_V7));
}
static void __REFLEX_GAME_A39 () {
__REFLEX_GAME_GENERIC_TEST(__DSZ(__REFLEX_GAME_V8));
}
static void __REFLEX_GAME_A40 () {
__REFLEX_GAME_GENERIC_TEST(__DSZ(__REFLEX_GAME_V9));
}
static void __REFLEX_GAME_A41 () {
__REFLEX_GAME_GENERIC_TEST(__DSZ(__REFLEX_GAME_V11));
}
static void __REFLEX_GAME_A42 () {
__REFLEX_GAME_GENERIC_TEST(__DSZ(__REFLEX_GAME_V12));
}

/* START ACTIONS */

/* KILL ACTIONS */

/* SUSPEND ACTIONS */

/* ACTIVATE ACTIONS */

/* WRITE ARGS ACTIONS */

/* RESET ACTIONS */

/* ACTION SEQUENCES */

/* THE ACTION ARRAY */

static __REFLEX_GAME_APF __REFLEX_GAME_ActionArray[] = {
0,
(__REFLEX_GAME_APF)__REFLEX_GAME_A1,
(__REFLEX_GAME_APF)__REFLEX_GAME_A2,
(__REFLEX_GAME_APF)__REFLEX_GAME_A3,
(__REFLEX_GAME_APF)__REFLEX_GAME_A4,
(__REFLEX_GAME_APF)__REFLEX_GAME_A5,
(__REFLEX_GAME_APF)__REFLEX_GAME_A6,
(__REFLEX_GAME_APF)__REFLEX_GAME_A7,
(__REFLEX_GAME_APF)__REFLEX_GAME_A8,
(__REFLEX_GAME_APF)__REFLEX_GAME_A9,
(__REFLEX_GAME_APF)__REFLEX_GAME_A10,
(__REFLEX_GAME_APF)__REFLEX_GAME_A11,
(__REFLEX_GAME_APF)__REFLEX_GAME_A12,
(__REFLEX_GAME_APF)__REFLEX_GAME_A13,
(__REFLEX_GAME_APF)__REFLEX_GAME_A14,
(__REFLEX_GAME_APF)__REFLEX_GAME_A15,
(__REFLEX_GAME_APF)__REFLEX_GAME_A16,
(__REFLEX_GAME_APF)__REFLEX_GAME_A17,
(__REFLEX_GAME_APF)__REFLEX_GAME_A18,
(__REFLEX_GAME_APF)__REFLEX_GAME_A19,
(__REFLEX_GAME_APF)__REFLEX_GAME_A20,
(__REFLEX_GAME_APF)__REFLEX_GAME_A21,
(__REFLEX_GAME_APF)__REFLEX_GAME_A22,
(__REFLEX_GAME_APF)__REFLEX_GAME_A23,
(__REFLEX_GAME_APF)__REFLEX_GAME_A24,
(__REFLEX_GAME_APF)__REFLEX_GAME_A25,
(__REFLEX_GAME_APF)__REFLEX_GAME_A26,
(__REFLEX_GAME_APF)__REFLEX_GAME_A27,
(__REFLEX_GAME_APF)__REFLEX_GAME_A28,
(__REFLEX_GAME_APF)__REFLEX_GAME_A29,
(__REFLEX_GAME_APF)__REFLEX_GAME_A30,
(__REFLEX_GAME_APF)__REFLEX_GAME_A31,
(__REFLEX_GAME_APF)__REFLEX_GAME_A32,
(__REFLEX_GAME_APF)__REFLEX_GAME_A33,
(__REFLEX_GAME_APF)__REFLEX_GAME_A34,
(__REFLEX_GAME_APF)__REFLEX_GAME_A35,
(__REFLEX_GAME_APF)__REFLEX_GAME_A36,
(__REFLEX_GAME_APF)__REFLEX_GAME_A37,
(__REFLEX_GAME_APF)__REFLEX_GAME_A38,
(__REFLEX_GAME_APF)__REFLEX_GAME_A39,
(__REFLEX_GAME_APF)__REFLEX_GAME_A40,
(__REFLEX_GAME_APF)__REFLEX_GAME_A41,
(__REFLEX_GAME_APF)__REFLEX_GAME_A42
};
static __REFLEX_GAME_APF *__REFLEX_GAME_PActionArray  = __REFLEX_GAME_ActionArray;


static void __REFLEX_GAME__reset_input () {
__REFLEX_GAME_V0 = _false;
__REFLEX_GAME_V1 = _false;
__REFLEX_GAME_V2 = _false;
__REFLEX_GAME_V3 = _false;
}

/* AUTOMATON ENGINE */

static int __REFLEX_GAME_engine () {
register __REFLEX_GAME_indextype x;
while (x = *(__REFLEX_GAME_cp++)) {
__ACT(x);
}
return *__REFLEX_GAME_cp;
}

int REFLEX_GAME () {
int x;
x = __REFLEX_GAME_engine();
__REFLEX_GAME_cp = __REFLEX_GAME_sct[x];
__REFLEX_GAME__reset_input();
return x!=0;
}

/* AUTOMATON RESET */

int REFLEX_GAME_reset () {
__REFLEX_GAME_cp = __REFLEX_GAME_sct1;
__REFLEX_GAME__reset_input();
return 0;
}