[gnu.g++.bug] A fatal error in g++ V1.35.0

denis%vlsi.poly@crim.ca ("Denis R. Martin") (07/05/89)

Hi there!

Here is a bug in g++ V1.35.0

When issuing the command:

g++ -c Adder.cc

The error message is:

Failed assertion 0 at line 6565 of `cplus-decl.c'.
g++: Program cc1plus got fatal signal 6.

g++ was compiled with gcc V1.35.0 with the following links
   tm.h -> tm-sun3+.h
   md   -> m68k.md
   config.h -> xm-sunos4+.h

Any kind of help would be appriciated.

Denis Martin,
Ecole Polytechnique, Montreal.
denis@vlsi.poly.ca

Adder.cc folows. It is self contained.

--------------------------------------------------------------------------------
# 1 "Adder.cc"
 
# 1 "Simulateur.h"
 
# 1 "/usr/local/lib/g++-include/stream.h"
 
#pragma once

# 1 "/usr/local/lib/g++-include/File.h"
 
#pragma once

# 1 "/usr/local/lib/g++-include/builtin.h"
 
#pragma once

overload clearbit;
overload dec;
overload gcd;
overload hex;
overload lcm;
overload lg;
overload oct;
overload setbit;
overload sign;
overload sqr;
overload testbit;
overload even;
overload odd;

# 1 "/usr/local/lib/g++-include/std.h"
 
#pragma once

#pragma once

overload abs;
overload atoi;

extern "C" {
void      _exit(int);
void      abort(void);
int       abs(int);
int       access(const char*, int);
int       acct(const char*);
unsigned  alarm(unsigned);
void*     alloca(int);
double    atof(const char*);
int       atoi(const char*);
long      atol(const char*);
int       bcmp(const void*, const void*, int);
void      bcopy(const void*, void*, int);
void*     brk(void*);
void      bzero(void*, int);
void*     calloc(unsigned, unsigned);
void      cfree(void*);
int       chdir(const char*);
int       chmod(const char*, int);
int       chown(const char*, int, int);
long      clock(void);
int       close(int);
int       creat(const char*, int);
char*     crypt(const char*, const char*);
char*     ctermid(char*);
char*     cuserid(char*);
double    drand48(void);
int       dup(int);
int       dup2(int, int);
int       dysize(int);
char*     ecvt(double, int, int*, int*);
char*     encrypt(char*, int);
double    erand(short*);
int       execl(const char*, const char *, ...);
int       execle(const char*, const char *, ...);
int       execlp(const char*, const char*, ...);
int       exect(const char*,  const char**,  char**);
int       execv(const char*,  const char**);
int       execve(const char*, const char**, char**);
int       execvp(const char*,  const char**);
void      exit(int);
int       fchmod(int, int);
int       fchown(int, int, int);
int       fcntl(int, int, int);
char*     fcvt(double, int, int*, int*);
int       ffs(int);
int       flock(int, int);
int       fork(void);
void      free(void*);
int       fsync(int);
long      ftok(const char*, int);
int       ftruncate(int, unsigned long);
char*     gcvt(double, int, char*);
char*     getcwd(char*, int);
int       getdomainname(char*, int);
int       getdtablesize(void);
int       getegid(void);
char*     getenv(const char*);
int       geteuid(void);
int       getgid(void);
int       getgroups(int, int*);
long      gethostid(void);
int       gethostname(char*, int);
char*     getlogin(void);
int       getopt(int, char**, char*);
int       getpagesize(void);
char*     getpass(const char*);
int       getpgrp(void);
int       getpid(void);
int       getppid(void);
int       getpriority(int, int);
int       getpw(int, char*);
unsigned  getuid(void);
char*     getwd(char*);
char*     index(const char*, int);
char*     initstate(unsigned, char*, int);
int       ioctl(int, int, char*);
int       isatty(int);
long      jrand48(short*);
int       kill(int, int);
int       killpg(int, int);
void      lcong48(short*);
int       link(const char*, const char*);
int       lock(int, int, long);
long      lrand48(void);
long      lseek(int, long, int);
void*     malloc(unsigned);
void*     memalign(unsigned, unsigned);
void*     memccpy(void*, const void*, int, int);
void*     memchr(const void*, int, int);
int       memcmp(const void*, const void*, int);
void*     memcpy(void*, const void*, int);
void*     memset(void*, int, int);
int       mkdir(const char*, int);
int       mknod(const char*, int, int);
int       mkstemp(char*);
char*     mktemp(char*);
long      mrand48(void);
int       nice(int);
long      nrand48(short*);
int       open(const char*, int, ...);
void      pause(void);
void      perror(const char*);
int       pipe(int*);
void      profil(char*, int, int, int);
int       psignal(unsigned, char*);
int       ptrace(int, int, int, int);
int       putenv(const char*);
int       qsort(void*, int, unsigned, auto (*ptf)(void*,void*));
int       rand(void);
long      random(void);
int       read(int, void*, unsigned);
int       readlink(const char*, char*, int);
void*     realloc(void*, unsigned);
int       rename(const char*, const char*);
char*     rindex(const char*, int);
int       rmdir(const char*);               
void*     sbrk(int);              
short*    seed48(short*);
int       send(int, char*, int, int);
int       setgid(int);
int       sethostname(char*, int);
int       setkey(const char*);
int       setpgrp(int, int);
int       setpriority(int, int, int);
int       setregid(int, int);
int       setreuid(int, int);
char*     setstate(char*);
int       setuid(int);
int       sigblock(int);
int       siginterrupt(int, int);
int       sigpause(int);
int       sigsetmask(int);
unsigned  sleep(unsigned);
int       srand(int);
void      srand48(long);
void      srandom(int);
int       stime(long*);
char*     strcat(char*, const char*);
char*     strchr(const char*, int);
int       strcmp(const char*, const char*);
char*     strcpy(char*, const char*);
int       strcspn(const char*, const char*);
char*     strdup(const char*);
int       strlen(const char*);
char*     strncat(char*, const char*, int);
int       strncmp(const char*, const char*, int);
char*     strncpy(char*, const char*, int);
char*     strpbrk(const char*, const char*);
char*     strrchr(const char*, int);
int       strspn(const char*, const char*);
double    strtod(const char*, char**);
char*     strtok(char*, const char*);
long      strtol(const char*, char**, int);
void      swab(void*, void*, int);
int       symlink(const char*, const char*);
int       syscall(int, ...);
int       system(const char*);
char*     tempnam(char*, char*);
int       tgetent(char*, char*);
int       tgetnum(char*);
int       tgetflag(char*);
char*     tgetstr(char *, char **);
char*     tgoto(char*, int, int);
long      time(long*);
 
char*     tmpnam(char*);
int       truncate(const char*, unsigned long);
char*     ttyname(int);
int       ttyslot(void);
unsigned  ualarm(unsigned, unsigned);
long      ulimit(int, long);
int       umask(int);
int       unlink(const char*);
unsigned  usleep(unsigned);
int       vadvise(int);
void*     valloc(unsigned);
int       vfork(void);
int       vhangup(void);
int       wait(int*);
int       write(int, const void*, unsigned);
}

extern char**   environ;
extern int      errno;
extern char*    sys_errlist[];
extern int      sys_nerr;                  
extern char*    optarg;
extern int      opterr;
extern int      optind;

# 48 "/usr/local/lib/g++-include/builtin.h"
# 1 "/usr/local/lib/g++-include/stddef.h"
 
#pragma once

enum bool   
{           
  FALSE = 0,
  TRUE  = 1              
};

typedef void (*one_arg_error_handler_t)(const char*);
typedef void (*two_arg_error_handler_t)(const char*, const char*);

# 49 "/usr/local/lib/g++-include/builtin.h"

# 1 "/usr/local/lib/g++-include/math.h"
 
#pragma once

overload acos;
overload acosh;
overload asin;
overload asinh;
overload atan2;
overload atanh;
overload ceil;
overload cos;
overload cosh;
overload exp;
overload floor;
overload gamma;
overload hypot;
overload log;
overload log10;
overload pow;
overload sin;
overload sinh;
overload sqrt;
overload tan;
overload tanh;

extern "C" {

double  acos(double);
double  acosh(double);
double  asin(double);
double  asinh(double);
double  atan(double);
double  atan2(double, double);
double  atanh(double);
double  cbrt(double);
double  ceil(double);
double  copysign(double,double);
double  cos(double);
double  cosh(double);
double  drem(double,double);
double  erf(double);
double  erfc(double);
double  exp(double);
double  expm1(double);
double  fabs(double);
double  finite(double);
double  floor(double);
double  frexp(double, int*);
double  gamma(double);
double  hypot(double,double);
double  infnan(int);
int     isinf(double);
int     isnan(double);
double  j0(double);
double  j1(double);
double  jn(int, double);
double  ldexp(double, int);
double  lgamma(double);
double  log(double);
double  log10(double);
double  log1p(double);
double  logb(double);
double  modf(double, double*);
double  pow(double, double);
double  rint(double);
double  scalb(double, int);
double  sin(double);
double  sinh(double);
double  sqrt(double);
double  tan(double);
double  tanh(double);
double  y0(double);
double  y1(double);
double  yn(int, double);

}

struct exception
{
  int type;
  char* name;
  double arg1, arg2, retval;
};

extern "C" int matherr(exception*);

# 1 "/usr/local/lib/g++-include/values.h"
 
#pragma once

# 108 "/usr/local/lib/g++-include/values.h"

# 126 "/usr/local/lib/g++-include/math.h"

# 1 "/usr/local/lib/g++-include/math-68881.h"
 
# 1 "/usr/include/errno.h"
 
# 1 "/usr/include/sys/errno.h"
 
# 7 "/usr/include/errno.h"

extern int errno;
# 30 "/usr/local/lib/g++-include/math-68881.h"

# 42 "/usr/local/lib/g++-include/math-68881.h"

inline		 static const double sin (double x)
{
  double value;

  asm		 ("fsin%.x %1,%0"
	 : "=f" (value)
	 : "f" (x));
  return value;
}

inline		 static const double cos (double x)
{
  double value;

  asm		 ("fcos%.x %1,%0"
	 : "=f" (value)
	 : "f" (x));
  return value;
}

inline		 static const double tan (double x)
{
  double value;

  asm		 ("ftan%.x %1,%0"
	 : "=f" (value)
	 : "f" (x));
  return value;
}

inline		 static const double asin (double x)
{
  double value;

  asm		 ("fasin%.x %1,%0"
	 : "=f" (value)
	 : "f" (x));
  return value;
}

inline		 static const double acos (double x)
{
  double value;

  asm		 ("facos%.x %1,%0"
	 : "=f" (value)
	 : "f" (x));
  return value;
}

inline		 static const double atan (double x)
{
  double value;

  asm		 ("fatan%.x %1,%0"
	 : "=f" (value)
	 : "f" (x));
  return value;
}

inline		 static const double atan2 (double y, double x)
{
  double pi, pi_over_2;

  asm		 ("fmovecr%.x %#0,%0"		 
	 : "=f" (pi)
	 :   );
  asm		 ("fscale%.b %#-1,%0"		 
	 : "=f" (pi_over_2)
	 : "0" (pi));
  if (x > 0)
    {
      if (y > 0)
	{
	  if (x > y)
	    return atan (y / x);
	  else
	    return pi_over_2 - atan (x / y);
	}
      else
	{
	  if (x > -y)
	    return atan (y / x);
	  else
	    return - pi_over_2 - atan (x / y);
	}
    }
  else
    {
      if (y > 0)
	{
	  if (-x > y)
	    return pi + atan (y / x);
	  else
	    return pi_over_2 - atan (x / y);
	}
      else
	{
	  if (-x > -y)
	    return - pi + atan (y / x);
	  else if (y < 0)
	    return - pi_over_2 - atan (x / y);
	  else
	    {
	      double value;

	      errno = 	33		;
	      asm		 ("fmove%.d %#0rnan,%0" 	 
		     : "=f" (value)
		     :  );
	      return value;
	    }
	}
    }
}

inline		 static const double sinh (double x)
{
  double value;

  asm		 ("fsinh%.x %1,%0"
	 : "=f" (value)
	 : "f" (x));
  return value;
}

inline		 static const double cosh (double x)
{
  double value;

  asm		 ("fcosh%.x %1,%0"
	 : "=f" (value)
	 : "f" (x));
  return value;
}

inline		 static const double tanh (double x)
{
  double value;

  asm		 ("ftanh%.x %1,%0"
	 : "=f" (value)
	 : "f" (x));
  return value;
}

inline		 static const double exp (double x)
{
  double value;

  asm		 ("fetox%.x %1,%0"
	 : "=f" (value)
	 : "f" (x));
  return value;
}

inline		 static const double log (double x)
{
  double value;

  asm		 ("flogn%.x %1,%0"
	 : "=f" (value)
	 : "f" (x));
  return value;
}

inline		 static const double log10 (double x)
{
  double value;

  asm		 ("flog10%.x %1,%0"
	 : "=f" (value)
	 : "f" (x));
  return value;
}

inline		 static const double sqrt (double x)
{
  double value;

  asm		 ("fsqrt%.x %1,%0"
	 : "=f" (value)
	 : "f" (x));
  return value;
}

inline		 static const double pow (const double x, const double y)
{
  if (x > 0)
    return exp (y * log (x));
  else if (x == 0)
    {
      if (y > 0)
	return 0.0;
      else
	{
	  double value;

	  errno = 	33		;
	  asm		 ("fmove%.d %#0rnan,%0"		 
		 : "=f" (value)
		 :  );
	  return value;
	}
    }
  else
    {
      double temp;

      asm		 ("fintrz%.x %1,%0"
	     : "=f" (temp)			 
	     : "f" (y));
      if (y == temp)
        {
	  int i = (int) y;
	  
	  if (i & 1 == 0)			 
	    return exp (y * log (x));
	  else
	    return - exp (y * log (x));
        }
      else
        {
	  double value;

	  errno = 	33		;
	  asm		 ("fmove%.d %#0rnan,%0"		 
		 : "=f" (value)
		 :  );
	  return value;
        }
    }
}

inline		 static const double fabs (double x)
{
  double value;

  asm		 ("fabs%.x %1,%0"
	 : "=f" (value)
	 : "f" (x));
  return value;
}

inline		 static const double ceil (double x)
{
  int rounding_mode, round_up;
  double value;

  asm		 volatile ("fmove%.l fpcr,%0"
		  : "=dm" (rounding_mode)
		  :   );
  round_up = rounding_mode | 0x30;
  asm		 volatile ("fmove%.l %0,fpcr"
		  :  
		  : "dmi" (round_up));
  asm		 volatile ("fint%.x %1,%0"
		  : "=f" (value)
		  : "f" (x));
  asm		 volatile ("fmove%.l %0,fpcr"
		  :  
		  : "dmi" (rounding_mode));
  return value;
}

inline		 static const double floor (double x)
{
  int rounding_mode, round_down;
  double value;

  asm		 volatile ("fmove%.l fpcr,%0"
		  : "=dm" (rounding_mode)
		  :   );
  round_down = (rounding_mode & ~0x10)
		| 0x20;
  asm		 volatile ("fmove%.l %0,fpcr"
		  :  
		  : "dmi" (round_down));
  asm		 volatile ("fint%.x %1,%0"
		  : "=f" (value)
		  : "f" (x));
  asm		 volatile ("fmove%.l %0,fpcr"
		  :  
		  : "dmi" (rounding_mode));
  return value;
}

inline		 static const double fmod (double x, double y)
{
  double value;

  asm		 ("fmod%.x %2,%0"
	 : "=f" (value)
	 : "0" (x),
	   "f" (y));
  return value;
}

inline		 static const double ldexp (double x, int n)
{
  double value;

  asm		 ("fscale%.l %2,%0"
	 : "=f" (value)
	 : "0" (x),
	   "dmi" (n));
  return value;
}

inline		 static double frexp (double x, int *exp)
{
  double float_exponent;
  int int_exponent;
  double mantissa;

  asm		 ("fgetexp%.x %1,%0"
	 : "=f" (float_exponent) 	 
	 : "f" (x));
  int_exponent = (int) float_exponent;
  asm		 ("fgetman%.x %1,%0"
	 : "=f" (mantissa)		 
	 : "f" (x));
  if (mantissa != 0)
    {
      asm		 ("fscale%.b %#-1,%0"
	     : "=f" (mantissa)		 
	     : "0" (mantissa));
      int_exponent += 1;
    }
  *exp = int_exponent;
  return mantissa;
}

inline		 static double modf (double x, double *ip)
{
  double temp;

  asm		 ("fintrz%.x %1,%0"
	 : "=f" (temp)			 
	 : "f" (x));
  *ip = temp;
  return x - temp;
}
# 184 "/usr/local/lib/g++-include/math.h"

# 50 "/usr/local/lib/g++-include/builtin.h"

long         abs(long);
double       abs(double);
void         clearbit(long&, long);
void         setbit(long&, long);
int          testbit(long, long);
int          even(long);
long         gcd(long, long);
long         lg(long); 
long         lcm(long, long);
int          odd(long);
double       pow(double, long);
long         pow(long, long);
int          sign(long);
int          sign(double);
long         sqr(long);
double       sqr(double);
long         sqrt(long);

double       start_timer();
double       return_elapsed_time(double);

char*        itoa(long x, int base = 10, int width = 0);
char*        hex(long x, int width = 0);
char*        oct(long x, int width = 0);
char*        dec(long x, int width = 0);
char*        form(const char* fmt ...);
char*        chr(char ch);

unsigned int hashpjw(const char*);
unsigned int multiplicativehash(int);
unsigned int foldhash(double);

extern void default_one_arg_error_handler(const char*);
extern void default_two_arg_error_handler(const char*, const char*);

extern two_arg_error_handler_t lib_error_handler;

extern two_arg_error_handler_t 
       set_lib_error_handler(two_arg_error_handler_t f);

 

inline double abs(double _arg) 
{
  return (_arg < 0.0)? -_arg : _arg;
}

inline long abs(long _arg) 
{
  return (_arg < 0)? -_arg : _arg;
}

inline int sign(long _arg)
{
  return (_arg == 0) ? 0 : ( (_arg > 0) ? 1 : -1 );
}

inline int sign(double _arg)
{
  return (_arg == 0.0) ? 0 : ( (_arg > 0.0) ? 1 : -1 );
}

inline long sqr(long _arg)
{
  return _arg * _arg;
}

inline double sqr(double _arg)
{
  return _arg * _arg;
}

inline int even(long _arg)
{
  return !(_arg & 1);
}

inline int odd(long _arg)
{
  return (_arg & 1);
}

inline long lcm(long _x, long _y)
{
  return _x / gcd(_x, _y) * _y;
}

inline void setbit(long& _x, long _b)
{
  _x |= (1 << _b);
}

inline void clearbit(long& _x, long _b)
{
  _x &= ~(1 << _b);
}

inline int testbit(long _x, long _b)
{
  return ((_x & (1 << _b)) != 0);
}

# 28 "/usr/local/lib/g++-include/File.h"

# 1 "/usr/local/lib/g++-include/stdio.h"
 
#pragma once

extern  struct  _iobuf {
    int      _cnt;
    char*    _ptr;
    char*    _base;

    int     _bufsiz;
    short   _flag;



    char    _file;
} _iob[];

extern "C" {

int    _doprnt(const char*, void*,     struct _iobuf *);
int    _doscan(    struct _iobuf *, const char*, void*);
int    _filbuf(    struct _iobuf *);
int    _flsbuf(unsigned,     struct _iobuf *);
int    fclose(    struct _iobuf *);
    struct _iobuf *  fdopen(int, const char*);
int    fflush(    struct _iobuf *);
int    fgetc(    struct _iobuf *);
char*  fgets(char*, int,     struct _iobuf  *);
    struct _iobuf *  fopen(const char*, const char*);
int    fprintf(    struct _iobuf *, const char* ...);
int    fputc(int,     struct _iobuf *);
int    fputs(const char*,     struct _iobuf *);
int    fread(void*, int, int,     struct _iobuf *);
    struct _iobuf *  freopen(const char*, const char*,     struct _iobuf *);
int    fscanf(    struct _iobuf *, const char* ...);
int    fseek(    struct _iobuf *, long, int);
long   ftell(    struct _iobuf  *);
int    fwrite(const void*, int, int,     struct _iobuf *);
char*  gets(char*);
int    getw(    struct _iobuf *);
int    pclose(    struct _iobuf *);
    struct _iobuf *  popen(const char*, const char*);
int    printf(const char* ...);
void   puts(const char*);
int    putw(int,     struct _iobuf *);
int    scanf(const char* ...);
void   setbuf(    struct _iobuf *, char*);
void   setbuffer(    struct _iobuf *, char*, int);
void   setlinebuf(    struct _iobuf *);
void   setvbuf(    struct _iobuf *, char*, int, int);
int    sscanf(char*, const char* ...);
    struct _iobuf *  tmpfile();
int    ungetc(int,     struct _iobuf *);
int    vfprintf(    struct _iobuf *, const char*, void* ap);
int    vprintf(const char*, void* ap);
int    vsprintf(char*, const char*, void* ap);


int    sprintf(char*, const char* ...);

}

# 29 "/usr/local/lib/g++-include/File.h"

enum io_mode                     
{
  io_readonly   = 0,            
  io_writeonly  = 1,
  io_readwrite  = 2, 
  io_appendonly = 3,
  io_append     = 4,             
};

enum access_mode                 
{
  a_createonly  = 0,             
  a_create      = 1,             
  a_useonly     = 2,             
  a_use         = 3,             
};

enum state_value                 
{ 
  _good         = 0,             
  _eof          = 1,             
  _fail         = 2,             
  _bad          = 4              
};


class File
{
protected:
      struct _iobuf *         fp;               
  char*         nm;               
  char          rw;               
                                  
  state_value   state;            
  long          stat;             

  void          initialize();
  void          reinitialize(const char*);
  char         *readline (int chunk_number, char terminator);

public:
                File();
                File(const char* filename, io_mode m, access_mode a);
                File(const char* filename, const char* m);   
                File(int filedesc, io_mode m);
                File(    struct _iobuf * fileptr);
                File(int sz, char* buf, io_mode m);

                ~File();

 

  File&         open(const char* filename, io_mode m, access_mode a);
  File&         open(const char* filename, const char* m);
  File&         open(int  filedesc, io_mode m);
  File&         open(    struct _iobuf * fileptr);

  File&         close();
  File&         remove();

 

  int           filedesc();
  const char*   name();
  void          setname(const char* newname);
  int           iocount();

  int           rdstate();
  int           eof();
  int           fail();
  int           bad();
  int           good();

 

  int           readable();
  int           writable();
  int           is_open();

  void*         operator void*();

 

  void          error();
  void          clear(state_value f = 0);  
  File&         failif(int cond);
  void          check_state();

 

  File&         get(char& c);
  File&         put(char  c);
  File&         unget(char c);
  File&         putback(char c);  

 

  File&         put(const char* s);
  File&         get    (char* s, int n, char terminator = '\n');
  File&         getline(char* s, int n, char terminator = '\n');
  File&         gets   (char **s, char terminator = '\n');

 

  File&         read(void* x, int sz, int n);
  File&         write(void* x, int sz, int n);


 

  File&         seek(long pos, int seek_mode=0);  
  long          tell();

  File&         flush();
  File&         setbuf(int buffer_kind);  
  File&         setbuf(int size, char* buf);
  File&         raw();
};


 

extern void  verbose_File_error_handler(char*);
extern void  quiet_File_error_handler(char*);
extern void  fatal_File_error_handler(char*);
extern one_arg_error_handler_t File_error_handler;
extern one_arg_error_handler_t set_File_error_handler(one_arg_error_handler_t);

inline int File::filedesc()
{ 
  return   ((fp)->_file) ;
}

inline const char* File::name()
{ 
  return nm; 
}

inline int File::iocount()
{ 
  return stat; 
}

inline int File::readable()
{ 
  if (fp != 0) { if (    (((fp)->_flag&   00020 )!=0) ) state |= _eof; if (  (((fp)->_flag&   00040 )!=0) ) state |= _bad;}
  return (state == _good && (rw & 01));
}

inline int File::writable()
{ 
  if (fp != 0 &&   (((fp)->_flag&   00040 )!=0) ) state |= _bad;
  return ((state & (_fail|_bad)) == 0 && (rw & 02));
}

inline int File::is_open()
{ 
  return (fp != 0);
}

inline void File::clear(state_value flag = 0)
{ 
  state = flag;
}

inline File& File::raw()
{ 
  return this->File::setbuf(   00004 ); 
}

inline void File::check_state()  
{
  if (fp != 0)
  {
    if (    (((fp)->_flag&   00020 )!=0) )
      state |= _eof;
    else
      state &= ~_eof;
    if (  (((fp)->_flag&   00040 )!=0) )
      state |= _bad;
  }
}

inline File& File::failif(int cond)
{ 
  if (cond) state |= _fail;  return *this; 
}

inline File& File::get(char& c)
{ 
  if (readable())
  {
    int ch = (--(fp)->_cnt>=0?(int)(*(unsigned char*)(fp)->_ptr++):_filbuf(fp)) ;
    c = ch;
    failif (ch ==       (-1) );
  }
  return *this;
}

inline File& File::put(char  c) 
{ 
  return failif (!writable() ||  (--( fp)->_cnt>=0? ((int)((unsigned char)((*( fp)->_ptr++=(unsigned)(c))))):_flsbuf((unsigned)(c), fp))  ==       (-1) );
}

inline File& File::unget(char c)
{ 
  return failif(!is_open() || !(rw & 01) || ungetc(c, fp) ==       (-1) );
} 

inline File& File::putback(char c)
{ 
  return failif (!is_open() || !(rw & 01) || ungetc(c, fp) ==       (-1) );
}

inline File& File::read(void* x, int sz, int n)
{ 
  return failif (!readable() || (stat = fread(x, sz, n, fp)) != n);
} 

inline File& File::write(void* x, int sz, int n) 
{ 
  return failif (!writable() || (stat = fwrite(x, sz, n, fp)) != n);
}

inline File& File::flush()
{ 
  return failif(!is_open() || fflush(fp) ==       (-1) );
}

inline File& File::seek(long pos, int seek_mode = 0)
{ 
  return failif (!is_open() || fseek(fp, pos, seek_mode) < 0); 
}

inline long File::tell()
{ 
  failif (!is_open() || (stat = ftell(fp) < 0));
  return stat;
}

inline int File::rdstate()
{ 
  check_state();  return state;  
}                                

inline void* File::operator void*()
{ 
  check_state();  return (state & (_bad|_fail))? 0 : this ; 
}

inline int File::eof()
{ 
  check_state(); return state & _eof; 
}

inline int File::fail()
{ 
  check_state(); return state & _fail; 
}

inline int File::bad()
{ 
  check_state(); return state & _bad; 
}

inline int File::good()
{ 
  check_state(); return rdstate() == _good; 
}

# 28 "/usr/local/lib/g++-include/stream.h"

class whitespace                 
{                                
  char filler;                     
};

class ostream: private File
{
public:
           File::open;      File::close;
           File::remove;    File::filedesc;  File::is_open;
           File::raw;       File::put;       File::check_state;
           File::iocount;   File::error;     File::name;
           File::setname;   File::rdstate;   File::flush;
           File::eof;       File::fail;      File::bad;
           File::good;      File::clear;     File::failif;
           File::setbuf;    File::writable;  File::readable;
           

           ostream();
           ostream(const char* filename, io_mode m, access_mode a);
           ostream(const char* filename, const char* m);
           ostream(int filedesc, io_mode m = io_writeonly);
           ostream(    struct _iobuf * fileptr);
           ostream(int sz, char* buf);

           ~ostream();

  void*    operator void*();

  ostream& form(const char* fmt, ...);           

  ostream& operator << (char   c);
  ostream& operator << (short  n);
  ostream& operator << (unsigned short n);
  ostream& operator << (int    n);
  ostream& operator << (unsigned int n);
  ostream& operator << (long   n);
  ostream& operator << (unsigned long n);
  ostream& operator << (float  n);
  ostream& operator << (double n);
  ostream& operator << (const char* s);
};


class istream: private File
{
protected:
  ostream* tied_to;         
  void     _flush();

public:
           File::open;      File::close;     File::get;  File::gets;
           File::remove;    File::filedesc;  File::is_open;
           File::raw;       File::unget;     File::getline;
           File::iocount;   File::error;     File::name;
           File::setname;   File::rdstate;   File::putback;
           File::eof;       File::fail;      File::bad;
           File::good;      File::clear;     File::failif;
           File::setbuf;    File::writable;  File::readable;
           File::check_state;

           istream();
           istream(const char* filename, io_mode m, access_mode a);
           istream(const char* filename, const char* m);
           istream(int filedesc, io_mode m = io_readonly);
           istream(    struct _iobuf * fileptr);
           istream(int sz, char* buf);

           ~istream();

  void*    operator void*();

  ostream* tie(ostream* s);

  istream& scan(const char* fmt, ...);

  istream& operator >> (char&   c);
  istream& operator >> (short&  n);
  istream& operator >> (unsigned short& n);
  istream& operator >> (int&    n);
  istream& operator >> (unsigned int& n);
  istream& operator >> (long&   n);
  istream& operator >> (unsigned long& n);
  istream& operator >> (float&  n);
  istream& operator >> (double& n);
  istream& operator >> (char*   s);
  istream& operator >> (whitespace& w);
};

void eatwhite(istream& s);

extern istream  cin;              
extern ostream  cout;             
extern ostream  cerr;             
extern whitespace WS;             

inline void* ostream::operator void*()
{ 
  check_state(); return (state & (_bad|_fail))? 0 : this ; 
}

inline ostream& ostream::operator<<(char   c)
{ 
  put(c);  return *this;
}

inline void*    istream::operator void*()
{ 
  check_state(); return (state & (_bad|_fail))? 0 : this ; 
}

inline void istream::_flush()
{
  if (tied_to) tied_to->flush();
}

# 17 "Simulateur.h"

# 1 "/usr/local/lib/g++-include/String.h"
 
#pragma once

struct StrRep                      
{
  unsigned short    len;          
  unsigned short    sz;           
  char              s[1];         
                                  
  friend StrRep*     Salloc(StrRep*, const char*, int, int);
  friend StrRep*     Scopy(StrRep*, StrRep*);
  friend StrRep*     Sresize(StrRep*, int);
  friend StrRep*     Scat(StrRep*, const char*, int, const char*, int);
  friend StrRep*     Sprepend(StrRep*, const char*, int);
  friend StrRep*     Sreverse(StrRep*, StrRep*);
  friend StrRep*     Supcase(StrRep*, StrRep*);
  friend StrRep*     Sdowncase(StrRep*, StrRep*);
  friend StrRep*     Scapitalize(StrRep*, StrRep*);

};


class String;
class SubString;
class StrTmp;


struct re_pattern_buffer;        
struct re_registers;

class Regex
{
  friend class       String;
  friend class       SubString;
protected:
  re_pattern_buffer* buf;
  re_registers*      reg;

  void               initialize(const char* t, int tlen, int fast, 
                                int bufsize, const char* transtable);

public:
                     Regex(const char* t, 
                           int fast = 0, 
                           int bufsize = 40, 
                           const char* transtable = 0);

                     Regex(String& x, 
                           int fast = 0, 
                           int bufsize = 40, 
                           const char* transtable = 0);

                     ~Regex();

  int                match(const char* s, int len, int pos = 0);
  int                search(const char* s, int len, 
                            int& matchlen, int startpos = 0);
  int                match_info(int& start, int& length, int nth = 0);

  int                OK();   
};

class SubString
{
  friend class      String;
  friend class      StrTmp;
protected:
  String*           S;
  unsigned short    pos;
  unsigned short    len;

  void              assign(StrRep*, const char*, int = -1);
                    SubString(String* x, int p, int l);
                    SubString(const SubString& x);

public:
                    ~SubString();

  void              operator =  (String&     y);
  void              operator =  (SubString&  y);
  void              operator =  (const char* t);
  void              operator =  (char        c);
  
  StrTmp            operator +  (String&     y);
  StrTmp            operator +  (SubString&  y);
  StrTmp            operator +  (const char* t);
  StrTmp            operator +  (char        c);
  StrTmp            operator +  (StrTmp& y);
  friend StrTmp     operator +  (const char* t,SubString&  y);
  friend StrTmp     operator +  (char       c, SubString&  x);

  friend int        operator == (SubString& x, String&     y);
  friend int        operator == (String&    x, SubString&  y);
  friend int        operator == (SubString& x, SubString&  y);
  friend int        operator == (SubString& x, const char* t);
  
  friend int        operator != (SubString& x, String&     y);
  friend int        operator != (String&    x, SubString&  y);
  friend int        operator != (SubString& x, SubString&  y);
  friend int        operator != (SubString& x, const char* t);
  
  friend int        operator <= (SubString& x, String&     y);
  friend int        operator <= (String&    x, SubString&  y);
  friend int        operator <= (SubString& x, SubString&  y);
  friend int        operator <= (SubString& x, const char* t);
  
  friend int        operator <  (SubString& x, String&     y);
  friend int        operator <  (String&    x, SubString&  y);
  friend int        operator <  (SubString& x, SubString&  y);
  friend int        operator <  (SubString& x, const char* t);
  
  friend int        operator >= (SubString& x, String&     y);
  friend int        operator >= (String&    x, SubString&  y);
  friend int        operator >= (SubString& x, SubString&  y);
  friend int        operator >= (SubString& x, const char* t);
  
  friend int        operator >  (SubString& x, String&     y);
  friend int        operator >  (String&    x, SubString&  y);
  friend int        operator >  (SubString& x, SubString&  y);
  friend int        operator >  (SubString& x, const char* t);

  int               contains(char        c);
  int               contains(String&     y);
  int               contains(SubString&  y);
  int               contains(const char* t);
  int               contains(Regex&       r);

  int               matches(Regex&  r);

 

  int               length();
  int               empty();

  friend ostream&   operator<<(ostream& s, SubString& x);

  int               OK(); 

 

  friend int        compare(SubString& x, String&     y);
  friend int        compare(String&    x, SubString&  y);
  friend int        compare(SubString& x, SubString&  y);
  friend int        compare(SubString& x, const char* y);

};


class String
{
  friend class      SubString;
  friend class      Regex;
  friend class      StrTmp;

protected:
  StrRep*           rep;

  int               search(int, int, const char*, int = -1);
  int               search(int, int, char);
  int               match(int, int, int, const char*, int = -1);
  int               _gsub(const char*, int, const char* ,int);
  int               _gsub(Regex&, const char*, int);

public:

 

                    String();
                    String(String& x);
                    String(SubString&  x);
                    String(const char* t);
                    String(const char* t, int len);
                    String(char c);

                    ~String();

  void              operator =  (String&     y);
  void              operator =  (StrTmp&     y);
  void              operator =  (const char* y);
  void              operator =  (char        c);
  void              operator =  (SubString&  y);

 

  StrTmp            operator +  (String&     y);     
  StrTmp            operator +  (const char* t);
  StrTmp            operator +  (char        c);
  StrTmp            operator +  (SubString&  y);     
  StrTmp            operator +  (StrTmp& y);
  friend StrTmp     operator +  (const char* t, String& y);
  friend StrTmp     operator +  (char        c, String& x);

  void              operator += (String&     y); 
  void              operator += (SubString&  y);
  void              operator += (const char* t);
  void              operator += (char        c);

  void              prepend(String&     y); 
  void              prepend(SubString&  y);
  void              prepend(const char* t);
  void              prepend(char        c);

  
 

  friend int        operator == (String&     x, String&     y);
  friend int        operator == (String&     x, const char* t);
  friend int        operator == (String&     x, SubString&  y);
  friend int        operator == (SubString&  x, String&     y);
  
  friend int        operator != (String&     x, String&     y);
  friend int        operator != (String&     x, const char* t);
  friend int        operator != (String&     x, SubString&  y);
  friend int        operator != (SubString&  x, String&     y);
  
  friend int        operator <= (String&     x, String&     y);
  friend int        operator <= (String&     x, const char* t);
  friend int        operator <= (String&     x, SubString&  y);
  friend int        operator <= (SubString&  x, String&     y);
  
  friend int        operator <  (String&     x, String&     y);
  friend int        operator <  (String&     x, const char* t);
  friend int        operator <  (String&     x, SubString&  y);
  friend int        operator <  (SubString&  x, String&     y);
  
  friend int        operator >= (String&     x, String&     y);
  friend int        operator >= (String&     x, const char* t);
  friend int        operator >= (String&     x, SubString&  y);
  friend int        operator >= (SubString&  x, String&     y);
  
  friend int        operator >  (String&     x, String&     y);
  friend int        operator >  (String&     x, const char* t);
  friend int        operator >  (String&     x, SubString&  y);
  friend int        operator >  (SubString&  x, String&     y);

  friend int        fcompare(String&   x, String&     y);  

 

  int               index(char        c, int startpos = 0);      
  int               index(String&     y, int startpos = 0);      
  int               index(SubString&  y, int startpos = 0);      
  int               index(const char* t, int startpos = 0);  
  int               index(Regex&      r, int startpos = 0);       

  int               contains(char        c);
  int               contains(String&     y);
  int               contains(SubString&  y);
  int               contains(const char* t);
  int               contains(Regex&      r);

  int               contains(char        c, int pos);
  int               contains(String&     y, int pos);
  int               contains(SubString&  y, int pos);
  int               contains(const char* t, int pos);
  int               contains(Regex&      r, int pos);

  int               matches(char        c, int pos = 0);
  int               matches(String&     y, int pos = 0);
  int               matches(SubString&  y, int pos = 0);
  int               matches(const char* t, int pos = 0);
  int               matches(Regex&      r, int pos = 0);

  int               freq(char        c);  
  int               freq(String&     y);
  int               freq(SubString&  y);
  int               freq(const char* t);

 

  SubString         at(int         pos, int len);
  SubString         at(String&     x, int startpos = 0); 
  SubString         at(SubString&  x, int startpos = 0); 
  SubString         at(const char* t, int startpos = 0);
  SubString         at(char        c, int startpos = 0);
  SubString         at(Regex&      r, int startpos = 0); 

  SubString         before(int          pos);
  SubString         before(String&      x, int startpos = 0);
  SubString         before(SubString&   x, int startpos = 0);
  SubString         before(const char*  t, int startpos = 0);
  SubString         before(char         c, int startpos = 0);
  SubString         before(Regex&       r, int startpos = 0);

  SubString         through(int          pos);
  SubString         through(String&      x, int startpos = 0);
  SubString         through(SubString&   x, int startpos = 0);
  SubString         through(const char*  t, int startpos = 0);
  SubString         through(char         c, int startpos = 0);
  SubString         through(Regex&       r, int startpos = 0);

  SubString         from(int          pos);
  SubString         from(String&      x, int startpos = 0);
  SubString         from(SubString&   x, int startpos = 0);
  SubString         from(const char*  t, int startpos = 0);
  SubString         from(char         c, int startpos = 0);
  SubString         from(Regex&       r, int startpos = 0);

  SubString         after(int         pos);
  SubString         after(String&     x, int startpos = 0);
  SubString         after(SubString&  x, int startpos = 0);
  SubString         after(const char* t, int startpos = 0);
  SubString         after(char        c, int startpos = 0);
  SubString         after(Regex&      r, int startpos = 0);

 

  void              del(int         pos, int len);
  void              del(String&     y, int startpos = 0);
  void              del(SubString&  y, int startpos = 0);
  void              del(const char* t, int startpos = 0);
  void              del(char        c, int startpos = 0);
  void              del(Regex&      r, int startpos = 0);

  int               gsub(String&     pat, String&     repl);
  int               gsub(SubString&  pat, String&     repl);
  int               gsub(const char* pat, String&     repl);
  int               gsub(const char* pat, const char* repl);
  int               gsub(Regex&      pat, String&     repl);

 

  friend int        split(String& x, String res[], int maxn, String& sep);
  friend int        split(String& x, String res[], int maxn, Regex&  sep);

  friend StrTmp     join(String src[], int n, String& sep);

  friend StrTmp     replicate(char        c, int n);
  friend StrTmp     replicate(String&     y, int n);

  friend StrTmp     common_prefix(String& x, String& y, int startpos = 0);
  friend StrTmp     common_suffix(String& x, String& y, int startpos = -1);

  friend StrTmp     reverse(String& x);
  friend StrTmp     upcase(String& x);
  friend StrTmp     downcase(String& x);
  friend StrTmp     capitalize(String& x);

 

  void              reverse();
  void              upcase();
  void              downcase();
  void              capitalize();

 

  char&             operator [] (int i);

  const char*       operator char*();

 

  friend ostream&   operator<<(ostream& s, String& x);
  friend ostream&   operator<<(ostream& s, SubString& x);
  friend istream&   operator>>(istream& s, String& x);

  friend int        readline(istream& s, String& x, 
                             char terminator = '\n',
                             int discard_terminator = 1);

 

  int               length();
  int               empty();

  void              alloc(int newsize);

  void              error(char* msg);
  int               OK();

 

  friend int        compare(String&    x, String&     y);
  friend int        compare(String&    x, SubString&  y);
  friend int        compare(String&    x, const char* y);
  friend int        compare(SubString& x, String&     y);
};

class StrTmp : public String
{
public:
                    StrTmp(StrRep* p);
                    StrTmp(String& x);
                    StrTmp(StrTmp& x);
                    ~StrTmp();

  StrTmp            operator + (String& y); 
  StrTmp            operator + (SubString& y); 
  StrTmp            operator + (const char* y); 
  StrTmp            operator + (char y); 
  friend StrTmp     operator + (const char* x, StrTmp& y);
  friend StrTmp     operator + (char x, StrTmp& y);

  friend StrTmp     reverse(StrTmp& x);
  friend StrTmp     upcase(StrTmp& x);
  friend StrTmp     downcase(StrTmp& x);
  friend StrTmp     capitalize(StrTmp& x);

};

 

extern Regex RXwhite;           
extern Regex RXint;             
extern Regex RXdouble;          
                                
                                
extern Regex RXalpha;           
extern Regex RXlowercase;       
extern Regex RXuppercase;       
extern Regex RXalphanum;        
extern Regex RXidentifier;      


 


extern StrRep  _nilStrRep;
extern String _nilString;


inline String::String()
{ 
  rep = &_nilStrRep;
}

inline String::String(String& x)
{ 
  rep = Scopy(0, x.rep);
}

inline String::String(const char* t)
{
  rep = Salloc(0, t, -1, -1);
}

inline StrTmp::StrTmp(StrRep* r) 
{
  rep = r;
}

inline StrTmp::StrTmp(String& x) 
{
  rep = x.rep; x.rep = &_nilStrRep;
}

inline StrTmp::StrTmp(StrTmp& x) 
{
  rep = x.rep; x.rep = &_nilStrRep;
}

inline String::String(const char* t, int tlen)
{
  rep = Salloc(0, t, tlen, tlen);
}

inline String::String(SubString& y)
{
  rep = Salloc(0, &(y.S->rep->s[y.pos]), y.len, y.len);
}

inline String::String(char c)
{
  rep = Salloc(0, &c, 1, 1);
}

inline String::~String()
{ 
  if (rep != &_nilStrRep) delete rep;
}

inline StrTmp::~StrTmp() {} 

inline void String::operator =  (String& y)
{ 
  rep = Scopy(rep, y.rep);
}

inline void String::operator =  (StrTmp& y)
{ 
  if (rep != &_nilStrRep) delete rep; 
  rep = y.rep; y.rep = &_nilStrRep;
}

inline void String::operator=(const char* t)
{
  rep = Salloc(rep, t, -1, -1); 
}

inline void String::operator=(SubString&  y)
{
  rep = Salloc(rep, &(y.S->rep->s[y.pos]), y.len, y.len);
}

inline void String::operator=(char c)
{
  rep = Salloc(rep, &c, 1, 1); 
}

inline void String::operator +=(String& y)
{
  rep = Scat(rep, rep->s, rep->len, y.rep->s, y.rep->len);
}

inline void String::operator +=(SubString& y)
{
  rep = Scat(rep, rep->s, rep->len, &(y.S->rep->s[y.pos]),y.len);
}

inline void String::operator += (const char* y)
{
  rep = Scat(rep, rep->s, rep->len, y, -1);
}

inline void String:: operator +=(char y)
{
  rep = Scat(rep, rep->s, rep->len, &y, 1); 
}

inline StrTmp String::operator + (String& y)
{
  return(Scat(0, rep->s, rep->len, y.rep->s, y.rep->len));
}

inline StrTmp String::operator +(SubString& y)
{
  return(Scat(0, rep->s, rep->len, &(y.S->rep->s[y.pos]),y.len));
}

inline StrTmp String::operator + (const char* y)
{
  return(Scat(0, rep->s, rep->len, y, -1));
}

inline StrTmp String::operator + (char y)
{
  return(Scat(0, rep->s, rep->len, &y, 1));
}

inline StrTmp SubString::operator + (String& y)
{
  return(Scat(0, &(S->rep->s[pos]), len, y.rep->s, y.rep->len));
}

inline StrTmp SubString::operator + (SubString& y)
{
  return(Scat(0, &(S->rep->s[pos]), len, &(y.S->rep->s[y.pos]), y.len));
}

inline StrTmp SubString::operator + (const char* y)
{
  return(Scat(0, &(S->rep->s[pos]), len, y, -1));
}

inline StrTmp SubString::operator + (char y)
{
  return(Scat(0, &(S->rep->s[pos]), len, &y, 1));
}

inline StrTmp operator +(const char* t, String& y)
{
  return(Scat(0, t, -1, y.rep->s, y.rep->len));
}

inline StrTmp operator + (const char* t, SubString& y)
{
  return(Scat(0, t, -1, &(y.S->rep->s[y.pos]), y.len));
}

inline StrTmp operator + (char c, String& y)
{
  return(Scat(0, &c, 1, y.rep->s, y.rep->len));
}

inline StrTmp operator + (char c, SubString& y)
{
  return(Scat(0, &c, 1, &(y.S->rep->s[y.pos]), y.len));
}

inline StrTmp StrTmp::operator + (String& y)
{
  rep = Scat(rep, rep->s, rep->len, y.rep->s, y.rep->len); return *this;
}

inline StrTmp StrTmp::operator + (SubString& y)
{
  rep = Scat(rep, rep->s, rep->len, &(y.S->rep->s[y.pos]),y.len); return *this;
}

inline StrTmp StrTmp::operator + (const char* y)
{
  rep = Scat(rep, rep->s, rep->len, y, -1); return *this;
}

inline StrTmp StrTmp::operator + (char y)
{
  rep = Scat(rep, rep->s, rep->len, &y, 1); return *this;
}

inline StrTmp String::operator + (StrTmp& y)
{
  y.rep = Sprepend(y.rep, rep->s, rep->len); return y;
}

inline StrTmp SubString::operator + (StrTmp& y)
{
  y.rep = Sprepend(y.rep, &(S->rep->s[pos]), len); return y;
}

inline StrTmp operator + (const char* x, StrTmp& y)
{
  y.rep = Sprepend(y.rep, x, -1); return y;
}

inline StrTmp operator + (char x, StrTmp& y)
{
  y.rep = Sprepend(y.rep, &x, 1); return y;
}

inline void String::prepend(String& y)
{
  rep = Sprepend(rep, y.rep->s, y.rep->len);
}

inline void String::prepend(const char* y)
{
  rep = Sprepend(rep, y, -1); 
}

inline void String::prepend(char y)
{
  rep = Sprepend(rep, &y, 1); 
}

inline void String::prepend(SubString& y)
{
  rep = Sprepend(rep, &(y.S->rep->s[y.pos]), y.len);
}

inline StrTmp reverse(String& x)
{
  return(Sreverse(x.rep, 0));
}

inline StrTmp reverse(StrTmp& x)
{
  x.rep = Sreverse(x.rep, x.rep); return x;
}

inline void String::reverse()
{
  rep = Sreverse(rep, rep);
}

inline StrTmp upcase(String& x)
{
  return(Supcase(x.rep, 0));
}

inline StrTmp upcase(StrTmp& x)
{
  x.rep = Supcase(x.rep, x.rep); return x;
}

inline void String::upcase()
{
  rep = Supcase(rep, rep);
}

inline StrTmp downcase(String& x)
{
  return(Sdowncase(x.rep, 0));
}

inline StrTmp downcase(StrTmp& x)
{
  x.rep = Sdowncase(x.rep, x.rep); return x;
}

inline void String::downcase()
{
  rep = Sdowncase(rep, rep);
}

inline StrTmp capitalize(String& x)
{
  return(Scapitalize(x.rep, 0));
}

inline StrTmp capitalize(StrTmp& x)
{
  x.rep = Scapitalize(x.rep, x.rep); return x;
}

inline void String::capitalize()
{
  rep = Scapitalize(rep, rep);
}

inline void String::alloc(int newsize)
{
  rep = Sresize(rep, newsize);
}

inline SubString::SubString(const SubString& x)
{ 
  S = x.S; pos = x.pos;   len = x.len; 
}

inline SubString::SubString(String* x, int first, int l)
{
  if (first < 0 || (unsigned)(first + l) > x->rep->len)
  {
    S = &_nilString; pos = len = 0;
  }
  else
  {
    S = x; pos = first; len = l;
  }
}

inline SubString::~SubString() {}

inline void SubString::operator = (const char* ys)
{
  assign(0, ys);
}

inline void SubString::operator = (char ch)
{
  assign(0, &ch, 1);
}

inline void SubString::operator = (String& y)
{
  assign(y.rep, y.rep->s, y.rep->len);
}

inline void SubString::operator = (SubString& y)
{
  assign(y.S->rep, &(y.S->rep->s[y.pos]), y.len);
}

inline int String::length()
{ 
  return rep->len;
}

inline int String::empty()
{ 
  return rep->len == 0;
}

inline char&  String::operator [] (int i) 
{ 
  if (((unsigned)i) >= rep->len) error("invalid index");
  return rep->s[i];
}

inline int String::index(char c, int startpos = 0)
{
  return search(startpos, rep->len, c);
}

inline int String::index(const char* t, int startpos = 0)
{   
  return search(startpos, rep->len, t);
}

inline int String::index(String& y, int startpos = 0)
{   
  return search(startpos, rep->len, y.rep->s, y.rep->len);
}

inline int String::index(SubString& y, int startpos = 0)
{   
  return search(startpos, rep->len, &(y.S->rep->s[y.pos]), y.len);
}

inline int String::contains(char c)
{
  return search(0, rep->len, c) >= 0;
}

inline int SubString::contains(char c)
{
  return S->search(pos, pos+len, 0, c) >= 0;
}

inline int String::contains(const char* t)
{   
  return search(0, rep->len, t) >= 0;
}

inline int String::contains(String& y)
{   
  return search(0, rep->len, y.rep->s, y.rep->len) >= 0;
}

inline int String::contains(SubString& y)
{   
  return search(0, rep->len, &(y.S->rep->s[y.pos]), y.len) >= 0;
}

inline int SubString::contains(const char* t)
{   
  return S->search(pos, pos+len, t) >= 0;
}

inline int SubString::contains(String& y)
{   
  return S->search(pos, pos+len, y.rep->s, y.rep->len) >= 0;
}

inline int SubString::contains(SubString&  y)
{   
  return S->search(pos, pos+len, &(y.S->rep->s[y.pos]), y.len) >= 0;
}

inline int String::contains(char c, int p)
{
  return match(p, rep->len, 0, &c, 1);
}

inline int String::matches(char c, int p = 0)
{
  return match(p, rep->len, 1, &c, 1);
}

inline int String::contains(const char* t, int p)
{
  return match(p, rep->len, 0, t);
}

inline int String::matches(const char* t, int p = 0)
{
  return match(p, rep->len, 1, t);
}

inline int String::contains(String& y, int p)
{
  return match(p, rep->len, 0, y.rep->s, y.rep->len);
}

inline int String::matches(String& y, int p = 0)
{
  return match(p, rep->len, 1, y.rep->s, y.rep->len);
}

inline int String::contains(SubString& y, int p)
{
  return match(p, rep->len, 0, &(y.S->rep->s[y.pos]), y.len);
}

inline int String::matches(SubString& y, int p = 0)
{
  return match(p, rep->len, 1, &(y.S->rep->s[y.pos]), y.len);
}

inline int String::contains(Regex& r)
{
  int unused;  return r.search(rep->s, rep->len, unused, 0) >= 0;
}

inline int SubString::contains(Regex& r)
{
  int unused;  return r.search(&(S->rep->s[pos]), len, unused, 0) >= 0;
}

inline int String::contains(Regex& r, int p)
{
  return r.match(rep->s, rep->len, p) >= 0;
}

inline int String::matches(Regex& r, int p = 0)
{
  int l = (p < 0)? -p : rep->len - p;
  return r.match(rep->s, rep->len, p) == l;
}

inline int SubString::matches(Regex& r)
{
  return r.match(&(S->rep->s[pos]), len, 0) == len;
}

inline const char* String::operator char*()
{ 
  return rep->s;
}

inline int String::index(Regex& r, int startpos = 0)
{
  int unused;  return r.search(rep->s, rep->len, unused, startpos);
}


inline  int SubString::length()
{ 
  return len;
}

inline  int SubString::empty()
{ 
  return len == 0;
}

inline  ostream& operator<<(ostream& s, String& x)
{ 
  s.put(x.rep->s); return s;
}

inline int operator==(String& x, String& y) 
{
  return compare(x, y) == 0; 
}

inline int operator!=(String& x, String& y)
{
  return compare(x, y) != 0; 
}

inline int operator>(String& x, String& y)
{
  return compare(x, y) > 0; 
}

inline int operator>=(String& x, String& y)
{
  return compare(x, y) >= 0; 
}

inline int operator<(String& x, String& y)
{
  return compare(x, y) < 0; 
}

inline int operator<=(String& x, String& y)
{
  return compare(x, y) <= 0; 
}

inline int operator==(String& x, SubString&  y) 
{
  return compare(x, y) == 0; 
}

inline int operator!=(String& x, SubString&  y)
{
  return compare(x, y) != 0; 
}

inline int operator>(String& x, SubString&  y)      
{
  return compare(x, y) > 0; 
}

inline int operator>=(String& x, SubString&  y)
{
  return compare(x, y) >= 0; 
}

inline int operator<(String& x, SubString&  y) 
{
  return compare(x, y) < 0; 
}

inline int operator<=(String& x, SubString&  y)
{
  return compare(x, y) <= 0; 
}

inline int operator==(String& x, const char* t) 
{
  return compare(x, t) == 0; 
}

inline int operator!=(String& x, const char* t) 
{
  return compare(x, t) != 0; 
}

inline int operator>(String& x, const char* t)  
{
  return compare(x, t) > 0; 
}

inline int operator>=(String& x, const char* t) 
{
  return compare(x, t) >= 0; 
}

inline int operator<(String& x, const char* t)  
{
  return compare(x, t) < 0; 
}

inline int operator<=(String& x, const char* t) 
{
  return compare(x, t) <= 0; 
}

inline int operator==(SubString& x, String& y) 
{
  return compare(y, x) == 0; 
}

inline int operator!=(SubString& x, String& y)
{
  return compare(y, x) != 0;
}

inline int operator>(SubString& x, String& y)      
{
  return compare(y, x) < 0;
}

inline int operator>=(SubString& x, String& y)     
{
  return compare(y, x) <= 0;
}

inline int operator<(SubString& x, String& y)      
{
  return compare(y, x) > 0;
}

inline int operator<=(SubString& x, String& y)     
{
  return compare(y, x) >= 0;
}

inline int operator==(SubString& x, SubString&  y) 
{
  return compare(x, y) == 0; 
}

inline int operator!=(SubString& x, SubString&  y)
{
  return compare(x, y) != 0;
}

inline int operator>(SubString& x, SubString&  y)      
{
  return compare(x, y) > 0;
}

inline int operator>=(SubString& x, SubString&  y)
{
  return compare(x, y) >= 0;
}

inline int operator<(SubString& x, SubString&  y) 
{
  return compare(x, y) < 0;
}

inline int operator<=(SubString& x, SubString&  y)
{
  return compare(x, y) <= 0;
}

inline int operator==(SubString& x, const char* t) 
{
  return compare(x, t) == 0; 
}

inline int operator!=(SubString& x, const char* t) 
{
  return compare(x, t) != 0;
}

inline int operator>(SubString& x, const char* t)  
{
  return compare(x, t) > 0; 
}

inline int operator>=(SubString& x, const char* t) 
{
  return compare(x, t) >= 0; 
}

inline int operator<(SubString& x, const char* t)  
{
  return compare(x, t) < 0; 
}

inline int operator<=(SubString& x, const char* t) 
{
  return compare(x, t) <= 0; 
}


inline SubString String::at(int first, int len)
{
  return SubString(this, first, len);
}

inline SubString String::before(int pos)
{
  return SubString(this, 0, pos);
}

inline SubString String::through(int pos)
{
  return SubString(this, 0, pos+1);
}

inline SubString String::after(int pos)
{
  return SubString(this, pos + 1, rep->len - (pos + 1));
}

inline SubString String::from(int pos)
{
  return SubString(this, pos, rep->len - pos);
}

inline int String::gsub(String& pat, String& r)
{
  return _gsub(pat.rep->s, pat.rep->len, r.rep->s, r.rep->len);
}

inline int String::gsub(SubString&  pat, String& r)
{
  return _gsub(&(pat.S->rep->s[pat.pos]), pat.len, r.rep->s, r.rep->len);
}

inline int String::gsub(Regex& pat, String& r)
{
  return _gsub(pat, r.rep->s, r.rep->len);
}

inline int String::gsub(const char* pat, String& r)
{
  return _gsub(pat, -1, r.rep->s, r.rep->len);
}

inline int String::gsub(const char* pat, const char* r)
{
  return _gsub(pat, -1, r, -1);
}

inline void String::del(String& y, int startpos = 0)
{
  del(search(startpos, rep->len, y.rep->s, y.rep->len), y.rep->len);
}

inline void String::del(SubString& y, int startpos = 0)
{
  del(search(startpos, rep->len, &(y.S->rep->s[y.pos]), y.len), y.len);
}

inline void String::del(char c, int startpos = 0)
{
  del(search(startpos, rep->len, c), 1);
}


inline Regex::Regex(String& x, int fast = 0, int bufsize = 40, 
             const char* transtable = 0)
{
  initialize(x.rep->s, x.rep->len, fast, bufsize, transtable);
}

inline Regex::Regex(const char* t, int fast = 0, int bufsize = 40, 
             const char* transtable = 0)
{
  initialize(t, -1, fast, bufsize, transtable);
}

# 18 "Simulateur.h"

# 1 "Define.h"
 
enum Logique { FAUX=0  , VRAI=!FAUX };

enum PortEntree { IN = 0, IN0 = 0, IN1, IN2 };
enum PortSortie { OUT = 0, OUT0 = 0, OUT1, OUT2 };
enum PortBiDir  { BIDIR = 0, BIDIR0 = 0, BIDIR1, BIDIR2 };
  
enum Type { Nand2, FanOut2, Source, Sink,
	     
	    Top,
	     
	    Not };

# 20 "Simulateur.h"

# 1 "Declaration.h"
 
extern Simulation();

# 21 "Simulateur.h"

# 1 "BlocPortAppel.h"
 
struct BlocEntreeAppel
{
  class BlocAppel *Bloc;
  PortSortie Port;
};

struct BlocSortieAppel
{
  class BlocAppel *Bloc;
  PortEntree Port;
};

struct BlocBiDirAppel
{
  class BlocAppel *Bloc;
  PortBiDir Port;
};


# 22 "Simulateur.h"

# 1 "Typedef.h"
 
typedef class BlocAppel* Appel;
typedef class BlocInstance* Instance;

# 23 "Simulateur.h"

# 1 "Appel.SLList.h"
 
#pragma once


# 1 "/usr/local/lib/g++-include/Pix.h"

#pragma once

typedef void* Pix;

# 30 "Appel.SLList.h"

struct AppelSLListNode
{
  AppelSLListNode*         tl;
  Appel                    hd;
                         AppelSLListNode();
                         AppelSLListNode(Appel  h, AppelSLListNode* t = 0);
                         ~AppelSLListNode();
};

inline AppelSLListNode::AppelSLListNode() {}

inline AppelSLListNode::AppelSLListNode(Appel  h, AppelSLListNode* t = 0)
{
  hd = h;
  tl = t;
}

inline AppelSLListNode::~AppelSLListNode() {}

typedef AppelSLListNode* AppelSLListNodePtr;

class AppelSLList
{
protected:
  AppelSLListNode*        last;

public:
                        AppelSLList();
                        AppelSLList(AppelSLList& a);
                        ~AppelSLList();

  AppelSLList&            operator = (AppelSLList& a);

  int                   empty();
  int                   length();

  void                  clear();

  Pix                   prepend(Appel  item);
  Pix                   append(Appel  item);

  void                  join(AppelSLList&);

  Pix                   prepend(AppelSLListNode*);
  Pix                   append(AppelSLListNode*);

  Appel&                  operator () (Pix p);
  Pix                   first();
  void                  next(Pix& p);
  int                   owns(Pix p);
  Pix                   ins_after(Pix p, Appel  item);
  void                  del_after(Pix p);

  Appel&                  front();
  Appel&                  rear();
  Appel                   remove_front();
  int                   remove_front(Appel& x);
  void                  del_front();

  void                  error(char* msg);
  int                   OK();
};


inline AppelSLList::~AppelSLList()
{
  clear();
}

inline AppelSLList::AppelSLList()
{
  last = 0;
}

inline int AppelSLList::empty()
{
  return last == 0;
}

inline int AppelSLList::length()
{
  int l = 0;
  AppelSLListNode* t = last;
  if (t != 0) do { ++l; t = t->tl; } while (t != last);
  return l;
}

inline Pix AppelSLList::first()
{
  return (last == 0)? 0 : Pix(last->tl);
}

inline void AppelSLList::next(Pix& p)
{
  p = (p == 0 || p == last)? 0 : Pix(((AppelSLListNode*)(p))->tl);
}

inline Appel& AppelSLList::operator () (Pix p)
{
  if (p == 0) error("null Pix");
  return ((AppelSLListNode*)(p))->hd;
}

inline Appel& AppelSLList::front()
{
  if (last == 0) error("front: empty list");
  return last->tl->hd;
}

inline Appel& AppelSLList::rear()
{
  if (last == 0) error("rear: empty list");
  return last->hd;
}

# 25 "Simulateur.h"
# 1 "Instance.SLList.h"
 
#pragma once

struct InstanceSLListNode
{
  InstanceSLListNode*         tl;
  Instance                    hd;
                         InstanceSLListNode();
                         InstanceSLListNode(Instance  h, InstanceSLListNode* t = 0);
                         ~InstanceSLListNode();
};

inline InstanceSLListNode::InstanceSLListNode() {}

inline InstanceSLListNode::InstanceSLListNode(Instance  h, InstanceSLListNode* t = 0)
{
  hd = h;
  tl = t;
}

inline InstanceSLListNode::~InstanceSLListNode() {}

typedef InstanceSLListNode* InstanceSLListNodePtr;




class InstanceSLList
{
protected:
  InstanceSLListNode*        last;

public:
                        InstanceSLList();
                        InstanceSLList(InstanceSLList& a);
                        ~InstanceSLList();

  InstanceSLList&            operator = (InstanceSLList& a);

  int                   empty();
  int                   length();

  void                  clear();

  Pix                   prepend(Instance  item);
  Pix                   append(Instance  item);

  void                  join(InstanceSLList&);

  Pix                   prepend(InstanceSLListNode*);
  Pix                   append(InstanceSLListNode*);

  Instance&                  operator () (Pix p);
  Pix                   first();
  void                  next(Pix& p);
  int                   owns(Pix p);
  Pix                   ins_after(Pix p, Instance  item);
  void                  del_after(Pix p);

  Instance&                  front();
  Instance&                  rear();
  Instance                   remove_front();
  int                   remove_front(Instance& x);
  void                  del_front();

  void                  error(char* msg);
  int                   OK();
};


inline InstanceSLList::~InstanceSLList()
{
  clear();
}

inline InstanceSLList::InstanceSLList()
{
  last = 0;
}

inline int InstanceSLList::empty()
{
  return last == 0;
}

inline int InstanceSLList::length()
{
  int l = 0;
  InstanceSLListNode* t = last;
  if (t != 0) do { ++l; t = t->tl; } while (t != last);
  return l;
}

inline Pix InstanceSLList::first()
{
  return (last == 0)? 0 : Pix(last->tl);
}

inline void InstanceSLList::next(Pix& p)
{
  p = (p == 0 || p == last)? 0 : Pix(((InstanceSLListNode*)(p))->tl);
}

inline Instance& InstanceSLList::operator () (Pix p)
{
  if (p == 0) error("null Pix");
  return ((InstanceSLListNode*)(p))->hd;
}

inline Instance& InstanceSLList::front()
{
  if (last == 0) error("front: empty list");
  return last->tl->hd;
}

inline Instance& InstanceSLList::rear()
{
  if (last == 0) error("rear: empty list");
  return last->hd;
}

# 26 "Simulateur.h"

# 1 "Objet.h"
 
class Objet
{
};

# 28 "Simulateur.h"

# 1 "Bloc.h"
 
class BlocAppel:public Objet  
{
private:
protected:
  int NumeroAppel;
  BlocEntreeAppel *BlocPortEntree;
  BlocBiDirAppel *BlocPortBiDir;
  BlocSortieAppel *BlocPortSortie;
  class BlocType *blocappelant;
public:
  Caracteristiques(int entrees,int bidir,int sorties);
  ConnecteAppelEntrees(PortEntree DeThis,
		       BlocAppel* BlocAConnecterEnEntree,
		       PortSortie SortieAConnecterEnEntree);
  ConnecteAppelSorties(PortSortie DeThis,
		       BlocAppel* BlocAConnecterASortie,
		       PortEntree EntreeAConnecterASortie);
  DefinieAppel();
  BlocType *BlocAppelant() { return blocappelant; }
  BlocAppel();
};

class BlocType:public Objet  
{
private:
  int NombreEntrees=0;
  int NombreSorties=0;
  int NombreBiDir=0;
  String *Nom;
protected:
public:
  String NomType();		 
  NomType(String);		 
  int Entrees() { return NombreEntrees; }
  int Sorties() { return NombreSorties; }
  int BiDir() { return NombreBiDir; }
  PortType(int entrees, int bidir, int sorties);
  virtual AppelInstance(BlocInstance *);
};

class BlocInstance : public Objet   
{
private:
protected:
  BlocInstance *InstanceAppelante;  
				 
public:
};


# 29 "Simulateur.h"

# 1 "BlocFeuille.h"
 
class BlocFeuilleAppel : public BlocAppel
{  
};

 
class BlocFeuilleType : public BlocType
{  
};

 
class BlocFeuilleInstance : public BlocInstance
{  
};

# 30 "Simulateur.h"

# 1 "BlocComposite.h"
 
class BlocCompositeAppel:public BlocAppel
{  
};

 
class BlocCompositeType:public BlocType
{  
protected:
  class AppelSLList *appellist;	 
				 
				 
public:
  AjouteAppel(BlocAppel *);
};

 
class BlocCompositeInstance:public BlocInstance
{  
protected:
  class InstanceSLList *instancelist;  
public:
  Instance(BlocInstance *);
};

# 31 "Simulateur.h"

# 13 "Adder.cc"