#include <perms.h>
// Edinburgh IMP77 Compiler - Version 8.4
//
// 1 !MINIMO: multiple output logic function minimiser
// 2 !
// 3 ! Hamish Dewar 1981
// 4 !
// 5
// 6 %external %integer %fn %spec CPUTIME
extern int CPUTIME(void);
// 7
// 8 %external %string(255) %fn %spec CLIPARAM
extern _imp_string255 CLIPARAM(void);
// 9
// 10 %record %format PAMINFO(%byte groupsep,keyflag, %short allflags, %record(*)%name params)
struct PAMINFO {
union {
struct {
unsigned char GROUPSEP;
unsigned char KEYFLAG;
short int ALLFLAGS;
struct PARAMS *PARAMS;
};
};
};
// 11
// 12 %external %record(paminfo) %map %spec PAM
extern struct PAMINFO *PAM(void)
;
// 13
// 14 %constinteger PAM NEWGROUP=1, PAM NODEFAULT=2, PAM MAJOR=4, PAM KEEPCASE=8, PAM INFILE=16, PAM OUTFILE=32
// 15
// 16 %external %routine %spec DEFINE PARAM %alias "PAM_DEFSTRING" (%string(255) text, %string(*)%name variable, %integer flags)
extern void DEFINEPARAM(_imp_string255 TEXT, _imp_string *VARIABLE, int FLAGS) __asm__("PAM_DEFSTRING");
// 17 %external %routine %spec DEFINE INT PARAM %alias "PAM_DEFINT" (%string(255) text, %integername variable, %integer flags)
extern void DEFINEINTPARAM(_imp_string255 TEXT, int *VARIABLE, int FLAGS) __asm__("PAM_DEFINT");
// 18 %external %routine %spec DEFINE ENUM PARAM %alias "PAM_DEFENUM" (%string(255) text, %bytename variable, %integer flags)
extern void DEFINEENUMPARAM(_imp_string255 TEXT, unsigned char *VARIABLE, int FLAGS) __asm__("PAM_DEFENUM");
// 19 %external %routine %spec DEFINE BOOLEAN PARAMS %alias "PAM_DEFBOOL" (%string(255) text, %integername variable, %integer flags)
extern void DEFINEBOOLEANPARAMS(_imp_string255 TEXT, int *VARIABLE, int FLAGS) __asm__("PAM_DEFBOOL");
// 20 %external %routine %spec PROCESS PARAMETERS %alias "PAM_PROCESS" (%string(255) parm)
extern void PROCESSPARAMETERS(_imp_string255 PARM) __asm__("PAM_PROCESS");
// 21
// 22 %begin
int main(int argc, char **argv) { /*%begin*/
_imp_initialise(argc, argv);
// 23
// 24 %constinteger outstream=1
// 25 ! Codes for logical operators
// 26 %constinteger not=-1, or=-2, and=-3; !(OR-1=AND)
// 27 ! Flag-bit
// 28 %constinteger sign=16_80000000, forced=16_40000000
// 29
// 30 ! Control parameters
// 31 %owninteger min=4096
static int MIN = 4096;
// 32 %owninteger inc=4096
static int INC = 4096;
// 33 %owninteger echo=0; !copy input to output stream
static int ECHO = 0;
// 34 %owninteger squash=0; !compress output tables
static int SQUASH = 0;
// 35 %owninteger nin=0; !negate input variables
static int NIN = 0;
// 36 %owninteger nout=0; !negate output variables
static int NOUT = 0;
// 37 %owninteger check=0; !check completeness
static int CHECK = 0;
// 38 %owninteger mon=0; !monitoring selector (bits)
static int MON = 0;
// 39 %owninteger single=0; !apply single (rather than multiple) method
static int SINGLE = 0;
// 40 %owninteger tabin=0; !tabular input
static int TABIN = 0;
// 41
// 42 %owninteger instream=3
static int INSTREAM = 3;
// 43
// 44 %integer negin,ignorin,negout,ignorout
int NEGIN;
int IGNORIN;
int NEGOUT;
int IGNOROUT;
// 45 %integer count,aim; !current,target score
int COUNT;
int AIM;
// 46 %integer minsep; !minimum free space in array W
int MINSEP;
// 47 %integer sym
int SYM;
// 48 %integer start
int START;
// 49
// 50 %constinteger storebound=2000
// 51 %integer dclim,esslim,sp1,sp,np,np1; !index vars to array W
int DCLIM;
int ESSLIM;
int SP1;
int SP;
int NP;
int NP1;
// 52 %integer needsp
int NEEDSP;
// 53 %recordformat cell(%integer t,f,outs,flags)
struct CELL {
union {
struct {
int T;
int F;
int OUTS;
int FLAGS;
};
};
};
// 54 %record(cell) %array w(1:storebound); !stack -> <- nest
struct CELL W[2000];
// 55
// 56 %constinteger namebound=256
// 57 %integer inmax,outmin,namemax; !index vars to NAME,EXP
int INMAX;
int OUTMIN;
int NAMEMAX;
// 58 %string(7)%array name(1:namebound)
_imp_string7 NAME[256];
// 59 %integerarray exp(1:namebound)
int EXP[256];
// 60
// 61 %constinteger defbound=8192
// 62 %integer dp
int DP;
// 63 %integerarray def(1:defbound)
int DEF[8192];
// 64
// 65 %integerfn bits(%integer v)
int BITS(int V) {
// 66 %integer k
int K;
// 67 k = 0
K = 0;
// 68 k = 1 %and v = v<<1>>1 %if v < 0
if (V >= 0) goto L_0001;
K = 1;
V = (unsigned int)V << 1 >> 1;
L_0001:;
// 69 %while v # 0 %cycle
L_0002:;
if (V == 0) goto L_0003;
// 70 k = k+1
K = K + 1;
// 71 v = v&(v-1)
V = V & V - 1;
// 72 %repeat
goto L_0002;
L_0003:;
// 73 %result = k
return K;
// 74 %end
} /* end of BITS */
// 75
// 76 %routine out(%integer v)
void OUT(int V) {
// 77 out(v//10) %and v = v-v//10*10 %if v >= 10
if (V < 10) goto L_0004;
OUT(((long)V / (long)10));
V = V - ((long)V / (long)10) * 10;
L_0004:;
// 78 printsymbol(v+'0')
_imp_PRINTSYMBOL(V + 48);
// 79 %end
return;
} /* end of OUT */
// 80
// 81 %routine croak(%string(32) s)
void CROAK(_imp_string32 S) {
// 82 select output(0)
_imp_SELECTOUTPUT(0);
// 83 newline
_imp_NEWLINE();
// 84 printstring("*".s." Abandoned")
_imp_PRINTSTRING(
*({
__typeof__(_imp_string255) tmp = *({
_imp_string255 tmp =
_imp_join((_imp_string *)/*?*/ &*({
_imp_string255 tmp =
_imp_join((_imp_string *)/*?*/ _imp_str_literal_ptr("*"), (_imp_string *)/*?*/ &S);
(_imp_string255 *)&tmp;
}),
(_imp_string *)/*?*/ _imp_str_literal_ptr(" Abandoned"));
(_imp_string255 *)&tmp;
}) /*q*/;
(_imp_string255 *)&tmp;
})
);
// 85 %if sym # nl %start
if (SYM == 10) goto L_0005;
// 86 printstring(" at: ")
_imp_PRINTSTRING(_imp_str_literal(" at: "));
// 87 %cycle
L_0006:;
// 88 readsymbol(sym)
_imp_READSYMBOL(/*?*/ &SYM);
// 89 printsymbol(sym)
_imp_PRINTSYMBOL(SYM);
// 90 %repeat %until sym = nl
if (SYM == 10) goto L_0007;
goto L_0006;
L_0007:;
// 91 %finish
L_0005:;
// 92 %stop
_imp_stop(0);
// 93 %end
} /* end of CROAK */
// 94
// 95 %routine print time
void PRINTTIME(void) {
// 96 %integer t
int T;
// 97 t = cputime
T = CPUTIME();
// 98 print((t-start)/1000,5,3)
_imp_PRINT((double)((T - START) / 1000), 5, 3);
// 99 start = t
START = T;
// 100 %end
return;
} /* end of PRINTTIME */
// 101
// 102 %routine push(%record(cell) v)
void PUSH(struct CELL V) {
// 103 ! Store V on (descending) nest
// 104 np = np-1; w(np) = v
NP = NP - 1;
W[NP - 1] = V;
// 105 %return %if np-sp >= minsep
if (NP - SP < MINSEP) goto L_0008;
return;
L_0008:;
// 106 minsep = np-sp
MINSEP = NP - SP;
// 107 %return %if minsep > 2
if (MINSEP <= 2) goto L_0009;
return;
L_0009:;
// 108 croak("No space.")
CROAK(_imp_str_literal_size(32, "No space."));
// 109 %end
return;
} /* end of PUSH */
// 110
// 111 %routine stack(%record(cell) v)
void STACK(struct CELL V) {
// 112 ! Store V on (ascending) stack
// 113 w(sp) = v; sp = sp+1
W[SP - 1] = V;
SP = SP + 1;
// 114 %return %if np-sp > minsep
if (NP - SP <= MINSEP) goto L_000A;
return;
L_000A:;
// 115 minsep = np-sp
MINSEP = NP - SP;
// 116 %return %if minsep > 2
if (MINSEP <= 2) goto L_000B;
return;
L_000B:;
// 117 croak("No space.")
CROAK(_imp_str_literal_size(32, "No space."));
// 118 %end
return;
} /* end of STACK */
// 119
// 120 ! R e a d a n d c h e c k d a t a
// 121 !
// 122 %routine readin
void READIN(void) {
// 123 %integer bit,pos,pos1,found,first,dp1,outmax
int BIT;
int POS;
int POS1;
int FOUND;
int FIRST;
int DP1;
int OUTMAX;
// 124 %integer pend
int PEND;
// 125 %string(7) curname
_imp_string7 CURNAME;
// 126
// 127 %routine put(%integer v)
void PUT(int V) {
// 128 croak(" Definitions too long") %if dp > defbound
if (DP <= 8192) goto L_000C;
CROAK(_imp_str_literal_size(32, " Definitions too long"));
L_000C:;
// 129 def(dp) = v; dp = dp+1
DEF[DP - 1] = V;
DP = DP + 1;
// 130 %end
return;
} /* end of PUT */
// 131
// 132 %routine read sym
void READSYM(void) {
// 133 %on %event 9 %start
if (!_imp_on_event(9)) goto L_000D;
// 134 sym = '*'
SYM = 42;
// 135 instream = instream-1
INSTREAM = INSTREAM - 1;
// 136 %return %if instream = 0
if (INSTREAM != 0) goto L_000E;
return;
L_000E:;
// 137 %if instream < 0 %start
if (INSTREAM >= 0) goto L_000F;
// 138 sym = nl
SYM = 10;
// 139 croak("Premature end of input.")
CROAK(_imp_str_literal_size(32, "Premature end of input."));
// 140 %finish
L_000F:;
// 141 select input(instream)
_imp_SELECTINPUT(INSTREAM);
// 142 %finish
L_000D:;
// 143 sym = pend; pend = 0
SYM = PEND;
PEND = 0;
// 144 %return %if sym # 0
if (SYM == 0) goto L_0010;
return;
L_0010:;
// 145 %cycle
L_0011:;
// 146 readsymbol(sym)
_imp_READSYMBOL(/*?*/ &SYM);
// 147 printsymbol(sym) %if echo # 0
if (ECHO == 0) goto L_0012;
_imp_PRINTSYMBOL(SYM);
L_0012:;
// 148 %return %unless sym = '{'
if (SYM == 123) goto L_0013;
return;
L_0013:;
// 149 %cycle
L_0014:;
// 150 read symbol(sym)
_imp_READSYMBOL(/*?*/ &SYM);
// 151 print symbol(sym) %if echo # 0
if (ECHO == 0) goto L_0015;
_imp_PRINTSYMBOL(SYM);
L_0015:;
// 152 %repeat %until sym = '}'
if (SYM == 125) goto L_0016;
goto L_0014;
L_0016:;
// 153 %repeat
goto L_0011;
// 154 %end
} /* end of READSYM */
// 155
// 156 %routine read name
void READNAME(void) {
// 157 !Read name (possibly null) to CURNAME leaving terminator in SYM
// 158 %integer k,l
int K;
int L;
// 159 read sym %until sym > ' '
L_0017:;
READSYM();
if (SYM > 32) goto L_0018;
goto L_0017;
L_0018:;
// 160 l = 0
L = 0;
// 161 k = sym; k = k-'a'+'A' %if k >= 'a'
K = SYM;
if (K < 97) goto L_0019;
K = K - 97 + 65;
L_0019:;
// 162 %if 'A' <= k <= 'Z' %start
{
// Double-sided test on K (Part I)
int tmp;
if (65 > (tmp = K)) goto L_001A;
// Double-sided test on K (Part II)
if (tmp > 90) goto L_001A;
}
// 163 %cycle
L_001B:;
// 164 %if l < 6 %start
if (L >= 6) goto L_001C;
// 165 l = l+1; charno(curname,l) = k
L = L + 1;
*_imp_CHARNO((_imp_string255 *)/*p*/ /*?*/ &CURNAME, L) = K;
// 166 %finish
L_001C:;
// 167 read sym
READSYM();
// 168 k = sym; k = k-'a'+'A' %if k >= 'a'
K = SYM;
if (K < 97) goto L_001D;
K = K - 97 + 65;
L_001D:;
// 169 %exit %unless '0' <= k <= '9' %c
{
// Double-sided test on K (Part I)
int tmp;
if (48 > (tmp = K)) goto L_001E;
// Double-sided test on K (Part II)
if (tmp <= 57) goto L_001F;
}
L_001E:;
if (*_imp_CHARNO((_imp_string255 *)/*p*/ /*?*/ &CURNAME, L) < 65) goto L_0020;
{
// Double-sided test on K (Part I)
int tmp;
if (65 > (tmp = K)) goto L_0020;
// Double-sided test on K (Part II)
if (tmp <= 90) goto L_001F;
}
L_0020:;
goto L_0021;
L_001F:;
// 170+ %or (charno(curname,l) >= 'A' %and 'A' <= k <= 'Z')
// 171 %repeat
goto L_001B;
L_0021:;
// 172 %if sym = '?' %start
if (SYM != 63) goto L_0022;
// 173 l = l+1; charno(curname,l) = sym
L = L + 1;
*_imp_CHARNO((_imp_string255 *)/*p*/ /*?*/ &CURNAME, L) = SYM;
// 174 read sym
READSYM();
// 175 %finish
L_0022:;
// 176 %finish
L_001A:;
// 177 length(curname) = l
*_imp_LENGTH((_imp_string255 *)/*p*/ /*?*/ &CURNAME) = L;
// 178 %if sym=' ' %start
if (SYM != 32) goto L_0023;
// 179 read sym %until sym#' '
L_0024:;
READSYM();
if (SYM != 32) goto L_0025;
goto L_0024;
L_0025:;
// 180 %if 'A'<=sym&95<='Z' %start
{
// Double-sided test on SYM & 95 (Part I)
int tmp;
if (65 > (tmp = SYM & 95)) goto L_0026;
// Double-sided test on SYM & 95 (Part II)
if (tmp > 90) goto L_0026;
}
// 181 pend = sym; sym = ' '
PEND = SYM;
SYM = 32;
// 182 %finish
L_0026:;
// 183 %finish
L_0023:;
// 184 %end
return;
} /* end of READNAME */
// 185
// 186 %routine init(%integername v)
void INIT(int *V) {
// 187 ! Read asignment for mode variable V (default 1)
// 188 found = 1
FOUND = 1;
// 189 v = 1
*V = 1;
// 190 read(v) %and out(v) %if sym = '='
if (SYM != 61) goto L_0027;
_imp_READ(V);
OUT(*V);
L_0027:;
// 191 %end
return;
} /* end of INIT */
// 192
// 193 %routine lookup
void LOOKUP(void) {
// 194 pos = namemax+1
POS = NAMEMAX + 1;
// 195 pos = pos-1 %until pos = 0 %or name(pos) = curname
L_0028:;
POS = POS - 1;
if (POS == 0) goto L_0029;
if (_imp_strcmp((_imp_string *)/*?*/ &NAME[POS - 1], (_imp_string *)/*?*/ &CURNAME) == 0) goto L_0029;
goto L_0028;
L_0029:;
// 196 %end
return;
} /* end of LOOKUP */
// 197
// 198 %routine queryname
void QUERYNAME(void) {
// 199 newline %if echo # 0
if (ECHO == 0) goto L_002A;
_imp_NEWLINE();
L_002A:;
// 200 printstring(curname." not known")
_imp_PRINTSTRING(
*({
__typeof__(_imp_string255) tmp = *({
_imp_string255 tmp =
_imp_join((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr(" not known"));
(_imp_string255 *)&tmp;
}) /*q*/;
(_imp_string255 *)&tmp;
})
);
// 201 newline
_imp_NEWLINE();
// 202 %end
return;
} /* end of QUERYNAME */
// 203
// 204 %routine addname
void ADDNAME(void) {
// 205 namemax = namemax+1
NAMEMAX = NAMEMAX + 1;
// 206 name(namemax) = curname
_imp_strncpy(/*?*/ &NAME[NAMEMAX - 1], ({
__typeof__(_imp_string7) tmp; /*B*/
tmp = CURNAME;
(void *)&tmp;
}),
/*max:*/ 7);
// 207 %end
return;
} /* end of ADDNAME */
// 208
// 209 %routine newname
void NEWNAME(void) {
// 210 croak("Duplicate: ".curname.". ") %if pos # 0
if (POS == 0) goto L_002B;
CROAK(
*({
__typeof__(_imp_string255) tmp = *({
_imp_string255 tmp = _imp_join((_imp_string *)/*?*/ &*({
_imp_string255 tmp =
_imp_join((_imp_string *)/*?*/ _imp_str_literal_ptr("Duplicate: "),
(_imp_string *)/*?*/ &CURNAME);
(_imp_string255 *)&tmp;
}),
(_imp_string *)/*?*/ _imp_str_literal_ptr(". "));
(_imp_string255 *)&tmp;
}) /*q*/;
(_imp_string32 *)&tmp;
})
);
L_002B:;
// 211 addname
ADDNAME();
// 212 %end
return;
} /* end of NEWNAME */
// 213
// 214 %routine read exp
void READEXP(void) {
// 215 ! Read logic expression: store as Polish
// 216 ! operands represented as name index values (> 0)
// 217 ! operators < 0
// 218 ! eg A&B ! \A&\B ==> 1 2 AND NOT 1 NOT NOT 2 NOT AND OR 0
// 219 ! A B & \ A \ \ B \ & !
// 220 ! note duplication of NOT before and after
// 221
// 222 %routine read term
void READTERM(void) {
// 223 read name
READNAME();
// 224 %if curname # "" %start
if (_imp_strcmp((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr("")) == 0) goto L_002C;
// 225 pend = sym %if sym >= 'A' %or sym = '('
if (SYM >= 65) goto L_002D;
if (SYM != 40) goto L_002E;
L_002D:;
PEND = SYM;
L_002E:;
// 226 lookup
LOOKUP();
// 227 queryname %and pos = 1 %if pos = 0
if (POS != 0) goto L_002F;
QUERYNAME();
POS = 1;
L_002F:;
// 228 put(pos)
PUT(POS);
// 229 %finish %else %if sym = '\' %start
goto L_0030;
L_002C:;
if (SYM != 92) goto L_0031;
// 230 put(not); !fore ..
PUT(-1);
// 231 read term
READTERM();
// 232 put(not); ! .. as well as aft
PUT(-1);
// 233 %finish %else %start
goto L_0030;
L_0031:;
// 234 croak("Faulty format. ") %if sym # '('
if (SYM == 40) goto L_0032;
CROAK(_imp_str_literal_size(32, "Faulty format. "));
L_0032:;
// 235 read exp
READEXP();
// 236 croak("Missing ')'. ") %if sym # ')'
if (SYM == 41) goto L_0033;
CROAK(_imp_str_literal_size(32, "Missing ')'. "));
L_0033:;
// 237 read sym
READSYM();
// 238 %finish
L_0030:;
// 239 %end
return;
} /* end of READTERM */
// 240
// 241 %routine read exp1
void READEXP1(void) {
// 242 read term
READTERM();
// 243 %while sym = '&' %or sym = '.' %or sym >= 'A' %or sym = '(' %cycle
L_0034:;
if (SYM == 38) goto L_0035;
if (SYM == 46) goto L_0035;
if (SYM >= 65) goto L_0035;
if (SYM != 40) goto L_0036;
L_0035:;
// 244 read term
READTERM();
// 245 put(and)
PUT(-3);
// 246 %repeat
goto L_0034;
L_0036:;
// 247 %end
return;
} /* end of READEXP1 */
// 248
// 249 read exp1
READEXP1();
// 250 %while sym = '!' %or sym = '+' %cycle
L_0037:;
if (SYM == 33) goto L_0038;
if (SYM != 43) goto L_0039;
L_0038:;
// 251 read exp1
READEXP1();
// 252 put(or)
PUT(-2);
// 253 %repeat
goto L_0037;
L_0039:;
// 254 %end; !READ EXP
return;
} /* end of READEXP */
// 255
// 256 namemax = 0; dp = 1
NAMEMAX = 0;
DP = 1;
// 257 pend = 0
PEND = 0;
// 258 ! MODE settings (if any)
// 259 %cycle
L_003A:;
// 260 read name
READNAME();
// 261 %stop %if sym = '*'
if (SYM != 42) goto L_003B;
_imp_stop(0);
L_003B:;
// 262 %exit %unless curname = "MODE"
if (_imp_strcmp((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr("MODE")) == 0) goto L_003C;
goto L_003D;
L_003C:;
// 263 printstring("MODE ") %and printsymbol(pend) %if echo=0
if (ECHO != 0) goto L_003E;
_imp_PRINTSTRING(_imp_str_literal("MODE "));
_imp_PRINTSYMBOL(PEND);
L_003E:;
// 264 echo = echo-2
ECHO = ECHO - 2;
// 265 %cycle
L_003F:;
// 266 read name
READNAME();
// 267 found = 0
FOUND = 0;
// 268 init(nin) %if curname = "NIN"
if (_imp_strcmp((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr("NIN")) != 0) goto L_0040;
INIT(/*?*/ &NIN);
L_0040:;
// 269 init(nout) %if curname = "NOUT"
if (_imp_strcmp((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr("NOUT")) != 0) goto L_0041;
INIT(/*?*/ &NOUT);
L_0041:;
// 270 init(min) %if curname = "MIN"
if (_imp_strcmp((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr("MIN")) != 0) goto L_0042;
INIT(/*?*/ &MIN);
L_0042:;
// 271 init(inc) %if curname = "INC"
if (_imp_strcmp((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr("INC")) != 0) goto L_0043;
INIT(/*?*/ &INC);
L_0043:;
// 272 init(echo) %if curname = "ECHO"
if (_imp_strcmp((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr("ECHO")) != 0) goto L_0044;
INIT(/*?*/ &ECHO);
L_0044:;
// 273 init(squash) %if curname = "SQUASH"
if (_imp_strcmp((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr("SQUASH")) != 0)
goto L_0045;
INIT(/*?*/ &SQUASH);
L_0045:;
// 274 init(check) %if curname = "CHECK"
if (_imp_strcmp((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr("CHECK")) != 0)
goto L_0046;
INIT(/*?*/ &CHECK);
L_0046:;
// 275 init(mon) %if curname = "MON"
if (_imp_strcmp((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr("MON")) != 0) goto L_0047;
INIT(/*?*/ &MON);
L_0047:;
// 276 init(single) %if curname = "SINGLE"
if (_imp_strcmp((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr("SINGLE")) != 0)
goto L_0048;
INIT(/*?*/ &SINGLE);
L_0048:;
// 277 init(tabin) %if curname = "TABIN"
if (_imp_strcmp((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr("TABIN")) != 0)
goto L_0049;
INIT(/*?*/ &TABIN);
L_0049:;
// 278 init(tabin) %and tabin = 1-tabin %if curname="EQUIN"
if (_imp_strcmp((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr("EQUIN")) != 0)
goto L_004A;
INIT(/*?*/ &TABIN);
TABIN = 1 - TABIN;
L_004A:;
// 279 printsymbol('?') %if found = 0
if (FOUND != 0) goto L_004B;
_imp_PRINTSYMBOL(63);
L_004B:;
// 280 %repeat %until sym # ','
if (SYM != 44) goto L_004C;
goto L_003F;
L_004C:;
// 281 %if echo<0 %start
if (ECHO >= 0) goto L_004D;
// 282 echo = echo+2
ECHO = ECHO + 2;
// 283 newline %if echo=0
if (ECHO != 0) goto L_004E;
_imp_NEWLINE();
L_004E:;
// 284 %finish
L_004D:;
// 285 %repeat
goto L_003A;
L_003D:;
// 286 ! INput list
// 287 croak("Keyword ".curname."? ") %if curname # "IN"
if (_imp_strcmp((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr("IN")) == 0) goto L_004F;
CROAK(
*({
__typeof__(_imp_string255) tmp = *({
_imp_string255 tmp = _imp_join((_imp_string *)/*?*/ &*({
_imp_string255 tmp =
_imp_join((_imp_string *)/*?*/ _imp_str_literal_ptr("Keyword "),
(_imp_string *)/*?*/ &CURNAME);
(_imp_string255 *)&tmp;
}),
(_imp_string *)/*?*/ _imp_str_literal_ptr("? "));
(_imp_string255 *)&tmp;
}) /*q*/;
(_imp_string32 *)&tmp;
})
);
L_004F:;
// 288 pend = sym %if pend=0
if (PEND != 0) goto L_0050;
PEND = SYM;
L_0050:;
// 289 bit = 1; negin = 0; ignorin = 0
BIT = 1;
NEGIN = 0;
IGNORIN = 0;
// 290 %cycle
L_0051:;
// 291 croak("Too many inputs.") %if bit = 0
if (BIT != 0) goto L_0052;
CROAK(_imp_str_literal_size(32, "Too many inputs."));
L_0052:;
// 292 read sym %until sym>' ' %and sym#','
L_0053:;
READSYM();
if (SYM <= 32) goto L_0054;
if (SYM != 44) goto L_0055;
L_0054:;
goto L_0053;
L_0055:;
// 293 %if sym = '-' %start
if (SYM != 45) goto L_0056;
// 294 ignorin = ignorin+bit
IGNORIN = IGNORIN + BIT;
// 295 curname = "-"
_imp_strncpy(/*?*/ &CURNAME, ({
__typeof__(_imp_string255) tmp; /*B*/
tmp = _imp_str_literal("-");
(void *)&tmp;
}),
/*max:*/ 7);
// 296 read sym
READSYM();
// 297 %finish %else %start
goto L_0057;
L_0056:;
// 298 %if sym = '\' %then negin = negin+bit %c
if (SYM != 92) goto L_0058;
NEGIN = NEGIN + BIT;
goto L_0059;
L_0058:;
PEND = SYM;
L_0059:;
// 299+ %else pend = sym
// 300 read name
READNAME();
// 301 lookup
LOOKUP();
// 302 %finish
L_0057:;
// 303 newname
NEWNAME();
// 304 exp(namemax) = bit
EXP[NAMEMAX - 1] = BIT;
// 305 bit = bit<<1
BIT = BIT << 1;
// 306 %repeat %until sym # ','
if (SYM != 44) goto L_005A;
goto L_0051;
L_005A:;
// 307 inmax = namemax
INMAX = NAMEMAX;
// 308 negin = \negin %if nin # 0
if (NIN == 0) goto L_005B;
NEGIN = (~NEGIN);
L_005B:;
// 309 ! logic equations
// 310 %if tabin = 0 %start
if (TABIN != 0) goto L_005C;
// 311 %cycle
L_005D:;
// 312 read name
READNAME();
// 313 %exit %if sym # '='
if (SYM == 61) goto L_005E;
goto L_005F;
L_005E:;
// 314 lookup
LOOKUP();
// 315 pos = 0 %if pos <= inmax
if (POS > INMAX) goto L_0060;
POS = 0;
L_0060:;
// 316 newname
NEWNAME();
// 317 exp(namemax) = dp; !start of Polish representation
EXP[NAMEMAX - 1] = DP;
// 318 namemax = namemax-1; !hide LH name to exclude self-ref
NAMEMAX = NAMEMAX - 1;
// 319 read exp
READEXP();
// 320 namemax = namemax+1; !restore LH name
NAMEMAX = NAMEMAX + 1;
// 321 put(0); !terminator
PUT(0);
// 322 croak("Faulty format. ") %if sym # nl
if (SYM == 10) goto L_0061;
CROAK(_imp_str_literal_size(32, "Faulty format. "));
L_0061:;
// 323 %repeat
goto L_005D;
L_005F:;
// 324 %finish %else %start; !tabular input
goto L_0062;
L_005C:;
// 325 pos1 = namebound+1; outmax = 0
POS1 = 256 + 1;
OUTMAX = 0;
// 326 %cycle
L_0063:;
// 327 read sym %until sym > ' '
L_0064:;
READSYM();
if (SYM > 32) goto L_0065;
goto L_0064;
L_0065:;
// 328 pend=sym %and %exit %if sym&95 = 'O'
if (SYM & 95 != 79) goto L_0066;
PEND = SYM;
goto L_0067;
L_0066:;
// 329 pos1 = pos1-1
POS1 = POS1 - 1;
// 330 croak("Too many table entries") %if pos1 = namemax
if (POS1 != NAMEMAX) goto L_0068;
CROAK(_imp_str_literal_size(32, "Too many table entries"));
L_0068:;
// 331 exp(pos1) = 0
EXP[POS1 - 1] = 0;
// 332 first = 1
FIRST = 1;
// 333 %for pos = 1,1,inmax %cycle
// %for POS = 1, 1, INMAX %cycle
{
int _final = INMAX;
if (invalid_for_loop(1, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle POS = 1, 1, INMAX");
POS = 0;
L_0069:
if (POS == _final) goto L_006A;
POS += 1;
// 334 %if ignorin>>(pos-1)&1 = 0 %c
if ((unsigned int)IGNORIN >> POS - 1 & 1 != 0) goto L_006C;
if (SYM == 48) goto L_006D;
if (SYM != 49) goto L_006C;
L_006D:;
// 335+ %and (sym = '0' %or sym = '1') %start
// 336 %if sym = '1' %then put(pos) %c
if (SYM != 49) goto L_006E;
PUT(POS);
goto L_006F;
L_006E:;
PUT(-1);
PUT(POS);
PUT(-1);
L_006F:;
// 337+ %else put(not) %and put(pos) %and put(not)
// 338 put(and) %if first = 0
if (FIRST != 0) goto L_0070;
PUT(-3);
L_0070:;
// 339 first = 0
FIRST = 0;
// 340 %finish
L_006C:;
// 341 read sym %until sym # ' '
L_0071:;
READSYM();
if (SYM != 32) goto L_0072;
goto L_0071;
L_0072:;
// 342 %repeat
goto L_0069;
}
L_006A:;
// 343 put(0)
PUT(0);
// 344 bit = 1; namemax = inmax
BIT = 1;
NAMEMAX = INMAX;
// 345 %while sym # nl %cycle
L_0073:;
if (SYM == 10) goto L_0074;
// 346 croak("Faulty entry. ") %if (sym # '0' %and sym # '1') %c
if (SYM == 48) goto L_0075;
if (SYM != 49) goto L_0076;
L_0075:;
if (NAMEMAX != OUTMAX) goto L_0077;
L_0076:;
CROAK(_imp_str_literal_size(32, "Faulty entry. "));
L_0077:;
// 347+ %or namemax = outmax
// 348 exp(pos1) = exp(pos1)!bit %if sym = '1'
if (SYM != 49) goto L_0078;
EXP[POS1 - 1] = EXP[POS1 - 1] | BIT;
L_0078:;
// 349 bit = bit<<1; namemax = namemax+1
BIT = BIT << 1;
NAMEMAX = NAMEMAX + 1;
// 350 read sym %until sym # ' '
L_0079:;
READSYM();
if (SYM != 32) goto L_007A;
goto L_0079;
L_007A:;
// 351 %repeat
goto L_0073;
L_0074:;
// 352 outmax = namemax %if outmax = 0
if (OUTMAX != 0) goto L_007B;
OUTMAX = NAMEMAX;
L_007B:;
// 353 croak("Faulty entry. ") %if outmax # namemax
if (OUTMAX == NAMEMAX) goto L_007C;
CROAK(_imp_str_literal_size(32, "Faulty entry. "));
L_007C:;
// 354 %repeat
goto L_0063;
L_0067:;
// 355 bit = 1
BIT = 1;
// 356 bit = \0 %and namemax = inmax+1 %if check # 0
if (CHECK == 0) goto L_007D;
BIT = (~0);
NAMEMAX = INMAX + 1;
L_007D:;
// 357 %for pos = inmax+1,1,namemax %cycle
// %for POS = INMAX + 1, 1, NAMEMAX %cycle
{
int _initial = INMAX + 1, _final = NAMEMAX;
if (invalid_for_loop(_initial, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle POS = INMAX + 1, 1, NAMEMAX");
POS = _initial - (1);
L_007E:
if (POS == _final) goto L_007F;
POS += 1;
// 358 exp(pos) = dp
EXP[POS - 1] = DP;
// 359 first = 1
FIRST = 1;
// 360 %integer first pos1 A = pos1 {workaround}
int FIRSTPOS1A;
FIRSTPOS1A = POS1;
// 361 %for pos1 = namebound,-1,first{workaround}pos1 A %cycle
// %for POS1 = 256, -1, FIRSTPOS1A %cycle
{
int _final = FIRSTPOS1A;
if (invalid_for_loop(256, -1, _final)) _imp_signal(5, 1, 0, "Illegal cycle POS1 = 256, -1, FIRSTPOS1A");
POS1 = 257;
L_0081:
if (POS1 == _final) goto L_0082;
POS1 -= 1;
// 362 %if exp(pos1)&bit # 0 %start
if (EXP[POS1 - 1] & BIT == 0) goto L_0083;
// 363 put(pos1)
PUT(POS1);
// 364 put(or) %if first = 0
if (FIRST != 0) goto L_0084;
PUT(-2);
L_0084:;
// 365 first = 0
FIRST = 0;
// 366 %finish
L_0083:;
// 367 %repeat
goto L_0081;
}
L_0082:;
// 368 put(0)
PUT(0);
// 369 bit = bit<<1
BIT = BIT << 1;
// 370 %repeat
goto L_007E;
}
L_007F:;
// 371 dp1 = 1
DP1 = 1;
// 372 %integer first pos1 B = pos1 {workaround}
int FIRSTPOS1B;
FIRSTPOS1B = POS1;
// 373 %for pos1 = namebound,-1,first{workaround}pos1 B %cycle
// %for POS1 = 256, -1, FIRSTPOS1B %cycle
{
int _final = FIRSTPOS1B;
if (invalid_for_loop(256, -1, _final)) _imp_signal(5, 1, 0, "Illegal cycle POS1 = 256, -1, FIRSTPOS1B");
POS1 = 257;
L_0085:
if (POS1 == _final) goto L_0086;
POS1 -= 1;
// 374 exp(pos1) = dp1
EXP[POS1 - 1] = DP1;
// 375 dp1 = dp1+1 %until def(dp1-1) = 0
L_0087:;
DP1 = DP1 + 1;
if (DEF[DP1 - 1 - 1] == 0) goto L_0088;
goto L_0087;
L_0088:;
// 376 %repeat
goto L_0085;
}
L_0086:;
// 377 read name
READNAME();
// 378 %finish
L_0062:;
// 379 ! OUTput list
// 380 ! note that OUTput names are added again
// 381 ! to simplify treatment of "Don't cares"
// 382 croak("Keyword ".curname."? ") %if curname # "OUT"
if (_imp_strcmp((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr("OUT")) == 0) goto L_0089;
CROAK(
*({
__typeof__(_imp_string255) tmp = *({
_imp_string255 tmp = _imp_join((_imp_string *)/*?*/ &*({
_imp_string255 tmp =
_imp_join((_imp_string *)/*?*/ _imp_str_literal_ptr("Keyword "),
(_imp_string *)/*?*/ &CURNAME);
(_imp_string255 *)&tmp;
}),
(_imp_string *)/*?*/ _imp_str_literal_ptr("? "));
(_imp_string255 *)&tmp;
}) /*q*/;
(_imp_string32 *)&tmp;
})
);
L_0089:;
// 383 pend = sym %if pend=0
if (PEND != 0) goto L_008A;
PEND = SYM;
L_008A:;
// 384 outmin = namemax+1; pos = inmax
OUTMIN = NAMEMAX + 1;
POS = INMAX;
// 385 negout = 0; ignorout = 0; bit = 1
NEGOUT = 0;
IGNOROUT = 0;
BIT = 1;
// 386 %cycle
L_008B:;
// 387 croak("Too many outputs. ") %if namemax-outmin+2 > 32
if (NAMEMAX - OUTMIN + 2 <= 32) goto L_008C;
CROAK(_imp_str_literal_size(32, "Too many outputs. "));
L_008C:;
// 388 read sym %until sym>' ' %and sym#','
L_008D:;
READSYM();
if (SYM <= 32) goto L_0080;
if (SYM != 44) goto L_008E;
L_0080:;
goto L_008D;
L_008E:;
// 389 %if sym = '-' %start
if (SYM != 45) goto L_008F;
// 390 ignorout = ignorout+bit
IGNOROUT = IGNOROUT + BIT;
// 391 curname = "-"
_imp_strncpy(/*?*/ &CURNAME, ({
__typeof__(_imp_string255) tmp; /*B*/
tmp = _imp_str_literal("-");
(void *)&tmp;
}),
/*max:*/ 7);
// 392 read sym
READSYM();
// 393 %finish %else %start
goto L_0090;
L_008F:;
// 394 %if sym = '\' %then negout = negout+bit %c
if (SYM != 92) goto L_0091;
NEGOUT = NEGOUT + BIT;
goto L_0092;
L_0091:;
PEND = SYM;
L_0092:;
// 395+ %else pend = sym
// 396 read name
READNAME();
// 397 %finish
L_0090:;
// 398 %if tabin = 0 %then lookup %else pos = pos+1
if (TABIN != 0) goto L_0093;
LOOKUP();
goto L_0094;
L_0093:;
POS = POS + 1;
L_0094:;
// 399 %if pos # 0 %start; !should be there
if (POS == 0) goto L_0095;
// 400 addname
ADDNAME();
// 401 exp(namemax) = dp
EXP[NAMEMAX - 1] = DP;
// 402 put(pos)
PUT(POS);
// 403 %if tabin = 0 %start
if (TABIN != 0) goto L_0096;
// 404 curname = curname."?"; !any "Don't cares" for this one?
_imp_strncpy(/*?*/ &CURNAME, ({
__typeof__(_imp_string255) tmp; /*B*/
tmp = *({
_imp_string255 tmp =
_imp_join((_imp_string *)/*?*/ &CURNAME, (_imp_string *)/*?*/ _imp_str_literal_ptr("?"));
(_imp_string255 *)&tmp;
});
(void *)&tmp;
}),
/*max:*/ 7);
// 405 lookup
LOOKUP();
// 406 %if pos # 0 %start; !if so
if (POS == 0) goto L_0097;
// 407 put(pos)
PUT(POS);
// 408 put(or)
PUT(-2);
// 409 %finish
L_0097:;
// 410 %finish
L_0096:;
// 411 put(0)
PUT(0);
// 412 %finish %else %start
goto L_0098;
L_0095:;
// 413 queryname
QUERYNAME();
// 414 %finish
L_0098:;
// 415 bit = bit<<1
BIT = BIT << 1;
// 416 %repeat %until sym # ','
if (SYM != 44) goto L_0099;
goto L_008B;
L_0099:;
// 417 %stop %if outmin > namemax; !no (surviving) outputs
if (OUTMIN <= NAMEMAX) goto L_009A;
_imp_stop(0);
L_009A:;
// 418 croak("Faulty format. ") %if sym # nl
if (SYM == 10) goto L_009B;
CROAK(_imp_str_literal_size(32, "Faulty format. "));
L_009B:;
// 419 negout = \negout %if nout # 0
if (NOUT == 0) goto L_009C;
NEGOUT = (~NEGOUT);
L_009C:;
// 420 %end; !READIN
return;
} /* end of READIN */
// 421
// 422 %routine print term(%record(cell) v, %integer x)
void PRINTTERM(struct CELL V, int X) {
// 423 %integer i,l
int I;
int L;
// 424 %for i = 1,1,inmax %cycle
// %for I = 1, 1, INMAX %cycle
{
int _final = INMAX;
if (invalid_for_loop(1, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle I = 1, 1, INMAX");
I = 0;
L_009D:
if (I == _final) goto L_009E;
I += 1;
// 425 space %if squash = 0
if (SQUASH != 0) goto L_00A0;
_imp_SPACE();
L_00A0:;
// 426 %if (v_t!v_f)&1 # 0 %start
if ((V.T | V.F) & 1 == 0) goto L_00A1;
// 427 l = ' '
L = 32;
// 428 l = '\' %if v_f&1 # 0
if (V.F & 1 == 0) goto L_00A2;
L = 92;
L_00A2:;
// 429 printsymbol(l)
_imp_PRINTSYMBOL(L);
// 430 print string(name(i))
_imp_PRINTSTRING(
*({
__typeof__(_imp_string7) tmp = NAME[I - 1] /*q*/;
(_imp_string255 *)&tmp;
})
);
// 431 %finish %else %start
goto L_00A3;
L_00A1:;
// 432 l = length(name(i))
L = *_imp_LENGTH((_imp_string255 *)/*p*/ /*?*/ &NAME[I - 1]);
// 433 spaces((l+1)//2)
_imp_SPACES(((long)(L + 1) / (long)2));
// 434 printsymbol('.')
_imp_PRINTSYMBOL(46);
// 435 spaces(l//2)
_imp_SPACES(((long)L / (long)2));
// 436 %finish
L_00A3:;
// 437 v_t = v_t>>1; v_f = v_f>>1
V.T = (unsigned int)V.T >> 1;
V.F = (unsigned int)V.F >> 1;
// 438 %repeat
goto L_009D;
}
L_009E:;
// 439 space %if squash = 0
if (SQUASH != 0) goto L_00A4;
_imp_SPACE();
L_00A4:;
// 440 printsymbol(':')
_imp_PRINTSYMBOL(58);
// 441 %for i = outmin,1,namemax %cycle
// %for I = OUTMIN, 1, NAMEMAX %cycle
{
int _initial = OUTMIN, _final = NAMEMAX;
if (invalid_for_loop(_initial, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle I = OUTMIN, 1, NAMEMAX");
I = _initial - (1);
L_00A5:
if (I == _final) goto L_00A6;
I += 1;
// 442 space
_imp_SPACE();
// 443 %if v_outs&1 # 0 %start
if (V.OUTS & 1 == 0) goto L_00A7;
// 444 printstring(name(i))
_imp_PRINTSTRING(
*({
__typeof__(_imp_string7) tmp = NAME[I - 1] /*q*/;
(_imp_string255 *)&tmp;
})
);
// 445 %finish %else %start
goto L_00A8;
L_00A7:;
// 446 l = length(name(i))
L = *_imp_LENGTH((_imp_string255 *)/*p*/ /*?*/ &NAME[I - 1]);
// 447 spaces((l-1)//2)
_imp_SPACES(((long)(L - 1) / (long)2));
// 448 %if x&1 = 0 %then printsymbol('.') %c
if (X & 1 != 0) goto L_00A9;
_imp_PRINTSYMBOL(46);
goto L_00AA;
L_00A9:;
_imp_PRINTSYMBOL(63);
L_00AA:;
// 449+ %else printsymbol('?')
// 450 spaces(l//2)
_imp_SPACES(((long)L / (long)2));
// 451 %finish
L_00A8:;
// 452 v_outs = v_outs>>1; x = x>>1
V.OUTS = (unsigned int)V.OUTS >> 1;
X = (unsigned int)X >> 1;
// 453 %repeat
goto L_00A5;
}
L_00A6:;
// 454 newline
_imp_NEWLINE();
// 455 %end
return;
} /* end of PRINTTERM */
// 456
// 457 %routine monitor(%integer lim)
void MONITOR(int LIM) {
// 458 %integer q
int Q;
// 459 newline
_imp_NEWLINE();
// 460 q = 1
Q = 1;
// 461 %while q # lim %cycle
L_00AB:;
if (Q == LIM) goto L_00AC;
// 462 write(q,2) %if mon&4 # 0
if (MON & 4 == 0) goto L_00AD;
_imp_WRITE(Q, 2);
L_00AD:;
// 463 print term(w(q),0)
PRINTTERM(W[Q - 1], 0);
// 464 q = q+1
Q = Q + 1;
// 465 %repeat
goto L_00AB;
L_00AC:;
// 466 newline
_imp_NEWLINE();
// 467 %end
return;
} /* end of MONITOR */
// 468
// 469 %routine copydown
void COPYDOWN(void) {
// 470 np1 = np
NP1 = NP;
// 471 %while sp # sp1 %cycle
L_00AE:;
if (SP == SP1) goto L_00AF;
// 472 sp = sp-1; np = np-1
SP = SP - 1;
NP = NP - 1;
// 473 w(np) = w(sp)
W[NP - 1] = W[SP - 1];
// 474 %repeat
goto L_00AE;
L_00AF:;
// 475 %end
return;
} /* end of COPYDOWN */
// 476
// 477 %routine erase(%integer p)
void ERASE(int P) {
// 478 sp = sp-1
SP = SP - 1;
// 479 %while p # sp %cycle
L_00B0:;
if (P == SP) goto L_00B1;
// 480 w(p) = w(p+1)
W[P - 1] = W[P + 1 - 1];
// 481 p = p+1
P = P + 1;
// 482 %repeat
goto L_00B0;
L_00B1:;
// 483 %end
return;
} /* end of ERASE */
// 484
// 485 %routine merge
void MERGE(void) {
// 486 %integer p,k,same
int P;
int K;
int SAME;
// 487 %ownrecord(cell) v,n=0
static struct CELL V;
static struct CELL N = {0};
// 488 %while np # np1 %cycle
L_00B2:;
if (NP == NP1) goto L_00B3;
// 489 v = w(np); np = np+1
V = W[NP - 1];
NP = NP + 1;
// 490 p = sp1; same = 0
P = SP1;
SAME = 0;
// 491 %while p # sp %cycle
L_00B4:;
if (P == SP) goto L_00B5;
// 492 %if w(p)_t!v_t = v_t %and w(p)_f!v_f = v_f %start; !V -> @P
if (W[P - 1].T | V.T != V.T) goto L_00B6;
if (W[P - 1].F | V.F != V.F) goto L_00B6;
// 493 v_outs = v_outs&(\w(p)_outs)
V.OUTS = V.OUTS & (~W[P - 1].OUTS);
// 494 %exit %if v_outs = 0
if (V.OUTS != 0) goto L_00B7;
goto L_00B5;
L_00B7:;
// 495 same = p %if w(p)_t = v_t %and w(p)_f = v_f
if (W[P - 1].T != V.T) goto L_00B8;
if (W[P - 1].F != V.F) goto L_00B8;
SAME = P;
L_00B8:;
// 496 %finish
L_00B6:;
// 497 p = p+1
P = P + 1;
// 498 %repeat
goto L_00B4;
L_00B5:;
// 499 %if v_outs # 0 %start
if (V.OUTS == 0) goto L_00B9;
// 500 %while p # sp1 %cycle
L_00BA:;
if (P == SP1) goto L_00BB;
// 501 p = p-1
P = P - 1;
// 502 n_outs = w(p)_outs&v_outs
N.OUTS = W[P - 1].OUTS & V.OUTS;
// 503 %if n_outs # 0 %start
if (N.OUTS == 0) goto L_00BC;
// 504 n_t = w(p)_t!v_t; n_f = w(p)_f!v_f
N.T = W[P - 1].T | V.T;
N.F = W[P - 1].F | V.F;
// 505 k = (n_t)&n_f
K = N.T & N.F;
// 506 %if k # 0 %and (k-1)&k = 0 %start; !singleton
if (K == 0) goto L_00BD;
if (K - 1 & K != 0) goto L_00BD;
// 507 n_t = n_t!!k; n_f = n_f!!k
N.T = N.T ^ K;
N.F = N.F ^ K;
// 508 push(n)
PUSH(N);
// 509 v_outs = v_outs!!n_outs %if n_t!v_t = v_t %and n_f!v_f = v_f; !V -> N
if (N.T | V.T != V.T) goto L_00BE;
if (N.F | V.F != V.F) goto L_00BE;
V.OUTS = V.OUTS ^ N.OUTS;
L_00BE:;
// 510 n_t = n_t!w(p)_t; n_f = n_f!w(p)_f
N.T = N.T | W[P - 1].T;
N.F = N.F | W[P - 1].F;
// 511 %finish
L_00BD:;
// 512 %if n_t = w(p)_t %and n_f = w(p)_f %start; !@P -> N
if (N.T != W[P - 1].T) goto L_00BF;
if (N.F != W[P - 1].F) goto L_00BF;
// 513 w(p)_outs = w(p)_outs!!n_outs
W[P - 1].OUTS = W[P - 1].OUTS ^ N.OUTS;
// 514 %if w(p)_outs = 0 %start
if (W[P - 1].OUTS != 0) goto L_00C0;
// 515 erase(p)
ERASE(P);
// 516 same = same-1 %if same > p
if (SAME <= P) goto L_00C1;
SAME = SAME - 1;
L_00C1:;
// 517 %finish
L_00C0:;
// 518 %finish
L_00BF:;
// 519 %exit %if v_outs = 0
if (V.OUTS != 0) goto L_00C2;
goto L_00BB;
L_00C2:;
// 520 %finish
L_00BC:;
// 521 %repeat
goto L_00BA;
L_00BB:;
// 522 %if v_outs # 0 %start
if (V.OUTS == 0) goto L_00C3;
// 523 %if same = 0 %start
if (SAME != 0) goto L_00C4;
// 524 w(sp) = v; sp = sp+1
W[SP - 1] = V;
SP = SP + 1;
// 525 %finish %else %start
goto L_00C5;
L_00C4:;
// 526 w(same)_outs = w(same)_outs+v_outs
W[SAME - 1].OUTS = W[SAME - 1].OUTS + V.OUTS;
// 527 %finish
L_00C5:;
// 528 %finish
L_00C3:;
// 529 %finish
L_00B9:;
// 530 %repeat
goto L_00B2;
L_00B3:;
// 531 %end
return;
} /* end of MERGE */
// 532
// 533 ! C o n v e r t f r o m P o l i s h t o i n t e r n a l
// 534 !
// 535 %routine convert
void CONVERT(void) {
// 536 %integer outbit,oldsp,i,j,k,p,q,hp,inv
int OUTBIT;
int OLDSP;
int I;
int J;
int K;
int P;
int Q;
int HP;
int INV;
// 537 %ownrecord(cell) v=0
static struct CELL V = {0};
// 538 %integerarray hold(1:20)
int HOLD[20];
// 539
// 540 %routine convert(%integer j)
void CONVERT(int J) {
// 541 %integer defp
int DEFP;
// 542 defp = exp(j)
DEFP = EXP[J - 1];
// 543 %cycle
L_00C6:;
// 544 j = def(defp); defp = defp+1; !get next item
J = DEF[DEFP - 1];
DEFP = DEFP + 1;
// 545 %return %if j = 0; !terminator
if (J != 0) goto L_00C7;
return;
L_00C7:;
// 546 %if j > 0 %start; !operand
if (J <= 0) goto L_00C8;
// 547 %if j > inmax %start; !start of sub-def
if (J <= INMAX) goto L_00C9;
// 548 convert(j)
CONVERT(J);
// 549 %finish %else %start
goto L_00CA;
L_00C9:;
// 550 hp = hp+1; hold(hp) = sp1
HP = HP + 1;
HOLD[HP - 1] = SP1;
// 551 sp1 = sp
SP1 = SP;
// 552 v_t = exp(j); v_f = 0
V.T = EXP[J - 1];
V.F = 0;
// 553 v_f = v_t %and v_t = 0 %if inv!!(negin>>(j-1)&1) # 0
if (INV ^ (unsigned int)NEGIN >> J - 1 & 1 == 0) goto L_00CB;
V.F = V.T;
V.T = 0;
L_00CB:;
// 554 stack(v)
STACK(V);
// 555 %finish
L_00CA:;
// 556 %finish %else %if j = not %start
goto L_00CC;
L_00C8:;
if (J != -1) goto L_00CD;
// 557 inv = inv!!1
INV = INV ^ 1;
// 558 %finish %else %if j-inv = and %start; !'AND' or inverted 'OR'
goto L_00CC;
L_00CD:;
if (J - INV != -3) goto L_00CE;
// 559 np1 = np; !Form pairwise intersection on nest
NP1 = NP;
// 560 %while sp # sp1 %cycle
L_00CF:;
if (SP == SP1) goto L_00D0;
// 561 sp = sp-1
SP = SP - 1;
// 562 p = sp1
P = SP1;
// 563 %while p # hold(hp) %cycle
L_00D1:;
if (P == HOLD[HP - 1]) goto L_00D2;
// 564 p = p-1
P = P - 1;
// 565 v_t = w(sp)_t!w(p)_t; v_f = w(sp)_f!w(p)_f
V.T = W[SP - 1].T | W[P - 1].T;
V.F = W[SP - 1].F | W[P - 1].F;
// 566 push(v) %if v_t&v_f = 0; !intersection ok
if (V.T & V.F != 0) goto L_00D3;
PUSH(V);
L_00D3:;
// 567 %repeat
goto L_00D1;
L_00D2:;
// 568 %repeat
goto L_00CF;
L_00D0:;
// 569 sp1 = hold(hp); hp = hp-1
SP1 = HOLD[HP - 1];
HP = HP - 1;
// 570 sp = sp1; !start with stack empty
SP = SP1;
// 571 merge
MERGE();
// 572 %finish %else %start; !'OR' or inverted 'AND'
goto L_00CC;
L_00CE:;
// 573 copydown; !one operand to nest
COPYDOWN();
// 574 sp1 = hold(hp); hp = hp-1
SP1 = HOLD[HP - 1];
HP = HP - 1;
// 575 merge
MERGE();
// 576 %finish
L_00CC:;
// 577 %repeat
goto L_00C6;
// 578 %end
} /* end of CONVERT */
// 579
// 580 sp = 1; np = storebound; minsep = np-sp
SP = 1;
NP = 2000;
MINSEP = NP - SP;
// 581 v_flags = 0
V.FLAGS = 0;
// 582 outbit = 1
OUTBIT = 1;
// 583 %for i = outmin,1,namemax %cycle
// %for I = OUTMIN, 1, NAMEMAX %cycle
{
int _initial = OUTMIN, _final = NAMEMAX;
if (invalid_for_loop(_initial, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle I = OUTMIN, 1, NAMEMAX");
I = _initial - (1);
L_00D4:
if (I == _final) goto L_00D5;
I += 1;
// 584 %if ignorout&outbit = 0 %start
if (IGNOROUT & OUTBIT != 0) goto L_00D6;
// 585 k = def(exp(i)+1); !2nd element of def
K = DEF[EXP[I - 1] + 1 - 1];
// 586 %if k # 0 %start; !"Don't cares" present
if (K == 0) goto L_00D7;
// 587 sp1 = 1; hp = 0; inv = 0
SP1 = 1;
HP = 0;
INV = 0;
// 588 v_outs = outbit
V.OUTS = OUTBIT;
// 589 convert(k)
CONVERT(K);
// 590 copydown
COPYDOWN();
// 591 sp1 = 1
SP1 = 1;
// 592 merge
MERGE();
// 593 %finish
L_00D7:;
// 594 %finish
L_00D6:;
// 595 outbit = outbit<<1
OUTBIT = OUTBIT << 1;
// 596 %repeat
goto L_00D4;
}
L_00D5:;
// 597 dclim = sp
DCLIM = SP;
// 598 outbit = 1
OUTBIT = 1;
// 599 %for i = outmin,1,namemax %cycle
// %for I = OUTMIN, 1, NAMEMAX %cycle
{
int _initial = OUTMIN, _final = NAMEMAX;
if (invalid_for_loop(_initial, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle I = OUTMIN, 1, NAMEMAX");
I = _initial - (1);
L_00D8:
if (I == _final) goto L_00D9;
I += 1;
// 600 %if ignorout&outbit = 0 %start
if (IGNOROUT & OUTBIT != 0) goto L_00DA;
// 601 sp1 = 1; hp = 0; inv = negout>>(i-outmin)&1
SP1 = 1;
HP = 0;
INV = (unsigned int)NEGOUT >> I - OUTMIN & 1;
// 602 v_outs = outbit
V.OUTS = OUTBIT;
// 603 convert(i)
CONVERT(I);
// 604 copydown
COPYDOWN();
// 605 sp1 = dclim
SP1 = DCLIM;
// 606 %if single # 0 %then merge %else %start
if (SINGLE == 0) goto L_00DB;
MERGE();
goto L_00DC;
L_00DB:;
// 607 oldsp = sp
OLDSP = SP;
// 608 %while np # np1 %cycle; !each element against rest
L_00DD:;
if (NP == NP1) goto L_00DE;
// 609 q = sp1-1; ! and null (ie straight)
Q = SP1 - 1;
// 610 v = 0
V = (struct CELL){0};
// 611 %cycle
L_00DF:;
// 612 v_t = v_t!w(np)_t; v_f = v_f!w(np)_f
V.T = V.T | W[NP - 1].T;
V.F = V.F | W[NP - 1].F;
// 613 %if v_t&v_f = 0 %start
if (V.T & V.F != 0) goto L_00E0;
// 614 v_outs = v_outs!outbit
V.OUTS = V.OUTS | OUTBIT;
// 615 p = sp
P = SP;
// 616 %while p # sp1 %cycle
L_00E1:;
if (P == SP1) goto L_00E2;
// 617 p = p-1
P = P - 1;
// 618 v_outs = v_outs!w(p)_outs %if w(p)_t = v_t %and w(p)_f = v_f
if (W[P - 1].T != V.T) goto L_00E3;
if (W[P - 1].F != V.F) goto L_00E3;
V.OUTS = V.OUTS | W[P - 1].OUTS;
L_00E3:;
// 619 j = w(p)_t!v_t; k = w(p)_f!v_f
J = W[P - 1].T | V.T;
K = W[P - 1].F | V.F;
// 620 %exit %if j = v_t %and k = v_f %and w(p)_outs&v_outs = v_outs; !V -> @P
if (J != V.T) goto L_00E4;
if (K != V.F) goto L_00E4;
if (W[P - 1].OUTS & V.OUTS != V.OUTS) goto L_00E4;
goto L_00E2;
L_00E4:;
// 621 %if j = w(p)_t %and k = w(p)_f %and w(p)_outs&v_outs = w(p)_outs %start
if (J != W[P - 1].T) goto L_00E5;
if (K != W[P - 1].F) goto L_00E5;
if (W[P - 1].OUTS & V.OUTS != W[P - 1].OUTS) goto L_00E5;
// 622 oldsp = oldsp-1 %if p < oldsp
if (P >= OLDSP) goto L_00E6;
OLDSP = OLDSP - 1;
L_00E6:;
// 623 q = q-1 %if p <= q
if (P > Q) goto L_00E7;
Q = Q - 1;
L_00E7:;
// 624 erase(p)
ERASE(P);
// 625 %finish
L_00E5:;
// 626 %repeat
goto L_00E1;
L_00E2:;
// 627 stack(v) %if p = sp1
if (P != SP1) goto L_00E8;
STACK(V);
L_00E8:;
// 628 %finish
L_00E0:;
// 629 q = q+1
Q = Q + 1;
// 630 %exit %if q = oldsp
if (Q != OLDSP) goto L_00E9;
goto L_00EA;
L_00E9:;
// 631 v = w(q)
V = W[Q - 1];
// 632 %repeat
goto L_00DF;
L_00EA:;
// 633 np = np+1
NP = NP + 1;
// 634 %repeat
goto L_00DD;
L_00DE:;
// 635 %finish
L_00DC:;
// 636 %finish
L_00DA:;
// 637 outbit = outbit<<1
OUTBIT = OUTBIT << 1;
// 638 %repeat
goto L_00D8;
}
L_00D9:;
// 639 %end; !convert
return;
} /* end of CONVERT */
// 640
// 641 %integerfn needed(%integer q,testlim)
int NEEDED(int Q, int TESTLIM) {
// 642 %integer p
int P;
// 643 %ownrecord(cell) v,n=0
static struct CELL V;
static struct CELL N = {0};
// 644 sp1 = sp; np1 = np
SP1 = SP;
NP1 = NP;
// 645 v = w(q)
V = W[Q - 1];
// 646 w(sp1)_t = v_t; w(sp1)_f = v_f
W[SP1 - 1].T = V.T;
W[SP1 - 1].F = V.F;
// 647 w(sp1)_outs = 0
W[SP1 - 1].OUTS = 0;
// 648 sp = sp+1
SP = SP + 1;
// 649 p = 1
P = 1;
// 650 %while p # testlim %cycle
L_00EB:;
if (P == TESTLIM) goto L_00EC;
// 651 %if w(p)_flags >= 0 %start
if (W[P - 1].FLAGS < 0) goto L_00ED;
// 652 n_outs = w(p)_outs&v_outs
N.OUTS = W[P - 1].OUTS & V.OUTS;
// 653 %if n_outs # 0 %and p # q %start
if (N.OUTS == 0) goto L_00EE;
if (P == Q) goto L_00EE;
// 654 n_t = w(p)_t!v_t; n_f = w(p)_f!v_f
N.T = W[P - 1].T | V.T;
N.F = W[P - 1].F | V.F;
// 655 %if n_t&n_f = 0 %start
if (N.T & N.F != 0) goto L_00EF;
// 656 np = np-1; w(np) = n
NP = NP - 1;
W[NP - 1] = N;
// 657 merge
MERGE();
// 658 %exit %if w(sp1)_outs = v_outs
if (W[SP1 - 1].OUTS != V.OUTS) goto L_00F0;
goto L_00EC;
L_00F0:;
// 659 %finish
L_00EF:;
// 660 %finish
L_00EE:;
// 661 %finish
L_00ED:;
// 662 p = p+1
P = P + 1;
// 663 %repeat
goto L_00EB;
L_00EC:;
// 664 needsp = sp
NEEDSP = SP;
// 665 sp = sp1
SP = SP1;
// 666 %result = p
return P;
// 667 %end
} /* end of NEEDED */
// 668
// 669 %routine print all
void PRINTALL(void) {
// 670 %integer p,q
int P;
int Q;
// 671 newlines(2)
_imp_NEWLINES(2);
// 672 q = dclim; q = esslim %if mon&2 # 0
Q = DCLIM;
if (MON & 2 == 0) goto L_00F1;
Q = ESSLIM;
L_00F1:;
// 673 %while q # sp %cycle
L_00F2:;
if (Q == SP) goto L_00F3;
// 674 %if w(q)_flags >= 0 %start
if (W[Q - 1].FLAGS < 0) goto L_00F4;
// 675 p = needed(q,sp)
P = NEEDED(Q, SP);
// 676 write(q,2) %if mon&4 # 0
if (MON & 4 == 0) goto L_00F5;
_imp_WRITE(Q, 2);
L_00F5:;
// 677 w(sp1)_outs = w(q)_outs-w(sp1)_outs
W[SP1 - 1].OUTS = W[Q - 1].OUTS - W[SP1 - 1].OUTS;
// 678 print term(w(sp1),w(q)_outs)
PRINTTERM(W[SP1 - 1], W[Q - 1].OUTS);
// 679 %finish
L_00F4:;
// 680 q = q+1
Q = Q + 1;
// 681 %repeat
goto L_00F2;
L_00F3:;
// 682 newline
_imp_NEWLINE();
// 683 %end
return;
} /* end of PRINTALL */
// 684
// 685 %routine pcount
void PCOUNT(void) {
// 686 write(count>>12,1)
_imp_WRITE((unsigned int)COUNT >> 12, 1);
// 687 printsymbol('/')
_imp_PRINTSYMBOL(47);
// 688 out(count&4095)
OUT(COUNT & 4095);
// 689 %end
return;
} /* end of PCOUNT */
// 690
// 691 %routine promote(%integer q,past)
void PROMOTE(int Q, int PAST) {
// 692 %record(cell) v
struct CELL V;
// 693 v = w(q)
V = W[Q - 1];
// 694 %if past = 0 %start
if (PAST != 0) goto L_00F6;
// 695 count = count+bits(v_t!v_f)+4096
COUNT = COUNT + BITS(V.T | V.F) + 4096;
// 696 past = esslim
PAST = ESSLIM;
// 697 esslim = esslim+1
ESSLIM = ESSLIM + 1;
// 698 %finish
L_00F6:;
// 699 %while past # esslim %and past # dclim %cycle
L_00F7:;
if (PAST == ESSLIM) goto L_00F8;
if (PAST == DCLIM) goto L_00F8;
// 700 %exit %if w(past-1)_flags <= v_flags
if (W[PAST - 1 - 1].FLAGS > V.FLAGS) goto L_00F9;
goto L_00F8;
L_00F9:;
// 701 past = past-1
PAST = PAST - 1;
// 702 %repeat
goto L_00F7;
L_00F8:;
// 703 %while q # past %cycle
L_00FA:;
if (Q == PAST) goto L_00FB;
// 704 q = q-1
Q = Q - 1;
// 705 w(q+1) = w(q)
W[Q + 1 - 1] = W[Q - 1];
// 706 %repeat
goto L_00FA;
L_00FB:;
// 707 w(q) = v
W[Q - 1] = V;
// 708 %end
return;
} /* end of PROMOTE */
// 709
// 710 ! R e d u c e n u m b e r o f i m p l i c a n t s
// 711 !
// 712 %routine reduce1
void REDUCE1(void) {
// 713 ! Find first essentials and redundants
// 714 ! order by weight
// 715 %integer p,q
int P;
int Q;
// 716 q = dclim; esslim = q
Q = DCLIM;
ESSLIM = Q;
// 717 %while q # sp %cycle
L_00FC:;
if (Q == SP) goto L_00FD;
// 718 w(q)_flags = bits(w(q)_t!w(q)_f)<<5+31-bits(w(q)_outs)
W[Q - 1].FLAGS = (BITS(W[Q - 1].T | W[Q - 1].F) << 5) + 31 - BITS(W[Q - 1].OUTS);
// 719 p = needed(q,sp)
P = NEEDED(Q, SP);
// 720 %if p = sp %start; !essential
if (P != SP) goto L_00FE;
// 721 promote(q,0)
PROMOTE(Q, 0);
// 722 %finish %else %if p >= esslim %start; !optional
goto L_00FF;
L_00FE:;
if (P < ESSLIM) goto L_0100;
// 723 promote(q,q)
PROMOTE(Q, Q);
// 724 %finish %else %start; !redundant
goto L_00FF;
L_0100:;
// 725 erase(q)
ERASE(Q);
// 726 q = q-1
Q = Q - 1;
// 727 %finish
L_00FF:;
// 728 q = q+1
Q = Q + 1;
// 729 %repeat
goto L_00FC;
L_00FD:;
// 730 %end; !reduce1
return;
} /* end of REDUCE1 */
// 731
// 732 %routine reduce2
void REDUCE2(void) {
// 733 ! Find secondary essentials & redundants
// 734 %integer p,q,bq,sphold,done
int P;
int Q;
int BQ;
int SPHOLD;
int DONE;
// 735 %record(cell) v
struct CELL V;
// 736 %cycle
L_0101:;
// 737 done = 1
DONE = 1;
// 738 q = sp
Q = SP;
// 739 %while q # esslim %cycle
L_0102:;
if (Q == ESSLIM) goto L_0103;
// 740 q = q-1
Q = Q - 1;
// 741 p = needed(q,esslim)
P = NEEDED(Q, ESSLIM);
// 742 %if p = esslim %start; !not (simply) redundant
if (P != ESSLIM) goto L_0104;
// 743 w(q)_outs = w(q)_outs-w(sp1)_outs
W[Q - 1].OUTS = W[Q - 1].OUTS - W[SP1 - 1].OUTS;
// 744 w(sp1)_outs = 0
W[SP1 - 1].OUTS = 0;
// 745 bq = w(q)_flags>>5
BQ = (unsigned int)W[Q - 1].FLAGS >> 5;
// 746 sphold = sp
SPHOLD = SP;
// 747 %while p # sp %cycle
L_0105:;
if (P == SP) goto L_0106;
// 748 %if w(p)_flags>>5-min < bq %and p # q %start
if (((unsigned int)W[P - 1].FLAGS >> 5) - MIN >= BQ) goto L_0107;
if (P == Q) goto L_0107;
// 749 v_outs = w(p)_outs&w(q)_outs
V.OUTS = W[P - 1].OUTS & W[Q - 1].OUTS;
// 750 %if v_outs # 0 %start
if (V.OUTS == 0) goto L_0108;
// 751 v_t = w(p)_t!w(q)_t; v_f = w(p)_f!w(q)_f
V.T = W[P - 1].T | W[Q - 1].T;
V.F = W[P - 1].F | W[Q - 1].F;
// 752 %if v_t&v_f = 0 %start
if (V.T & V.F != 0) goto L_0109;
// 753 sp1 = sp; sp = needsp
SP1 = SP;
SP = NEEDSP;
// 754 %while sp1 # needsp %cycle
L_010A:;
if (SP1 == NEEDSP) goto L_010B;
// 755 w(sp) = w(sp1)
W[SP - 1] = W[SP1 - 1];
// 756 sp = sp+1; sp1 = sp1+1
SP = SP + 1;
SP1 = SP1 + 1;
// 757 %repeat
goto L_010A;
L_010B:;
// 758 push(v)
PUSH(V);
// 759 merge
MERGE();
// 760 sp = sphold
SP = SPHOLD;
// 761 %exit %if w(sp1)_outs = w(q)_outs
if (W[SP1 - 1].OUTS != W[Q - 1].OUTS) goto L_010C;
goto L_0106;
L_010C:;
// 762 %finish
L_0109:;
// 763 %finish
L_0108:;
// 764 %finish
L_0107:;
// 765 p = p+1
P = P + 1;
// 766 %repeat
goto L_0105;
L_0106:;
// 767 %finish
L_0104:;
// 768 %if p # sp %start; !redundant
if (P == SP) goto L_010D;
// 769 erase(q)
ERASE(Q);
// 770 p = p-1 %if p > q
if (P <= Q) goto L_010E;
P = P - 1;
L_010E:;
// 771 %if p >= esslim %start; !P may now be essential
if (P < ESSLIM) goto L_010F;
// 772 %if needed(p,sp) = sp %start
if (NEEDED(P, SP) != SP) goto L_0110;
// 773 q = q+1 %if p >= q
if (P < Q) goto L_0111;
Q = Q + 1;
L_0111:;
// 774 promote(p,0)
PROMOTE(P, 0);
// 775 done = 0
DONE = 0;
// 776 %finish
L_0110:;
// 777 %finish
L_010F:;
// 778 %finish
L_010D:;
// 779 %repeat
goto L_0102;
L_0103:;
// 780 %repeat %until done # 0
if (DONE != 0) goto L_0112;
goto L_0101;
L_0112:;
// 781 %end; !reduce2
return;
} /* end of REDUCE2 */
// 782
// 783 %routine order
void ORDER(void) {
// 784 %integer j,k,p,q,r,poss,last
int J;
int K;
int P;
int Q;
int R;
int POSS;
int LAST;
// 785 %integerarray link(1:sp)
int LINK[SP - 1 + 1];
// 786 %record(cell) v
struct CELL V;
// 787 q = sp; poss = 0; last = sp
Q = SP;
POSS = 0;
LAST = SP;
// 788 %while q # esslim %cycle
L_0113:;
if (Q == ESSLIM) goto L_0114;
// 789 q = q-1
Q = Q - 1;
// 790 p = needed(q,sp)
P = NEEDED(Q, SP);
// 791 link(q) = p
LINK[Q - 1] = P;
// 792 %if p > q %and link(p) > p %start
if (P <= Q) goto L_0115;
if (LINK[P - 1] <= P) goto L_0115;
// 793 poss = poss+1
POSS = POSS + 1;
// 794 poss = poss+99 %if q # last
if (Q == LAST) goto L_0116;
POSS = POSS + 99;
L_0116:;
// 795 v = w(p); !promote P before Q
V = W[P - 1];
// 796 r = sp
R = SP;
// 797 %cycle
L_0117:;
// 798 r = r-1
R = R - 1;
// 799 j = link(r)
J = LINK[R - 1];
// 800 %if j = p %then j = q %else %if q <= j < p %then j = j+1
if (J != P) goto L_0118;
J = Q;
goto L_0119;
L_0118:;
{
// Double-sided test on J (Part I)
int tmp;
if (Q > (tmp = J)) goto L_011A;
// Double-sided test on J (Part II)
if (tmp >= P) goto L_011A;
}
J = J + 1;
L_011A:;
L_0119:;
// 801 %if r >= p %then %start
if (R < P) goto L_011B;
// 802 link(r) = j
LINK[R - 1] = J;
// 803 %finish %else %start
goto L_011C;
L_011B:;
// 804 link(r+1) = j
LINK[R + 1 - 1] = J;
// 805 w(r+1) = w(r)
W[R + 1 - 1] = W[R - 1];
// 806 %finish
L_011C:;
// 807 %repeat %until r = q
if (R == Q) goto L_011D;
goto L_0117;
L_011D:;
// 808 w(r) = v
W[R - 1] = V;
// 809 q = q+2; last = q-1; !try Q again
Q = Q + 2;
LAST = Q - 1;
// 810 %finish
L_0115:;
// 811 %repeat
goto L_0113;
L_0114:;
// 812 write(poss,1)
_imp_WRITE(POSS, 1);
// 813 !First pass
// 814 %cycle
L_011E:;
// 815 v = w(q)
V = W[Q - 1];
// 816 v_flags = v_flags>>5
V.FLAGS = (unsigned int)V.FLAGS >> 5;
// 817 p = needed(q,sp)
P = NEEDED(Q, SP);
// 818 %if p > q %start
if (P <= Q) goto L_011F;
// 819 count = count+v_flags+4096
COUNT = COUNT + V.FLAGS + 4096;
// 820 w(q)_flags = v_flags+count<<5
W[Q - 1].FLAGS = V.FLAGS + (COUNT << 5);
// 821 %finish %else %start
goto L_0120;
L_011F:;
// 822 %cycle
L_0121:;
// 823 p = p+1
P = P + 1;
// 824 %repeat %until w(p)_flags >= 0
if (W[P - 1].FLAGS >= 0) goto L_0122;
goto L_0121;
L_0122:;
// 825 r = q
R = Q;
// 826 %while r # p %cycle
L_0123:;
if (R == P) goto L_0124;
// 827 r = r-1
R = R - 1;
// 828 w(r+1) = w(r)
W[R + 1 - 1] = W[R - 1];
// 829 %repeat
goto L_0123;
L_0124:;
// 830 v_flags = w(r-1)_flags&16_0FFFFFE0+v_flags+sign
V.FLAGS = (W[R - 1 - 1].FLAGS & 268435424) + V.FLAGS + (-2147483648);
// 831 w(r) = v
W[R - 1] = V;
// 832 %finish
L_0120:;
// 833 q = q+1
Q = Q + 1;
// 834 %repeat %until q = sp
if (Q == SP) goto L_0125;
goto L_011E;
L_0125:;
// 835 %end;
return;
} /* end of ORDER */
// ?K unused
// 836 ; !order
// 836
// 837 ! F i n d m i n i m a l s e l e c t i o n
// 838 !
// 839 %routine minimise
void MINIMISE(void) {
// 840 ! Find minimal selection
// 841 %integer k,p,q,m
int K;
int P;
int Q;
int M;
// 842 q = sp
Q = SP;
// 843 %cycle
L_0126:;
// 844 %while q # sp %cycle
L_0127:;
if (Q == SP) goto L_0128;
// 845 m = w(q)_flags
M = W[Q - 1].FLAGS;
// 846 p = needed(q,sp)
P = NEEDED(Q, SP);
// 847 %if p = sp %start; !mandatory
if (P != SP) goto L_0129;
// 848 m = m+forced
M = M + 1073741824;
// 849 %finish %else %start; !optional or redundant
goto L_012A;
L_0129:;
// 850 m = m+(sign+forced) %if p < q; !redundant
if (P >= Q) goto L_012B;
M = M + ((-2147483648) + 1073741824);
L_012B:;
// 851 %finish
L_012A:;
// 852 %if m >= 0 %start; !selected
if (M < 0) goto L_012C;
// 853 k = m&31+count+4096
K = (M & 31) + COUNT + 4096;
// 854 %exit %if k+inc > aim
if (K + INC <= AIM) goto L_012D;
goto L_0128;
L_012D:;
// 855 %exit %if k+inc > m>>5&16_7FFFFF
if (K + INC <= (unsigned int)M >> 5 & 8388607) goto L_012E;
goto L_0128;
L_012E:;
// 856 count = k
COUNT = K;
// 857 %finish
L_012C:;
// 858 w(q)_flags = m
W[Q - 1].FLAGS = M;
// 859 q = q+1
Q = Q + 1;
// 860 %repeat
goto L_0127;
L_0128:;
// 861 %if q = sp %start; !scan completed successfully
if (Q != SP) goto L_012F;
// 862 pcount
PCOUNT();
// 863 printall %if inc = 0 %or mon&1 # 0
if (INC == 0) goto L_006B;
if (MON & 1 == 0) goto L_0130;
L_006B:;
PRINTALL();
L_0130:;
// 864 aim = count
AIM = COUNT;
// 865 q = esslim
Q = ESSLIM;
// 866 %while q # sp %cycle; !save marker bits
L_0131:;
if (Q == SP) goto L_0132;
// 867 k = w(q)_flags&16_cfffffff
K = W[Q - 1].FLAGS & (-805306369);
// 868 w(q)_flags = (k&16_c0000000)>>2+k
W[Q - 1].FLAGS = ((unsigned int)(K & (-1073741824)) >> 2) + K;
// 869 q = q+1
Q = Q + 1;
// 870 %repeat
goto L_0131;
L_0132:;
// 871 %finish
L_012F:;
// 872 %cycle; !scan backward to de-select
L_0133:;
// 873 %if q = esslim %start; !scan completed
if (Q != ESSLIM) goto L_0134;
// 874 %while q # sp %cycle; !restore marker bits
L_0135:;
if (Q == SP) goto L_0136;
// 875 k = w(q)_flags&16_3fffffff
K = W[Q - 1].FLAGS & 1073741823;
// 876 w(q)_flags = (k&16_30000000)<<2+k
W[Q - 1].FLAGS = ((K & 805306368) << 2) + K;
// 877 q = q+1
Q = Q + 1;
// 878 %repeat
goto L_0135;
L_0136:;
// 879 %return %if inc <= min; !all done
if (INC > MIN) goto L_0137;
return;
L_0137:;
// 880 count = aim; !restore count
COUNT = AIM;
// 881 inc = inc>>1
INC = (unsigned int)INC >> 1;
// 882 print all %if inc = 0
if (INC != 0) goto L_0138;
PRINTALL();
L_0138:;
// 883 %finish
L_0134:;
// 884 q = q-1
Q = Q - 1;
// 885 m = w(q)_flags
M = W[Q - 1].FLAGS;
// 886 w(q)_flags = m&16_3fffffff
W[Q - 1].FLAGS = M & 1073741823;
// 887 %if m >= 0 %start
if (M < 0) goto L_0139;
// 888 k = m&31+4096
K = (M & 31) + 4096;
// 889 count = count-k
COUNT = COUNT - K;
// 890 %exit %if m&forced = 0
if (M & 1073741824 != 0) goto L_013A;
goto L_013B;
L_013A:;
// 891 %finish
L_0139:;
// 892 %repeat
goto L_0133;
L_013B:;
// 893 w(q)_flags = w(q)_flags+sign
W[Q - 1].FLAGS = W[Q - 1].FLAGS + (-2147483648);
// 894 q = q+1
Q = Q + 1;
// 895 %repeat
goto L_0126;
// 896 %end; !minimise
} /* end of MINIMISE */
// 897
// 898 %begin {initialise}
{ /*%begin*/
// 899 %string(255)in1=":N",in2=":N",in3,out=":T"
_imp_string255 IN1;
_imp_strncpy(/*?*/ &IN1, ({
__typeof__(_imp_string255) tmp; /*B*/
tmp = _imp_str_literal(":N");
(void *)&tmp;
}),
/*max:*/ 255);
_imp_string255 IN2;
_imp_strncpy(/*?*/ &IN2, ({
__typeof__(_imp_string255) tmp; /*B*/
tmp = _imp_str_literal(":N");
(void *)&tmp;
}),
/*max:*/ 255);
_imp_string255 IN3;
_imp_string255 OUT;
_imp_strncpy(/*?*/ &OUT, ({
__typeof__(_imp_string255) tmp; /*B*/
tmp = _imp_str_literal(":T");
(void *)&tmp;
}),
/*max:*/ 255);
// 900 %integer bools=16_05000000{single,equin}
int BOOLS;
BOOLS = 83886080;
// 901
// 902 %routine init(%integername n)
void INIT(int *N) {
// 903 n = 1 %if bools<0; bools = bools<<1
if (BOOLS >= 0) goto L_013C;
*N = 1;
L_013C:;
BOOLS = BOOLS << 1;
// 904 %end
return;
} /* end of INIT */
// 905
// 906 defineparam("Input file",in3,pamnodefault)
DEFINEPARAM(_imp_str_literal("Input file"), (_imp_string255 *)/*p*/ /*?*/ &IN3, 2);
// 907 defineparam("Input 2",in2,0)
DEFINEPARAM(_imp_str_literal("Input 2"), (_imp_string255 *)/*p*/ /*?*/ &IN2, 0);
// 908 defineparam("Input 3",in1,0)
DEFINEPARAM(_imp_str_literal("Input 3"), (_imp_string255 *)/*p*/ /*?*/ &IN1, 0);
// 909 defineparam("Output file",out,pamnewgroup)
DEFINEPARAM(_imp_str_literal("Output file"), (_imp_string255 *)/*p*/ /*?*/ &OUT, 1);
// 910 defineintparam("MIN",min,0)
DEFINEINTPARAM(_imp_str_literal("MIN"), /*?*/ &MIN, 0);
// 911 defineintparam("INC",inc,0)
DEFINEINTPARAM(_imp_str_literal("INC"), /*?*/ &INC, 0);
// 912 defineintparam("MON",mon,0)
DEFINEINTPARAM(_imp_str_literal("MON"), /*?*/ &MON, 0);
// 913 definebooleanparams("ECho,SQuash,NIn,NOut,Check,SIngle,Tabin,EQuin",bools,0)
DEFINEBOOLEANPARAMS(_imp_str_literal("ECho,SQuash,NIn,NOut,Check,SIngle,Tabin,EQuin"), /*?*/ &BOOLS, 0);
// 914 processparameters(cliparam)
PROCESSPARAMETERS(
*({
__typeof__(_imp_string255) tmp = CLIPARAM() /*q*/;
(_imp_string255 *)&tmp;
})
);
// 915 init(echo)
INIT(/*?*/ &ECHO);
// 916 init(squash)
INIT(/*?*/ &SQUASH);
// 917 init(nin)
INIT(/*?*/ &NIN);
// 918 init(nout)
INIT(/*?*/ &NOUT);
// 919 init(check)
INIT(/*?*/ &CHECK);
// 920 init(single)
INIT(/*?*/ &SINGLE);
// 921 init(tabin)
INIT(/*?*/ &TABIN);
// 922 tabin = 0 %if bools<0 {equin}
if (BOOLS >= 0) goto L_013D;
TABIN = 0;
L_013D:;
// 923 openinput(instream-2,in3)
_imp_OPENINPUT(INSTREAM - 2,
*({
__typeof__(_imp_string255) tmp = IN3 /*q*/;
(_imp_string255 *)&tmp;
})
);
// 924 openinput(instream-1,in2)
_imp_OPENINPUT(INSTREAM - 1,
*({
__typeof__(_imp_string255) tmp = IN2 /*q*/;
(_imp_string255 *)&tmp;
})
);
// 925 openinput(instream,in1)
_imp_OPENINPUT(INSTREAM,
*({
__typeof__(_imp_string255) tmp = IN1 /*q*/;
(_imp_string255 *)&tmp;
})
);
// 926 openoutput(outstream,out)
_imp_OPENOUTPUT(1,
*({
__typeof__(_imp_string255) tmp = OUT /*q*/;
(_imp_string255 *)&tmp;
})
);
// 927 %end
goto end_1000;
end_1000:;
}
// 928
// 929 select output(outstream)
_imp_SELECTOUTPUT(1);
// 930 select input(instream)
_imp_SELECTINPUT(INSTREAM);
// 931 %cycle
L_013E:;
// 932 start = cputime
START = CPUTIME();
// 933 readin
READIN();
// 934 printstring("Read in:")
_imp_PRINTSTRING(_imp_str_literal("Read in:"));
// 935 print time
PRINTTIME();
// 936 newline
_imp_NEWLINE();
// 937 convert
CONVERT();
// 938 aim = 999999; count = 0
AIM = 999999;
COUNT = 0;
// 939 printstring("Implicants:")
_imp_PRINTSTRING(_imp_str_literal("Implicants:"));
// 940 write(sp-dclim,3)
_imp_WRITE(SP - DCLIM, 3);
// 941 print time
PRINTTIME();
// 942 newline
_imp_NEWLINE();
// 943 print all %if inc#0 %and mon&16#0
if (INC == 0) goto L_013F;
if (MON & 16 == 0) goto L_013F;
PRINTALL();
L_013F:;
// 944 reduce1
REDUCE1();
// 945 printstring("Reduced(1):")
_imp_PRINTSTRING(_imp_str_literal("Reduced(1):"));
// 946 write(sp-dclim,3)
_imp_WRITE(SP - DCLIM, 3);
// 947 printstring(" (nucleus")
_imp_PRINTSTRING(_imp_str_literal(" (nucleus"));
// 948 pcount
PCOUNT();
// 949 printsymbol(')')
_imp_PRINTSYMBOL(41);
// 950 print time
PRINTTIME();
// 951 newline
_imp_NEWLINE();
// 952 print all %if inc # 0 %and mon&16#0
if (INC == 0) goto L_0140;
if (MON & 16 == 0) goto L_0140;
PRINTALL();
L_0140:;
// 953 %if sp # esslim %start
if (SP == ESSLIM) goto L_0141;
// 954 reduce2
REDUCE2();
// 955 printstring("Reduced(2):")
_imp_PRINTSTRING(_imp_str_literal("Reduced(2):"));
// 956 write(sp-dclim,3)
_imp_WRITE(SP - DCLIM, 3);
// 957 printstring(" (nucleus")
_imp_PRINTSTRING(_imp_str_literal(" (nucleus"));
// 958 pcount
PCOUNT();
// 959 printsymbol(')')
_imp_PRINTSYMBOL(41);
// 960 order %if sp # esslim
if (SP == ESSLIM) goto L_0142;
ORDER();
L_0142:;
// 961 print time
PRINTTIME();
// 962 newline
_imp_NEWLINE();
// 963 print all %if inc # 0 %and mon&16#0
if (INC == 0) goto L_0143;
if (MON & 16 == 0) goto L_0143;
PRINTALL();
L_0143:;
// 964 %finish
L_0141:;
// 965 monitor(esslim) %if mon&2 # 0
if (MON & 2 == 0) goto L_0144;
MONITOR(ESSLIM);
L_0144:;
// 966 %if sp # esslim %start
if (SP == ESSLIM) goto L_0145;
// 967 monitor(sp) %if mon&8 # 0
if (MON & 8 == 0) goto L_0146;
MONITOR(SP);
L_0146:;
// 968 printstring("Minimised:")
_imp_PRINTSTRING(_imp_str_literal("Minimised:"));
// 969 minimise
MINIMISE();
// 970 %finish
L_0145:;
// 971 print all %if inc # 0 %and mon&1 = 0
if (INC == 0) goto L_0147;
if (MON & 1 != 0) goto L_0147;
PRINTALL();
L_0147:;
// 972 printstring(" Cells used:")
_imp_PRINTSTRING(_imp_str_literal(" Cells used:"));
// 973 write(storebound-1-minsep,1)
_imp_WRITE(2000 - 1 - MINSEP, 1);
// 974 print time
PRINTTIME();
// 975 newline
_imp_NEWLINE();
// 976 %repeat
goto L_013E;
// 977
// 978 %endofprogram
end_0:;
}