int     nofloat;
int     peekc;
int     obuf[3+(512/sizeof(int))];	/***/
int     tabflg;
int	cflg;
int     labno   1;

main(argc, argv)
char **argv;
{
/*
	A1 -> A
	A2    B
	A     O
	B1    C
	B2    D
	BE    L
	BF    P
	C1    E
	C2    F
	F     G
	H     H
	R     I
	R1    J
	S     K
	I     M
	M     N

		*       +1
		S       +2
		C       +4
		1       +8

	z  -> 4
	c     8
	r     9
	a     14
	e     20
	n     63
	*       +0100
*/

	auto c,snlflg,nlflg,t,smode,m,ssmode;
	extern fin;

	smode = nlflg = snlflg = ssmode = cflg = 0;
	if (argc>1)
		if ((fin = open(argv[1], 0)) < 0) {
			printf("?\n");
			return;
		}
	obuf[0] = 1;
	if (argc>2)
		if ((obuf[0] = creat(argv[2], 0666)) < 0) {
			printf("?\n");
			return;
		}
loop:
	c = getcx();
	if (c!='\n' && c!='\t') nlflg = 0;
	if (ssmode!=0 && c!='%') {
		ssmode = 0;
/***/		printf("   IMPUR\nL%d   EQU   *\n\tDB  ", labno++);
/***/		cflg++;
	}
	switch(c) {

	case '\0':
/***/		printf("   PURE\n   DC   0\n   END\n");
		fflush(obuf);
		return;

	case ':':
		if (!smode)
/***/			printf("   EQU  *+ADC\n   DC   0"); else
			putchar(':');
		goto loop;

	case 'A':
		if ((c=getcx())=='1' || c=='2') {
			putchar(c+'A'-'1');
			goto loop;
		}
		putchar('O');
		peekc = c;
		goto loop;

	case 'B':
		switch (getcx()) {

		case '1':
			putchar('C');
			goto loop;

		case '2':
			putchar('D');
			goto loop;

		case 'E':
			putchar('L');
			goto loop;

		case 'F':
			putchar('P');
			goto loop;
		}
		putchar('?');
		goto loop;

	case 'C':
		putchar(getcx()+'E'-'1');
		goto loop;

	case 'F':
		putchar('G');
		goto subtre;

	case 'R':
		if ((c=getcx()) == '1')
		putchar('J'); else {
			putchar('I');
			peekc = c;
		}
		goto loop;

	case 'H':
		putchar('H');
		goto subtre;

	case 'I':
		putchar('M');
		goto loop;

	case 'S':
		putchar('K');
subtre:
		snlflg = 1;
		t = 'A';
l1:
		switch (c=getcx()) {

		case '*':
			t++;
			goto l1;

		case 'S':
			t =+ 2;
			goto l1;

		case 'C':
			t =+ 4;
			goto l1;

		case '1':
			t =+ 8;
			goto l1;

		case '2':
			t =+ 16;
			goto l1;
		}
		peekc = c;
		putchar(t);
		goto loop;

	case '#':
		if(getcx()=='1')
			putchar('#'); else
			putchar('"');
		goto loop;

	case '\'':
		printf("''");
		goto loop;

	case '%':
		if (smode)
/***/			printf("   PURE\n");
		if (ssmode==0) {
			if ((peekc=getcx())=='[') {
				peekc = 0;
/***/				printf("  IMPUR\n");
				while((c=getcx())!=']')
					putchar(c);
				getcx();
/***/				printf("  EQU *\n  PURE\n");
				goto loop;
			}
		}
loop1:
		switch (c=getcx()) {

		case ' ':
		case '\t':
			goto loop1;
		case 'a':
			m = 16;
			t = flag();
			goto pf;

		case ',':
/***			putchar(';');  ***/
			goto loop1;

		case 'i':
			m = 12;
			t = flag();
			goto pf;
		case 'z':
			m = 4;
			t = flag();
			goto pf;

		case 'r':
			m = 9;
			t = flag();
			goto pf;

		case '1':
			m = 5;
			t = flag();
			goto pf;

		case 'c':
			t = 0;
			m = 8;
			goto pf;

		case 'e':
			t = flag();
			m = 20;
			goto pf;

		case 'n':
			t = flag();
			m = 63;
pf:
			if ((c=getcx())=='*')
				m =+ 0100; else
				peekc = c;
/***/			printf("\tDB  X'%x',X'%x'\n", m, t);
			goto loop1;

		case '[':
			printf("L%d  EQU ", labno++);
			while((c=getcx()) != ']')
				putchar(c);
			getcx();
			putchar('\n');
			ssmode = 0;
			smode = 0;
			goto loop;

		case '\n':
/***/			printf("   DC   A(L%d)\n", labno);
			ssmode = 1;
			nlflg = 1;
			smode = 1;
			goto loop;
		}
		putchar(c);
		goto loop1;

	case '\t':
		if (smode) {
			tabflg++;
			goto loop;
		}
		if (nlflg) {
			nlflg = 0;
/***/			putchar('\t');
			goto loop;
		}
		putchar('\t');
		goto loop;

	case '\n':
		if (!smode)  {
			putchar('\n');
			goto loop;
		}
		if (nlflg) {
			nlflg = 0;
/***/			if (!cflg) {
/***/				printf("',");
/***/			}
/***/			cflg = 0;
/***/			printf("X'00'\n   PURE\n");
			smode = 0;
			goto loop;
		}
		if (!snlflg) {
/***/			if (!cflg)
/***/				printf("',");
/***/			cflg = 0;
/***/			printf("X'0A'\n\tDB  ");
/***/			cflg++;
/***/		}
		snlflg = 0;
		nlflg = 1;
		goto loop;

/***/	case 'P':
/***/		putchar('Q');
/***/		if ((c=getcx()) == '-')
/***/			snlflg++;
/***/		peekc = c;
/***/		goto loop;
/***/
	case 'X':
	case 'Y':
	case 'T':
		snlflg++;
	}
	if (!smode && 'a'<=c && c<= 'z')
		c =+ 'A'-'a';
	putchar(c);
	goto loop;
}

getcx() {
	auto t, ifcnt;

	ifcnt = 0;
gc:
	if (peekc) {
		t = peekc;
		peekc = 0;
	} else
		t = getchar();
	if (t==0)
		return(0);
	if (t=='{') {
		ifcnt++;
		t = getchar();
	}
	if (t=='}') {
		t = getcx();
		if (--ifcnt==0)
			if (t=='\n')
				t = getcx();
	}
	if (ifcnt && nofloat)
		goto gc;
	return(t);
}

flag() {
	register c, f;

	f = 0;
l1:
	switch(c=getcx()) {

	case 'w':
		f = 1;
		goto l1;

	case 'i':
		f = 2;
		goto l1;

	case 'b':
		f = 3;
		goto l1;

	case 'f':
		f = 4;
		goto l1;

	case 'd':
		f = 5;
		goto l1;

	case 's':
		f = 6;
		goto l1;

	case 'l':
		f = 8;
		goto l1;

	case 'p':
		f =+ 16;
		goto l1;
	}
	peekc = c;
	return(f);
}

putchar(c)
{
	if (tabflg) {
		tabflg = 0;
/***/		if (!cflg)
/***/			printf("',");
/***/		cflg = 0;
/***/		printf("X'%x',", c+0200);
/***/		cflg++;
/***/	} else {
/***/		if (cflg) {
/***/			cflg = 0;
/***/			printf("C'");
/***/		}
		putc(c, obuf);
/***/	}
}
