char  *_ptrbf, *_ptrst, *__fmt;
printf(a1,a2,a3,a4){
auto char  c, *s,  adj, *ptr,*p, buf[30];
int lnflg;
extern cputc(),_putstr(), cout;
auto int  *adx, x, n, m, width, prec,i, padchar, fd;
double *dblptr;
int *lngptr, longdata;
char (*f)();
_ptrbf = buf;

fd=cout;
adx = &a1;
f = cputc;
if (a1 == -1)
  {
  f = _putstr;
  _ptrst = a2;
  adx =+ 2;
  }
else if (a1 >= 0 && a1 <= 9)
  fd = *adx++;
__fmt = *adx++;


while( c = *__fmt++ ){
   if(c != '%') (*f)(c,fd);
   else { x = *adx++;
      if( *__fmt == '-' ){ adj = 'l';  __fmt++; }
      else adj = 'r';
   padchar = (*__fmt=='0') ? '0' : ' ';
      width = __conv();
      if( *__fmt == '.'){++__fmt; prec = __conv();}
      else prec = -1;

   s = lnflg = 0;
	swc:
   switch ( c = *__fmt++ ) {
	case 'u': case 'U':
	_prtone(x, c, 10); break;
	case 'd': case 'D':
		lnflg ? _prtl(longdata) : _prtone(x,c,10);
		break;
	case 'l': case 'L':
			lnflg = 1;
			lngptr = adx++ -1;
			longdata = *lngptr;
			goto swc;
     case 'o':
     case 'O':
	lnflg ? _prls(longdata, c, 7, 3) : _prtone(x,c,8); break;
     case 'x':
     case 'X':
	lnflg ? _prls (longdata, c,15,4) : _prtone(x,c,16); break;
      case 'S':
     case 's':    s=x;
        break;
     case 'C':
     case 'c':   *_ptrbf++ = x&0777;
         break;
     case 'E':
     case 'e':
     case 'F':
     case 'f':
      dblptr = adx-1;
      adx =+ 3;
      ftoa (*dblptr, s=buf, prec, c);
      prec = -1;
     break;
     default:   (*f)(c,fd);
         adx--;
   }
   if (s == 0)
    {*_ptrbf = '\0'; s = buf;}
   n = _clenf (s);
   n = (prec<n && prec >= 0) ? prec : n;
   m = width-n;
	if (adj == 'r')
		{
		if (padchar=='0' && s[0] == '-')
			{
			n--;
			(*f)(*s++,fd);
			}
		while (m-- > 0)
			(*f)(padchar,fd);
		}
   while (n--) (*f)(*s++,fd);
   while (m-- > 0) (*f)(padchar,fd);
   _ptrbf = buf;
   }
}
if(a1 == -1) (*f)('\0',fd);
}


__conv()
{
auto c,n;
n = 0;
while( ((c = *__fmt++) >= '0') && (c<='9')) n = n*10+c-'0';
__fmt--;
return(n);
}

_putstr(chr,str){
*_ptrst++ = chr;
return;
}
_prtone(n, format, base)
{
int digs[15], *dpt, k;
extern int ldivr;
dpt = digs;
if (n<0 && format == 'd') {n = -n; *_ptrbf++ = '-';}
while (n!=0)
 {
 n = ldiv(0,n,base);
 *dpt++ = ldivr;
  }
if (dpt == digs)
   *dpt++ = 0;
while (dpt != digs)
	{
	k = *--dpt;
	*_ptrbf++ = k + ((k<=9) ? '0' : ( (format== 'x') ? 'a'-10 : 'A'-10));
	}
}
_prtl(n)
	int n;
{
int digs[15], *dpt;
dpt = digs;
if (n>=0) n= -n;
else *_ptrbf++ = '-';
for(; n!= 0; n=n/10)
	*dpt++ = n%10;
if (dpt==digs)
	*dpt++ = 0;
while (dpt != digs)
	*_ptrbf++ = '0' - *--dpt;
}
_prls (n, format, mask, shift)
	int n;
{
	int digs[15], *dpt, k;
	int bigmask;
	bigmask = 1;
	bigmask = bigmask << (32-shift);
	bigmask = bigmask -1;
	for(dpt=digs; n != 0; n= (n>>shift)&bigmask)
		*dpt++ = n&mask;
	if (dpt==digs)
		*dpt++ = 0;
	while (dpt != digs)
		{
		k = *--dpt;
		*_ptrbf++ = k + ( (k<=9) ? '0' : ( (format=='x') ? 'a'-10 : 'A'-10));
		}
	}
