; GNU C version 3.4-llvm 20030530 (experimental) (i686-pc-linux-gnu)
;	compiled by GNU C version 3.2.
; GGC heuristics: --param ggc-min-expand=90 --param ggc-min-heapsize=113090
; options passed:  -E -iprefix -DSPEC_CPU2000 -O0
; options enabled:  -feliminate-unused-debug-types -fpeephole
; -ffunction-cse -fkeep-static-consts -fpcc-struct-return -fgcse-lm
; -fgcse-sm -fsched-interblock -fsched-spec -fbranch-count-reg -fcommon
; -fgnu-linker -fargument-alias -fzero-initialized-in-bss -fident
; -fmath-errno -ftrapping-math -m80387 -mhard-float -mno-soft-float
; -mieee-fp -mfp-ret-in-387 -maccumulate-outgoing-args -mno-red-zone
; -mtune=pentiumpro -march=i386

target pointersize = 32
target endian = little
ize_t;
# 35 "/usr/include/stdio.h" 2 3 4

# 1 "/usr/include/bits/types.h" 1 3 4
# 28 "/usr/include/bits/types.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 29 "/usr/include/bits/types.h" 2 3 4


# 1 "/home/dcrowe/llvm/cfrontend/x86/llvm-gcc/lib/gcc-lib/i686-pc-linux-gnu/3.4-llvm/include/stddef.h" 1 3 4
# 32 "/usr/include/bits/types.h" 2 3 4


typedef unsigned char __u_char;
typedef unsigned short int __u_short;
typedef unsigned int __u_int;
typedef unsigned long int __u_long;


typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef signed short int __int16_t;
typedef unsigned short int __uint16_t;
typedef signed int __int32_t;
typedef unsigned int __uint32_t;




__extension__ typedef signed long long int __int64_t;
__extension__ typedef unsigned long long int __uint64_t;





__extension__ typedef long long int __quad_t;
__extension__ typedef unsigned long long int __u_quad_t;
# 128 "/usr/include/bits/types.h" 3 4
# 1 "/usr/include/bits/typesizes.h" 1 3 4
# 129 "/usr/include/bits/types.h" 2 3 4


typedef unsigned long long int __dev_t;
typedef unsigned int __uid_t;
typedef unsigned int __gid_t;
typedef unsigned long int __ino_t;
typedef unsigned long long int __ino64_t;
typedef unsigned int __mode_t;
typedef unsigned int __nlink_t;
typedef long int __off_t;
typedef long long int __off64_t;
typedef int __pid_t;
typedef struct { int __val[2]; } __fsid_t;
typedef long int __clock_t;
typedef unsigned long int __rlim_t;
typedef unsigned long long int __rlim64_t;
typedef unsigned int __id_t;
typedef long int __time_t;
typedef unsigned int __useconds_t;
typedef long int __suseconds_t;

typedef int __daddr_t;
typedef long int __swblk_t;
typedef int __key_t;


typedef int __clockid_t;


typedef int __timer_t;


typedef long int __blksize_t;




typedef long int __blkcnt_t;
typedef long long int __blkcnt64_t;


typedef unsigned long int __fsblkcnt_t;
typedef unsigned long long int __fsblkcnt64_t;


typedef unsigned long int __fsfilcnt_t;
typedef unsigned long long int __fsfilcnt64_t;




typedef int __ssize_t;
typedef __off64_t __loff_t;
typedef __quad_t *__qaddr_t;
typedef char *__caddr_t;


typedef int __intptr_t;


typedef unsigned int __socklen_t;
# 37 "/usr/include/stdio.h" 2 3 4









typedef struct _IO_FILE FILE;





# 62 "/usr/include/stdio.h" 3 4
typedef struct _IO_FILE __FILE;
# 72 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/libio.h" 1 3 4
# 32 "/usr/include/libio.h" 3 4
# 1 "/usr/include/_G_config.h" 1 3 4
# 14 "/usr/include/_G_config.h" 3 4
# 1 "/home/dcrowe/llvm/cfrontend/x86/llvm-gcc/lib/gcc-lib/i686-pc-linux-gnu/3.4-llvm/include/stddef.h" 1 3 4
# 325 "/home/dcrowe/llvm/cfrontend/x86/llvm-gcc/lib/gcc-lib/i686-pc-linux-gnu/3.4-llvm/include/stddef.h" 3 4
typedef long int wchar_t;
# 354 "/home/dcrowe/llvm/cfrontend/x86/llvm-gcc/lib/gcc-lib/i686-pc-linux-gnu/3.4-llvm/include/stddef.h" 3 4
typedef unsigned int wint_t;
# 15 "/usr/include/_G_config.h" 2 3 4
# 24 "/usr/include/_G_config.h" 3 4
# 1 "/usr/include/wchar.h" 1 3 4
# 48 "/usr/include/wchar.h" 3 4
# 1 "/home/dcrowe/llvm/cfrontend/x86/llvm-gcc/lib/gcc-lib/i686-pc-linux-gnu/3.4-llvm/include/stddef.h" 1 3 4
# 49 "/usr/include/wchar.h" 2 3 4

# 1 "/usr/include/bits/wchar.h" 1 3 4
# 51 "/usr/include/wchar.h" 2 3 4
# 71 "/usr/include/wchar.h" 3 4
typedef struct
{
  int __count;
  union
  {
    wint_t __wch;
    char __wchb[4];
  } __value;
} __mbstate_t;
# 25 "/usr/include/_G_config.h" 2 3 4

typedef struct
{
  __off_t __pos;
  __mbstate_t __state;
} _G_fpos_t;
typedef struct
{
  __off64_t __pos;
  __mbstate_t __state;
} _G_fpos64_t;
# 44 "/usr/include/_G_config.h" 3 4
# 1 "/usr/include/gconv.h" 1 3 4
# 28 "/usr/include/gconv.h" 3 4
# 1 "/usr/include/wchar.h" 1 3 4
# 48 "/usr/include/wchar.h" 3 4
# 1 "/home/dcrowe/llvm/cfrontend/x86/llvm-gcc/lib/gcc-lib/i686-pc-linux-gnu/3.4-llvm/include/stddef.h" 1 3 4
# 49 "/usr/include/wchar.h" 2 3 4
# 29 "/usr/include/gconv.h" 2 3 4


# 1 "/home/dcrowe/llvm/cfrontend/x86/llvm-gcc/lib/gcc-lib/i686-pc-linux-gnu/3.4-llvm/include/stddef.h" 1 3 4
# 32 "/usr/include/gconv.h" 2 3 4





enum
{
  __GCONV_OK = 0,
  __GCONV_NOCONV,
  __GCONV_NODB,
  __GCONV_NOMEM,

  __GCONV_EMPTY_INPUT,
  __GCONV_FULL_OUTPUT,
  __GCONV_ILLEGAL_INPUT,
  __GCONV_INCOMPLETE_INPUT,

  __GCONV_ILLEGAL_DESCRIPTOR,
  __GCONV_INTERNAL_ERROR
};



enum
{
  __GCONV_IS_LAST = 0x0001,
  __GCONV_IGNORE_ERRORS = 0x0002
};



struct __gconv_step;
struct __gconv_step_data;
struct __gconv_loaded_object;
struct __gconv_trans_data;



typedef int (*__gconv_fct) (struct __gconv_step *, struct __gconv_step_data *,
       __const unsigned char **, __const unsigned char *,
       unsigned char **, size_t *, int, int);


typedef wint_t (*__gconv_btowc_fct) (struct __gconv_step *, unsigned char);


typedef int (*__gconv_init_fct) (struct __gconv_step *);
typedef void (*__gconv_end_fct) (struct __gconv_step *);



typedef int (*__gconv_trans_fct) (struct __gconv_step *,
      struct __gconv_step_data *, void *,
      __const unsigned char *,
      __const unsigned char **,
      __const unsigned char *, unsigned char **,
      size_t *);


typedef int (*__gconv_trans_context_fct) (void *, __const unsigned char *,
       __const unsigned char *,
       unsigned char *, unsigned char *);


typedef int (*__gconv_trans_query_fct) (__const char *, __const char ***,
     size_t *);


typedef int (*__gconv_trans_init_fct) (void **, const char *);
typedef void (*__gconv_trans_end_fct) (void *);

struct __gconv_trans_data
{

  __gconv_trans_fct __trans_fct;
  __gconv_trans_context_fct __trans_context_fct;
  __gconv_trans_end_fct __trans_end_fct;
  void *__data;
  struct __gconv_trans_data *__next;
};



struct __gconv_step
{
  struct __gconv_loaded_object *__shlib_handle;
  __const char *__modname;

  int __counter;

  char *__from_name;
  char *__to_name;

  __gconv_fct __fct;
  __gconv_btowc_fct __btowc_fct;
  __gconv_init_fct __init_fct;
  __gconv_end_fct __end_fct;



  int __min_needed_from;
  int __max_needed_from;
  int __min_needed_to;
  int __max_needed_to;


  int __stateful;

  void *__data;
};



struct __gconv_step_data
{
  unsigned char *__outbuf;
  unsigned char *__outbufend;



  int __flags;



  int __invocation_counter;



  int __internal_use;

  __mbstate_t *__statep;
  __mbstate_t __state;



  struct __gconv_trans_data *__trans;
};



typedef struct __gconv_info
{
  size_t __nsteps;
  struct __gconv_step *__steps;
  __extension__ struct __gconv_step_data __data [];
} *__gconv_t;
# 45 "/usr/include/_G_config.h" 2 3 4
typedef union
{
  struct __gconv_info __cd;
  struct
  {
    struct __gconv_info __cd;
    struct __gconv_step_data __data;
  } __combined;
} _G_iconv_t;

typedef int _G_int16_t __attribute__ ((__mode__ (__HI__)));
typedef int _G_int32_t __attribute__ ((__mode__ (__SI__)));
typedef unsigned int _G_uint16_t __attribute__ ((__mode__ (__HI__)));
typedef unsigned int _G_uint32_t __attribute__ ((__mode__ (__SI__)));
# 33 "/usr/include/libio.h" 2 3 4
# 53 "/usr/include/libio.h" 3 4
# 1 "/home/dcrowe/llvm/cfrontend/x86/llvm-gcc/lib/gcc-lib/i686-pc-linux-gnu/3.4-llvm/include/stdarg.h" 1 3 4
# 43 "/home/dcrowe/llvm/cfrontend/x86/llvm-gcc/lib/gcc-lib/i686-pc-linux-gnu/3.4-llvm/include/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 54 "/usr/include/libio.h" 2 3 4
# 162 "/usr/include/libio.h" 3 4
struct _IO_jump_t; struct _IO_FILE;
# 172 "/usr/include/libio.h" 3 4
typedef void _IO_lock_t;





struct _IO_marker {
  struct _IO_marker *_next;
  struct _IO_FILE *_sbuf;



  int _pos;
# 195 "/usr/include/libio.h" 3 4
};


enum __codecvt_result
{
  __codecvt_ok,
  __codecvt_partial,
  __codecvt_error,
  __codecvt_noconv
};
# 263 "/usr/include/libio.h" 3 4
struct _IO_FILE {
  int _flags;




  char* _IO_read_ptr;
  char* _IO_read_end;
  char* _IO_read_base;
  char* _IO_write_base;
  char* _IO_write_ptr;
  char* _IO_write_end;
  char* _IO_buf_base;
  char* _IO_buf_end;

  char *_IO_save_base;
  char *_IO_backup_base;
  char *_IO_save_end;

  struct _IO_marker *_markers;

  struct _IO_FILE *_chain;

  int _fileno;



  int _flags2;

  __off_t _old_offset;



  unsigned short _cur_column;
  signed char _vtable_offset;
  char _shortbuf[1];



  _IO_lock_t *_lock;
# 311 "/usr/include/libio.h" 3 4
  __off64_t _offset;





  void *__pad1;
  void *__pad2;

  int _mode;

  char _unused2[15 * sizeof (int) - 2 * sizeof (void *)];

};


typedef struct _IO_FILE _IO_FILE;


struct _IO_FILE_plus;

extern struct _IO_FILE_plus _IO_2_1_stdin_;
extern struct _IO_FILE_plus _IO_2_1_stdout_;
extern struct _IO_FILE_plus _IO_2_1_stderr_;
# 350 "/usr/include/libio.h" 3 4
typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);







typedef __ssize_t __io_write_fn (void *__cookie, __const char *__buf,
     size_t __n);







typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w);


typedef int __io_close_fn (void *__cookie);
# 402 "/usr/include/libio.h" 3 4
extern int __underflow (_IO_FILE *) ;
extern int __uflow (_IO_FILE *) ;
extern int __overflow (_IO_FILE *, int) ;
extern wint_t __wunderflow (_IO_FILE *) ;
extern wint_t __wuflow (_IO_FILE *) ;
extern wint_t __woverflow (_IO_FILE *, wint_t) ;
# 432 "/usr/include/libio.h" 3 4
extern int _IO_getc (_IO_FILE *__fp) ;
extern int _IO_putc (int __c, _IO_FILE *__fp) ;
extern int _IO_feof (_IO_FILE *__fp) ;
extern int _IO_ferror (_IO_FILE *__fp) ;

extern int _IO_peekc_locked (_IO_FILE *__fp) ;





extern void _IO_flockfile (_IO_FILE *) ;
extern void _IO_funlockfile (_IO_FILE *) ;
extern int _IO_ftrylockfile (_IO_FILE *) ;
# 462 "/usr/include/libio.h" 3 4
extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
   __gnuc_va_list, int *__restrict) ;
extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
    __gnuc_va_list) ;
extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t) ;
extern size_t _IO_sgetn (_IO_FILE *, void *, size_t) ;

extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int) ;
extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int) ;

extern void _IO_free_backup_area (_IO_FILE *) ;
# 73 "/usr/include/stdio.h" 2 3 4
# 86 "/usr/include/stdio.h" 3 4


typedef _G_fpos_t fpos_t;




# 138 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/bits/stdio_lim.h" 1 3 4
# 139 "/usr/include/stdio.h" 2 3 4



extern struct _IO_FILE *stdin;
extern struct _IO_FILE *stdout;
extern struct _IO_FILE *stderr;







extern int remove (__const char *__filename) ;

extern int rename (__const char *__old, __const char *__new) ;






extern FILE *tmpfile (void) ;
# 171 "/usr/include/stdio.h" 3 4
extern char *tmpnam (char *__s) ;

# 181 "/usr/include/stdio.h" 3 4
extern char *tmpnam_r (char *__s) ;
# 193 "/usr/include/stdio.h" 3 4
extern char *tempnam (__const char *__dir, __const char *__pfx)
     __attribute__ ((__malloc__));





extern int fclose (FILE *__stream) ;

extern int fflush (FILE *__stream) ;




extern int fflush_unlocked (FILE *__stream) ;
# 216 "/usr/include/stdio.h" 3 4



extern FILE *fopen (__const char *__restrict __filename,
      __const char *__restrict __modes) ;

extern FILE *freopen (__const char *__restrict __filename,
        __const char *__restrict __modes,
        FILE *__restrict __stream) ;
# 239 "/usr/include/stdio.h" 3 4

# 250 "/usr/include/stdio.h" 3 4
extern FILE *fdopen (int __fd, __const char *__modes) ;
# 271 "/usr/include/stdio.h" 3 4



extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) ;



extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
      int __modes, size_t __n) ;





extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
         size_t __size) ;


extern void setlinebuf (FILE *__stream) ;





extern int fprintf (FILE *__restrict __stream,
      __const char *__restrict __format, ...) ;

extern int printf (__const char *__restrict __format, ...) ;

extern int sprintf (char *__restrict __s,
      __const char *__restrict __format, ...) ;


extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
       __gnuc_va_list __arg) ;

extern int vprintf (__const char *__restrict __format, __gnuc_va_list __arg)
     ;

extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
       __gnuc_va_list __arg) ;





extern int snprintf (char *__restrict __s, size_t __maxlen,
       __const char *__restrict __format, ...)
     __attribute__ ((__format__ (__printf__, 3, 4)));

extern int vsnprintf (char *__restrict __s, size_t __maxlen,
        __const char *__restrict __format, __gnuc_va_list __arg)
     __attribute__ ((__format__ (__printf__, 3, 0)));

# 349 "/usr/include/stdio.h" 3 4


extern int fscanf (FILE *__restrict __stream,
     __const char *__restrict __format, ...) ;

extern int scanf (__const char *__restrict __format, ...) ;

extern int sscanf (__const char *__restrict __s,
     __const char *__restrict __format, ...) ;

# 379 "/usr/include/stdio.h" 3 4


extern int fgetc (FILE *__stream) ;
extern int getc (FILE *__stream) ;


extern int getchar (void) ;








extern int getc_unlocked (FILE *__stream) ;
extern int getchar_unlocked (void) ;




extern int fgetc_unlocked (FILE *__stream) ;





extern int fputc (int __c, FILE *__stream) ;
extern int putc (int __c, FILE *__stream) ;


extern int putchar (int __c) ;








extern int fputc_unlocked (int __c, FILE *__stream) ;




extern int putc_unlocked (int __c, FILE *__stream) ;
extern int putchar_unlocked (int __c) ;





extern int getw (FILE *__stream) ;


extern int putw (int __w, FILE *__stream) ;





extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
     ;



extern char *gets (char *__s) ;

# 475 "/usr/include/stdio.h" 3 4


extern int fputs (__const char *__restrict __s, FILE *__restrict __stream)
     ;


extern int puts (__const char *__s) ;



extern int ungetc (int __c, FILE *__stream) ;



extern size_t fread (void *__restrict __ptr, size_t __size,
       size_t __n, FILE *__restrict __stream) ;

extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
        size_t __n, FILE *__restrict __s) ;

# 504 "/usr/include/stdio.h" 3 4
extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
         size_t __n, FILE *__restrict __stream) ;
extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
          size_t __n, FILE *__restrict __stream) ;





extern int fseek (FILE *__stream, long int __off, int __whence) ;

extern long int ftell (FILE *__stream) ;

extern void rewind (FILE *__stream) ;

# 544 "/usr/include/stdio.h" 3 4



extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos)
     ;

extern int fsetpos (FILE *__stream, __const fpos_t *__pos) ;
# 563 "/usr/include/stdio.h" 3 4

# 573 "/usr/include/stdio.h" 3 4


extern void clearerr (FILE *__stream) ;

extern int feof (FILE *__stream) ;

extern int ferror (FILE *__stream) ;




extern void clearerr_unlocked (FILE *__stream) ;
extern int feof_unlocked (FILE *__stream) ;
extern int ferror_unlocked (FILE *__stream) ;





extern void perror (__const char *__s) ;






# 1 "/usr/include/bits/sys_errlist.h" 1 3 4
# 27 "/usr/include/bits/sys_errlist.h" 3 4
extern int sys_nerr;
extern __const char *__const sys_errlist[];
# 600 "/usr/include/stdio.h" 2 3 4




extern int fileno (FILE *__stream) ;




extern int fileno_unlocked (FILE *__stream) ;






extern FILE *popen (__const char *__command, __const char *__modes) ;


extern int pclose (FILE *__stream) ;





extern char *ctermid (char *__s) ;
# 653 "/usr/include/stdio.h" 3 4
extern void flockfile (FILE *__stream) ;



extern int ftrylockfile (FILE *__stream) ;


extern void funlockfile (FILE *__stream) ;
# 677 "/usr/include/stdio.h" 3 4

# 17 "header.h" 2
# 1 "/usr/include/ctype.h" 1 3 4
# 30 "/usr/include/ctype.h" 3 4

# 41 "/usr/include/ctype.h" 3 4
# 1 "/usr/include/endian.h" 1 3 4
# 37 "/usr/include/endian.h" 3 4
# 1 "/usr/include/bits/endian.h" 1 3 4
# 38 "/usr/include/endian.h" 2 3 4
# 42 "/usr/include/ctype.h" 2 3 4






enum
{
  _ISupper = ((0) < 8 ? ((1 << (0)) << 8) : ((1 << (0)) >> 8)),
  _ISlower = ((1) < 8 ? ((1 << (1)) << 8) : ((1 << (1)) >> 8)),
  _ISalpha = ((2) < 8 ? ((1 << (2)) << 8) : ((1 << (2)) >> 8)),
  _ISdigit = ((3) < 8 ? ((1 << (3)) << 8) : ((1 << (3)) >> 8)),
  _ISxdigit = ((4) < 8 ? ((1 << (4)) << 8) : ((1 << (4)) >> 8)),
  _ISspace = ((5) < 8 ? ((1 << (5)) << 8) : ((1 << (5)) >> 8)),
  _ISprint = ((6) < 8 ? ((1 << (6)) << 8) : ((1 << (6)) >> 8)),
  _ISgraph = ((7) < 8 ? ((1 << (7)) << 8) : ((1 << (7)) >> 8)),
  _ISblank = ((8) < 8 ? ((1 << (8)) << 8) : ((1 << (8)) >> 8)),
  _IScntrl = ((9) < 8 ? ((1 << (9)) << 8) : ((1 << (9)) >> 8)),
  _ISpunct = ((10) < 8 ? ((1 << (10)) << 8) : ((1 << (10)) >> 8)),
  _ISalnum = ((11) < 8 ? ((1 << (11)) << 8) : ((1 << (11)) >> 8))
};
# 81 "/usr/include/ctype.h" 3 4
extern __const unsigned short int **__ctype_b_loc (void)
     __attribute__ ((__const));
extern __const __int32_t **__ctype_tolower_loc (void)
     __attribute__ ((__const));
extern __const __int32_t **__ctype_toupper_loc (void)
     __attribute__ ((__const));
# 96 "/usr/include/ctype.h" 3 4






extern int isalnum (int) ;
extern int isalpha (int) ;
extern int iscntrl (int) ;
extern int isdigit (int) ;
extern int islower (int) ;
extern int isgraph (int) ;
extern int isprint (int) ;
extern int ispunct (int) ;
extern int isspace (int) ;
extern int isupper (int) ;
extern int isxdigit (int) ;



extern int tolower (int __c) ;


extern int toupper (int __c) ;


# 142 "/usr/include/ctype.h" 3 4
extern int isascii (int __c) ;



extern int toascii (int __c) ;



extern int _toupper (int) ;
extern int _tolower (int) ;
# 323 "/usr/include/ctype.h" 3 4

# 18 "header.h" 2
# 1 "/usr/include/string.h" 1 3 4
# 28 "/usr/include/string.h" 3 4





# 1 "/home/dcrowe/llvm/cfrontend/x86/llvm-gcc/lib/gcc-lib/i686-pc-linux-gnu/3.4-llvm/include/stddef.h" 1 3 4
# 34 "/usr/include/string.h" 2 3 4




extern void *memcpy (void *__restrict __dest,
       __const void *__restrict __src, size_t __n) ;


extern void *memmove (void *__dest, __const void *__src, size_t __n)
     ;






extern void *memccpy (void *__restrict __dest, __const void *__restrict __src,
        int __c, size_t __n)
     ;





extern void *memset (void *__s, int __c, size_t __n) ;


extern int memcmp (__const void *__s1, __const void *__s2, size_t __n)
     __attribute__ ((__pure__));


extern void *memchr (__const void *__s, int __c, size_t __n)
      __attribute__ ((__pure__));

# 80 "/usr/include/string.h" 3 4


extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
     ;

extern char *strncpy (char *__restrict __dest,
        __const char *__restrict __src, size_t __n) ;


extern char *strcat (char *__restrict __dest, __const char *__restrict __src)
     ;

extern char *strncat (char *__restrict __dest, __const char *__restrict __src,
        size_t __n) ;


extern int strcmp (__const char *__s1, __const char *__s2)
     __attribute__ ((__pure__));

extern int strncmp (__const char *__s1, __const char *__s2, size_t __n)
     __attribute__ ((__pure__));


extern int strcoll (__const char *__s1, __const char *__s2)
     __attribute__ ((__pure__));

extern size_t strxfrm (char *__restrict __dest,
         __const char *__restrict __src, size_t __n) ;

# 126 "/usr/include/string.h" 3 4
extern char *strdup (__const char *__s) __attribute__ ((__malloc__));
# 160 "/usr/include/string.h" 3 4


extern char *strchr (__const char *__s, int __c) __attribute__ ((__pure__));

extern char *strrchr (__const char *__s, int __c) __attribute__ ((__pure__));











extern size_t strcspn (__const char *__s, __const char *__reject)
     __attribute__ ((__pure__));


extern size_t strspn (__const char *__s, __const char *__accept)
     __attribute__ ((__pure__));

extern char *strpbrk (__const char *__s, __const char *__accept)
     __attribute__ ((__pure__));

extern char *strstr (__const char *__haystack, __const char *__needle)
     __attribute__ ((__pure__));



extern char *strtok (char *__restrict __s, __const char *__restrict __delim)
     ;




extern char *__strtok_r (char *__restrict __s,
    __const char *__restrict __delim,
    char **__restrict __save_ptr) ;

extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,
         char **__restrict __save_ptr) ;
# 228 "/usr/include/string.h" 3 4


extern size_t strlen (__const char *__s) __attribute__ ((__pure__));

# 241 "/usr/include/string.h" 3 4


extern char *strerror (int __errnum) ;




extern char *strerror_r (int __errnum, char *__buf, size_t __buflen) ;




extern void __bzero (void *__s, size_t __n) ;



extern void bcopy (__const void *__src, void *__dest, size_t __n) ;


extern void bzero (void *__s, size_t __n) ;


extern int bcmp (__const void *__s1, __const void *__s2, size_t __n)
     __attribute__ ((__pure__));


extern char *index (__const char *__s, int __c) __attribute__ ((__pure__));


extern char *rindex (__const char *__s, int __c) __attribute__ ((__pure__));



extern int ffs (int __i) __attribute__ ((__const__));
# 287 "/usr/include/string.h" 3 4
extern int strcasecmp (__const char *__s1, __const char *__s2)
     __attribute__ ((__pure__));


extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
     __attribute__ ((__pure__));
# 309 "/usr/include/string.h" 3 4
extern char *strsep (char **__restrict __stringp,
       __const char *__restrict __delim) ;
# 379 "/usr/include/string.h" 3 4

# 19 "header.h" 2
# 1 "/usr/include/stdlib.h" 1 3 4
# 33 "/usr/include/stdlib.h" 3 4
# 1 "/home/dcrowe/llvm/cfrontend/x86/llvm-gcc/lib/gcc-lib/i686-pc-linux-gnu/3.4-llvm/include/stddef.h" 1 3 4
# 34 "/usr/include/stdlib.h" 2 3 4


# 93 "/usr/include/stdlib.h" 3 4


typedef struct
  {
    int quot;
    int rem;
  } div_t;



typedef struct
  {
    long int quot;
    long int rem;
  } ldiv_t;



# 137 "/usr/include/stdlib.h" 3 4
extern size_t __ctype_get_mb_cur_max (void) ;




extern double atof (__const char *__nptr) __attribute__ ((__pure__));

extern int atoi (__const char *__nptr) __attribute__ ((__pure__));

extern long int atol (__const char *__nptr) __attribute__ ((__pure__));





__extension__ extern long long int atoll (__const char *__nptr)
     __attribute__ ((__pure__));





extern double strtod (__const char *__restrict __nptr,
        char **__restrict __endptr) ;

# 174 "/usr/include/stdlib.h" 3 4


extern long int strtol (__const char *__restrict __nptr,
   char **__restrict __endptr, int __base) ;

extern unsigned long int strtoul (__const char *__restrict __nptr,
      char **__restrict __endptr, int __base)
     ;




__extension__
extern long long int strtoq (__const char *__restrict __nptr,
        char **__restrict __endptr, int __base) ;

__extension__
extern unsigned long long int strtouq (__const char *__restrict __nptr,
           char **__restrict __endptr, int __base)
     ;





__extension__
extern long long int strtoll (__const char *__restrict __nptr,
         char **__restrict __endptr, int __base) ;

__extension__
extern unsigned long long int strtoull (__const char *__restrict __nptr,
     char **__restrict __endptr, int __base)
     ;

# 264 "/usr/include/stdlib.h" 3 4
extern double __strtod_internal (__const char *__restrict __nptr,
     char **__restrict __endptr, int __group)
     ;
extern float __strtof_internal (__const char *__restrict __nptr,
    char **__restrict __endptr, int __group)
     ;
extern long double __strtold_internal (__const char *__restrict __nptr,
           char **__restrict __endptr,
           int __group) ;

extern long int __strtol_internal (__const char *__restrict __nptr,
       char **__restrict __endptr,
       int __base, int __group) ;



extern unsigned long int __strtoul_internal (__const char *__restrict __nptr,
          char **__restrict __endptr,
          int __base, int __group) ;




__extension__
extern long long int __strtoll_internal (__const char *__restrict __nptr,
      char **__restrict __endptr,
      int __base, int __group) ;



__extension__
extern unsigned long long int __strtoull_internal (__const char *
         __restrict __nptr,
         char **__restrict __endptr,
         int __base, int __group)
     ;
# 408 "/usr/include/stdlib.h" 3 4
extern char *l64a (long int __n) ;


extern long int a64l (__const char *__s) __attribute__ ((__pure__));


# 1 "/usr/include/sys/types.h" 1 3 4
# 29 "/usr/include/sys/types.h" 3 4






typedef __u_char u_char;
typedef __u_short u_short;
typedef __u_int u_int;
typedef __u_long u_long;
typedef __quad_t quad_t;
typedef __u_quad_t u_quad_t;
typedef __fsid_t fsid_t;




typedef __loff_t loff_t;



typedef __ino_t ino_t;
# 62 "/usr/include/sys/types.h" 3 4
typedef __dev_t dev_t;




typedef __gid_t gid_t;




typedef __mode_t mode_t;




typedef __nlink_t nlink_t;




typedef __uid_t uid_t;





typedef __off_t off_t;
# 100 "/usr/include/sys/types.h" 3 4
typedef __pid_t pid_t;




typedef __id_t id_t;




typedef __ssize_t ssize_t;





typedef __daddr_t daddr_t;
typedef __caddr_t caddr_t;





typedef __key_t key_t;
# 133 "/usr/include/sys/types.h" 3 4
# 1 "/usr/include/time.h" 1 3 4
# 74 "/usr/include/time.h" 3 4


typedef __time_t time_t;



# 92 "/usr/include/time.h" 3 4
typedef __clockid_t clockid_t;
# 104 "/usr/include/time.h" 3 4
typedef __timer_t timer_t;
# 134 "/usr/include/sys/types.h" 2 3 4
# 147 "/usr/include/sys/types.h" 3 4
# 1 "/home/dcrowe/llvm/cfrontend/x86/llvm-gcc/lib/gcc-lib/i686-pc-linux-gnu/3.4-llvm/include/stddef.h" 1 3 4
# 148 "/usr/include/sys/types.h" 2 3 4



typedef unsigned long int ulong;
typedef unsigned short int ushort;
typedef unsigned int uint;
# 191 "/usr/include/sys/types.h" 3 4
typedef int int8_t __attribute__ ((__mode__ (__QI__)));
typedef int int16_t __attribute__ ((__mode__ (__HI__)));
typedef int int32_t __attribute__ ((__mode__ (__SI__)));
typedef int int64_t __attribute__ ((__mode__ (__DI__)));


typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));
typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));

typedef int register_t __attribute__ ((__mode__ (__word__)));
# 216 "/usr/include/sys/types.h" 3 4
# 1 "/usr/include/sys/select.h" 1 3 4
# 31 "/usr/include/sys/select.h" 3 4
# 1 "/usr/include/bits/select.h" 1 3 4
# 32 "/usr/include/sys/select.h" 2 3 4


# 1 "/usr/include/bits/sigset.h" 1 3 4
# 23 "/usr/include/bits/sigset.h" 3 4
typedef int __sig_atomic_t;




typedef struct
  {
    unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
  } __sigset_t;
# 35 "/usr/include/sys/select.h" 2 3 4



typedef __sigset_t sigset_t;





# 1 "/usr/include/time.h" 1 3 4
# 118 "/usr/include/time.h" 3 4
struct timespec
  {
    __time_t tv_sec;
    long int tv_nsec;
  };
# 45 "/usr/include/sys/select.h" 2 3 4

# 1 "/usr/include/bits/time.h" 1 3 4
# 67 "/usr/include/bits/time.h" 3 4
struct timeval
  {
    __time_t tv_sec;
    __suseconds_t tv_usec;
  };
# 47 "/usr/include/sys/select.h" 2 3 4


typedef __suseconds_t suseconds_t;





typedef long int __fd_mask;
# 67 "/usr/include/sys/select.h" 3 4
typedef struct
  {






    __fd_mask __fds_bits[1024 / (8 * sizeof (__fd_mask))];


  } fd_set;






typedef __fd_mask fd_mask;
# 99 "/usr/include/sys/select.h" 3 4







extern int select (int __nfds, fd_set *__restrict __readfds,
     fd_set *__restrict __writefds,
     fd_set *__restrict __exceptfds,
     struct timeval *__restrict __timeout) ;
# 122 "/usr/include/sys/select.h" 3 4

# 217 "/usr/include/sys/types.h" 2 3 4


# 1 "/usr/include/sys/sysmacros.h" 1 3 4
# 220 "/usr/include/sys/types.h" 2 3 4
# 231 "/usr/include/sys/types.h" 3 4
typedef __blkcnt_t blkcnt_t;



typedef __fsblkcnt_t fsblkcnt_t;



typedef __fsfilcnt_t fsfilcnt_t;
# 266 "/usr/include/sys/types.h" 3 4
# 1 "/usr/include/bits/pthreadtypes.h" 1 3 4
# 23 "/usr/include/bits/pthreadtypes.h" 3 4
# 1 "/usr/include/bits/sched.h" 1 3 4
# 83 "/usr/include/bits/sched.h" 3 4
struct __sched_param
  {
    int __sched_priority;
  };
# 24 "/usr/include/bits/pthreadtypes.h" 2 3 4


struct _pthread_fastlock
{
  long int __status;
  int __spinlock;

};



typedef struct _pthread_descr_struct *_pthread_descr;





typedef struct __pthread_attr_s
{
  int __detachstate;
  int __schedpolicy;
  struct __sched_param __schedparam;
  int __inheritsched;
  int __scope;
  size_t __guardsize;
  int __stackaddr_set;
  void *__stackaddr;
  size_t __stacksize;
} pthread_attr_t;





__extension__ typedef long long __pthread_cond_align_t;




typedef struct
{
  struct _pthread_fastlock __c_lock;
  _pthread_descr __c_waiting;
  char __padding[48 - sizeof (struct _pthread_fastlock)
   - sizeof (_pthread_descr) - sizeof (__pthread_cond_align_t)];
  __pthread_cond_align_t __align;
} pthread_cond_t;



typedef struct
{
  int __dummy;
} pthread_condattr_t;


typedef unsigned int pthread_key_t;





typedef struct
{
  int __m_reserved;
  int __m_count;
  _pthread_descr __m_owner;
  int __m_kind;
  struct _pthread_fastlock __m_lock;
} pthread_mutex_t;



typedef struct
{
  int __mutexkind;
} pthread_mutexattr_t;



typedef int pthread_once_t;
# 150 "/usr/include/bits/pthreadtypes.h" 3 4
typedef unsigned long int pthread_t;
# 267 "/usr/include/sys/types.h" 2 3 4



# 415 "/usr/include/stdlib.h" 2 3 4






extern long int random (void) ;


extern void srandom (unsigned int __seed) ;





extern char *initstate (unsigned int __seed, char *__statebuf,
   size_t __statelen) ;



extern char *setstate (char *__statebuf) ;







struct random_data
  {
    int32_t *fptr;
    int32_t *rptr;
    int32_t *state;
    int rand_type;
    int rand_deg;
    int rand_sep;
    int32_t *end_ptr;
  };

extern int random_r (struct random_data *__restrict __buf,
       int32_t *__restrict __result) ;

extern int srandom_r (unsigned int __seed, struct random_data *__buf) ;

extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
   size_t __statelen,
   struct random_data *__restrict __buf) ;

extern int setstate_r (char *__restrict __statebuf,
         struct random_data *__restrict __buf) ;






extern int rand (void) ;

extern void srand (unsigned int __seed) ;




extern int rand_r (unsigned int *__seed) ;







extern double drand48 (void) ;
extern double erand48 (unsigned short int __xsubi[3]) ;


extern long int lrand48 (void) ;
extern long int nrand48 (unsigned short int __xsubi[3]) ;


extern long int mrand48 (void) ;
extern long int jrand48 (unsigned short int __xsubi[3]) ;


extern void srand48 (long int __seedval) ;
extern unsigned short int *seed48 (unsigned short int __seed16v[3]) ;
extern void lcong48 (unsigned short int __param[7]) ;





struct drand48_data
  {
    unsigned short int __x[3];
    unsigned short int __old_x[3];
    unsigned short int __c;
    unsigned short int __init;
    unsigned long long int __a;
  };


extern int drand48_r (struct drand48_data *__restrict __buffer,
        double *__restrict __result) ;
extern int erand48_r (unsigned short int __xsubi[3],
        struct drand48_data *__restrict __buffer,
        double *__restrict __result) ;


extern int lrand48_r (struct drand48_data *__restrict __buffer,
        long int *__restrict __result) ;
extern int nrand48_r (unsigned short int __xsubi[3],
        struct drand48_data *__restrict __buffer,
        long int *__restrict __result) ;


extern int mrand48_r (struct drand48_data *__restrict __buffer,
        long int *__restrict __result) ;
extern int jrand48_r (unsigned short int __xsubi[3],
        struct drand48_data *__restrict __buffer,
        long int *__restrict __result) ;


extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
     ;

extern int seed48_r (unsigned short int __seed16v[3],
       struct drand48_data *__buffer) ;

extern int lcong48_r (unsigned short int __param[7],
        struct drand48_data *__buffer) ;









extern void *malloc (size_t __size) __attribute__ ((__malloc__));

extern void *calloc (size_t __nmemb, size_t __size)
     __attribute__ ((__malloc__));







extern void *realloc (void *__ptr, size_t __size) __attribute__ ((__malloc__));

extern void free (void *__ptr) ;




extern void cfree (void *__ptr) ;



# 1 "/usr/include/alloca.h" 1 3 4
# 25 "/usr/include/alloca.h" 3 4
# 1 "/home/dcrowe/llvm/cfrontend/x86/llvm-gcc/lib/gcc-lib/i686-pc-linux-gnu/3.4-llvm/include/stddef.h" 1 3 4
# 26 "/usr/include/alloca.h" 2 3 4







extern void *alloca (size_t __size) ;






# 577 "/usr/include/stdlib.h" 2 3 4




extern void *valloc (size_t __size) __attribute__ ((__malloc__));
# 590 "/usr/include/stdlib.h" 3 4


extern void abort (void) __attribute__ ((__noreturn__));



extern int atexit (void (*__func) (void)) ;





extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
     ;






extern void exit (int __status) __attribute__ ((__noreturn__));

# 622 "/usr/include/stdlib.h" 3 4


extern char *getenv (__const char *__name) ;




extern char *__secure_getenv (__const char *__name) ;





extern int putenv (char *__string) ;





extern int setenv (__const char *__name, __const char *__value, int __replace)
     ;


extern int unsetenv (__const char *__name) ;






extern int clearenv (void) ;
# 661 "/usr/include/stdlib.h" 3 4
extern char *mktemp (char *__template) ;







extern int mkstemp (char *__template) ;
# 688 "/usr/include/stdlib.h" 3 4
extern char *mkdtemp (char *__template) ;





extern int system (__const char *__command) ;

# 712 "/usr/include/stdlib.h" 3 4
extern char *realpath (__const char *__restrict __name,
         char *__restrict __resolved) ;






typedef int (*__compar_fn_t) (__const void *, __const void *);









extern void *bsearch (__const void *__key, __const void *__base,
        size_t __nmemb, size_t __size, __compar_fn_t __compar);



extern void qsort (void *__base, size_t __nmemb, size_t __size,
     __compar_fn_t __compar);



extern int abs (int __x) __attribute__ ((__const__));
extern long int labs (long int __x) __attribute__ ((__const__));












extern div_t div (int __numer, int __denom)
     __attribute__ ((__const__));
extern ldiv_t ldiv (long int __numer, long int __denom)
     __attribute__ ((__const__));

# 776 "/usr/include/stdlib.h" 3 4
extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt,
     int *__restrict __sign) ;




extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
     int *__restrict __sign) ;




extern char *gcvt (double __value, int __ndigit, char *__buf) ;




extern char *qecvt (long double __value, int __ndigit,
      int *__restrict __decpt, int *__restrict __sign) ;
extern char *qfcvt (long double __value, int __ndigit,
      int *__restrict __decpt, int *__restrict __sign) ;
extern char *qgcvt (long double __value, int __ndigit, char *__buf) ;




extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
     int *__restrict __sign, char *__restrict __buf,
     size_t __len) ;
extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
     int *__restrict __sign, char *__restrict __buf,
     size_t __len) ;

extern int qecvt_r (long double __value, int __ndigit,
      int *__restrict __decpt, int *__restrict __sign,
      char *__restrict __buf, size_t __len) ;
extern int qfcvt_r (long double __value, int __ndigit,
      int *__restrict __decpt, int *__restrict __sign,
      char *__restrict __buf, size_t __len) ;







extern int mblen (__const char *__s, size_t __n) ;


extern int mbtowc (wchar_t *__restrict __pwc,
     __const char *__restrict __s, size_t __n) ;


extern int wctomb (char *__s, wchar_t __wchar) ;



extern size_t mbstowcs (wchar_t *__restrict __pwcs,
   __const char *__restrict __s, size_t __n) ;

extern size_t wcstombs (char *__restrict __s,
   __const wchar_t *__restrict __pwcs, size_t __n)
     ;








extern int rpmatch (__const char *__response) ;
# 908 "/usr/include/stdlib.h" 3 4
extern int getloadavg (double __loadavg[], int __nelem) ;






# 20 "header.h" 2






int strncasecmp(const char *s1, const char *s2, size_t);
void mark_allocation_point(void);
void reset_allocation_point(void);
void initialize_memory(void);
# 172 "header.h"
typedef struct Connector_struct Connector;
struct Connector_struct{
    short label;
    short word;


    char priority;
    char multi;
    Connector * next;
    char * string;
};

typedef struct Disjunct_struct Disjunct;
struct Disjunct_struct {
    Disjunct *next;
    short cost;
    char marked;
    char * string;
    Connector *left, *right;
};

typedef struct Link_struct Link;
struct Link_struct {
    int l, r;
    Connector * lc, * rc;
    char * name;
};

typedef struct Match_node_struct Match_node;
struct Match_node_struct {
    Match_node * next;
    Disjunct * d;
};

typedef struct Exp_struct Exp;
typedef struct X_node_struct X_node;
struct X_node_struct {
    char * string;
    Exp * exp;
    X_node *next;
};

typedef struct Word_struct Word;
struct Word_struct {
    char string[60];
    X_node * x;
    Disjunct * d;
};






typedef struct E_list_struct E_list;

struct Exp_struct {
    char type;
    unsigned char cost;

    char dir;
    char multi;
    union {
 E_list * l;
 char * string;
    }u;
};

struct E_list_struct {
    E_list * next;
    Exp * e;
};
# 252 "header.h"
typedef struct Word_file_struct Word_file;
struct Word_file_struct {
    char file[60];
    int changed;
    Word_file * next;
};





typedef struct Dict_node_struct Dict_node;
struct Dict_node_struct {
    char * string;
    Word_file * file;
    Exp * exp;
    Dict_node *left, *right;
};


typedef struct Violation_list_struct Violation_list;
struct Violation_list_struct {
    Violation_list * next;
    char * string;
};

typedef struct D_type_list_struct D_type_list;
struct D_type_list_struct {
    D_type_list * next;
    int type;
};

typedef struct PP_node_struct PP_node;
struct PP_node_struct {
    D_type_list ** d_type_array;
    Violation_list * v;
};




typedef struct Linkage_info_struct Linkage_info;
struct Linkage_info_struct {
    int index;
    short N_violations, null_cost, disjunct_cost, and_cost, link_cost;
};

typedef struct List_o_links_struct List_o_links;
struct List_o_links_struct{
    int link;
    int word;
    int dir;
    List_o_links * next;
};


extern int N_dict;
extern Dict_node * dict_root;

extern int finished_cuts;
extern Word sentence[];
extern int N_null;
extern int N_words;
extern int left_wall_defined;
extern int right_wall_defined;
extern int postprocess_defined;
extern int andable_defined;
extern int unknown_word_defined;
extern int capitalized_word_defined;
extern int verbosity;
extern int maxlinklength;
extern int null_links;
extern int screen_width;
extern int display_short;
extern int display_on;
extern int display_links;
extern int display_postscript;
extern int display_word_subscripts;
extern int display_link_subscripts;
extern int display_bad;
extern int display_multiple;
extern int display_fat;
extern int display_walls;
extern int echo_on;
extern int www_mode;
extern int just_one;


extern int parse_cost;
extern int mark_cost;
extern int N_in_table;
extern int N_hash_lookups;
extern int work_in_hash_lookups;
extern int space_in_use;
extern int max_space_in_use;


extern Link link_array[];
extern Link pp_link_array[];
extern int N_links;
extern char * chosen_words[];
extern Disjunct * chosen_disjuncts[];
extern char has_fat_down[];
extern char is_conjunction[];
extern char * deletable[];





extern unsigned int randtable[256];
extern int line_number;






void read_dictionary(void);
void print_dictionary_data(void);
void print_dictionary_words(void);
void print_expression(Exp *);
X_node * build_word_expressions(char *);
int maxcost_of_sentence(void);
void build_sentence_disjuncts(int cost_cutoff);
Disjunct * build_disjuncts_for_dict_node(Dict_node *);
void open_dictionary(char *);
int boolean_dictionary_lookup(char *);
int boolean_abridged_lookup(char *);
Dict_node * dictionary_lookup(char *);

Dict_node * abridged_lookup(char *);
int delete_dictionary_words(char *);
int table_lookup(int, int, Connector *, Connector *, int);
void print_disjunct_counts(void);
void print_links_graphically(FILE *fp);
void print_links(FILE *fp);
void extract_links(int index, int cost);
PP_node * post_process(void);
int match(Connector *, Connector *);
int count(int lw, int rw, Connector *le, Connector *re, int cost);
void * xalloc(int);
void xfree(char *, int);
void prune(void);
void power_prune(int);
int prune_match(Connector *, Connector *);
void free_disjuncts(Disjunct *);
void free_X_nodes(X_node *);
void free_connectors(Connector *);
void init_randtable(void);
void init_table(void);
void free_table(void);
Dict_node * read_word_file(Dict_node *, char *);
int files_need_saving(void);
void save_files(void);
Dict_node * insert_dict(Dict_node *, Dict_node *);
void error(char *);
void insert_idiom(Dict_node *);
int contains_underbar(char *);
void print_disjunct_list(Disjunct *);
int is_idiom_word(char *);
Disjunct* eliminate_duplicate_disjuncts(Disjunct * );
void print_sentence(FILE *fp, int w);
void print_all_word_disjuncts(void);
Disjunct * copy_disjunct(Disjunct * );
Connector * copy_connectors(Connector *);
void free_strings(void);
void free_this_string_later(char *, int);
void free_lookup_list(void);

void build_AND_tables(void);
Disjunct * build_AND_disjunct_list(char *);
void free_AND_tables(void);
Disjunct * catenate_disjuncts(Disjunct *, Disjunct *);
X_node * catenate_X_nodes(X_node *, X_node *);
Disjunct * build_COMMA_disjunct_list(void);
Disjunct * explode_disjunct_list(Disjunct *);
void print_AND_statistics(void);
void init_fast_matcher(void);
void free_fast_matcher(void);

Match_node * form_match_list(int, Connector *, int, Connector *, int);
void put_match_list(Match_node *);
int next_power_of_two_up(int);
void init_andable_hash_table(void);
int upper_case_match(char *, char *);
void print_a_link(FILE *fp, int link);
char * intersect_strings(char *, char *);
void construct_comma(void);
void construct_either(void);
void construct_neither(void);
void construct_notonlybut(void);
void construct_both(void);
Disjunct * glom_wall_connector(Disjunct *);
void build_conjunction_tables(void);
int sentence_contains(char *);
int parse(int mincost);
void free_Exp(Exp *);
void free_E_list(E_list *);
Exp * copy_Exp(Exp *);
void expression_prune(void);
int size_of_expression(Exp *);
void construct_wall_expressions(void);
void print_expression_sizes(void);
Linkage_info analyze_fat_linkage(int);
Linkage_info analyze_thin_linkage(int);
void free_PP_node(PP_node *);
void compute_chosen_words(void);
int is_canonical_linkage(void);
void compute_pp_link_array_connectors(void);
int set_has_fat_down(void);
void left_print_string(FILE* fp, char *, char *);
void conjunction_prune(void);
# 11 "main.c" 2
# 130 "main.c"
Word sentence[250];

int N_words;

int left_wall_defined;
int right_wall_defined;
int postprocess_defined;
int andable_defined;
int unknown_word_defined;
int capitalized_word_defined;
int maxlinklength = 250;
int null_link_search = 1;
int use_unknown_word = 1;
int verbosity = 0;
int screen_width = 79;
int display_short = 1;
int display_on = 1;
int display_links = 0;
int display_bad = 0;
int display_fat = 0;
int display_multiple = 1;
int display_postscript = 0;
int display_word_subscripts = 1;
int display_link_subscripts = 1;

int display_walls = 0;
int echo_on = 0;
int www_mode = 0;
int just_one = 0;


int linkage_count_limit = 5000;
int word_count_limit = 250;

int null_links = 1;
char is_conjunction[250];
char * deletable[250];



int parse_cost;
int mark_cost;
int N_in_table;
int N_hash_lookups;
int work_in_hash_lookups;
double cumulative_time;

int issue_sentence_word(char * s) {


    if (*s == '\0') return 1;
    if (strlen(s) >= 60) {
 printf("The word \"%s\" is too long.\n", s);
 printf("A word can have a maximum of %d characters.\n", 60 -1);
 return 0;
    }
    if (N_words == 250) {
 printf("The sentence has too many words.\n");
 return 0;
    }
    strcpy(sentence[N_words].string, s);
    N_words++;
    return 1;
}
# 246 "main.c"
char * strip_left[] = {"(", "$", ((void *)0)};
char * strip_right[] = {")", "%", ",", ".", ":", ";", "?", "!", "'", "'s", ((void *)0)};



int separate_word(char * w, char *wend, int is_first_word) {





    int i, len, n_stripped;
    int stripped[10];
    char word[60 +1];

    for (;;) {
 for (i=0; strip_left[i] != ((void *)0); i++) {
     if (strncmp(w, strip_left[i], strlen(strip_left[i])) == 0) {
  if (!issue_sentence_word(strip_left[i])) return 0;
  w += strlen(strip_left[i]);
  break;
     }
 }
 if (strip_left[i] == ((void *)0)) break;
    }

    for (n_stripped = 0; n_stripped < 10; n_stripped++) {
 strncpy(word, w, wend-w);
 word[wend-w] = '\0';
 if (wend == w) break;

 if (boolean_dictionary_lookup(word)) break;
 if (is_first_word && ((*__ctype_b_loc ())[(int) ((word[0]))] & (unsigned short int) _ISupper)) {
     word[0] = tolower(word[0]);
     if (boolean_dictionary_lookup(word)) {
  word[0] = toupper(word[0]);
  break;
     }
     word[0] = toupper(word[0]);
 }
 for (i=0; strip_right[i] != ((void *)0); i++) {
     len = strlen(strip_right[i]);
     if ((wend-w) < len) continue;
     if (strncmp(wend-len, strip_right[i], len) == 0) {
  stripped[n_stripped] = i;
  wend -= len;
  break;
     }
 }
 if (strip_right[i] == ((void *)0)) break;
    }



    if (n_stripped == 10) {
 printf("\"%s\" is followed by too many punctuation marks.\n", word);
 return 0;
    }

    if (!issue_sentence_word(word)) return 0;
    for (i=n_stripped-1; i>=0; i--) {
 if (!issue_sentence_word(strip_right[stripped[i]])) return 0;
    }
    return 1;
}

int separate_sentence(char * s) {






    char *t;
    int is_first;

    N_words = 0;

    if (left_wall_defined) if (!issue_sentence_word(("LEFT-WALL"))) return 0;

    is_first = 1;
    for(;;) {
 while(((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISspace) || (*s == '\"')) s++;
 if (*s == '\0') break;
 for (t=s; !((((*__ctype_b_loc ())[(int) ((*t))] & (unsigned short int) _ISspace) || (*t == '\"')) || *t=='\0'); t++);
 if (!separate_word(s, t, is_first)) return 0;
 is_first = 0;
 s = t;
 if (*s == '\0') break;
    }

    if (right_wall_defined) if (!issue_sentence_word(("RIGHT-WALL"))) return 0;

    return (N_words > left_wall_defined + right_wall_defined);
}


int isnumber(char * s) {
    if (!((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISdigit)) return 0;
    for (; *s != '\0'; s++) {
 if ((!((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISdigit)) && (*s != '.') && (*s != ',')) {
     return 0;
 }
    }
    return 1;
}

int ishyphenated(char * s) {




    int hyp, nonalpha;
    hyp = nonalpha = 0;
    if (*s == '-') return 0;
    while (*s != '\0') {
 if (!((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISalpha) && !((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISdigit) && (*s!='.') && (*s!=',')
     && (*s!='-')) return 0;
 if (*s == '-') hyp++;
 s++;
    }
    return ((*(s-1)!='-') && (hyp>0));
}
# 378 "main.c"
void free_sentence_disjuncts(void) {
    int i;
    for (i=0; i<N_words; i++) {
 free_disjuncts(sentence[i].d);
    }
}

void free_sentence_expressions(void) {
    int i;
    for (i=0; i<N_words; i++) {
 free_X_nodes(sentence[i].x);
    }
}

int special_string(int i, char * s) {
    X_node * e;
    if (boolean_dictionary_lookup(s)) {
 sentence[i].x = build_word_expressions(s);
 for (e = sentence[i].x; e != ((void *)0); e = e->next) {
     e->string = sentence[i].string;
 }
 return 1;
    } else {
 printf("To process this sentence your dictionary ");
 printf("needs the word \"%s\".\n", s);
 return 0;
    }
}

void handle_unknown_word(int i, char * s) {





    char *t;
    X_node *d;
    char str[60 +1];

    sentence[i].x = build_word_expressions(("UNKNOWN-WORD"));
    if (sentence[i].x == ((void *)0)) { if (!(0)) { printf("Assertion failed: %s\n", "UNKNOWN_WORD should have been there"); exit(1); } };

    for (d = sentence[i].x; d != ((void *)0); d = d->next) {
 t = strchr(d->string, '.');
 if (t != ((void *)0)) {
     sprintf(str, "%.50s[?].%.5s", s, t+1);
 } else {
     sprintf(str, "%.50s[?]", s);
 }
 t = (char *) xalloc(strlen(str)+1);
 free_this_string_later(t, strlen(str)+1);
 strcpy(t,str);
 d->string = t;
    }
}

int build_sentence_expressions(void) {
# 452 "main.c"
    int i;
    int first_word;
    char * s, *t;
    X_node * e;
    if (left_wall_defined) {
 first_word = 1;
    } else {
 first_word = 0;
    }


    for (i=0; i<N_words; i++) {
 s = sentence[i].string;
 if (boolean_dictionary_lookup(s)) {
     sentence[i].x = build_word_expressions(s);
 } else if (((*__ctype_b_loc ())[(int) ((s[0]))] & (unsigned short int) _ISupper) && capitalized_word_defined) {
     if (!special_string(i,("CAPITALIZED-WORDS"))) return 0;
 } else if (isnumber(s)){


     if (!special_string(i,("NUMBERS"))) return 0;
 } else if (ishyphenated(s)) {

     if (!special_string(i,("HYPHENATED-WORDS"))) return 0;
 } else if (unknown_word_defined && use_unknown_word) {

     handle_unknown_word(i, s);
 } else {


     { if (!(0)) { printf("Assertion failed: %s\n", "I should have found that word."); exit(1); } };
 }
    }



    s = sentence[first_word].string;
    if (((*__ctype_b_loc ())[(int) ((s[0]))] & (unsigned short int) _ISupper)) {
 t = (char *) xalloc(strlen(s)+1);
 free_this_string_later(t, strlen(s)+1);
 strcpy(t,s);
 t[0] = tolower(t[0]);
 if (boolean_dictionary_lookup(t)) {
     if (boolean_dictionary_lookup(s)) {
  e = build_word_expressions(t);
  sentence[first_word].x = catenate_X_nodes(sentence[first_word].x, e);
     } else {
  s[0] = tolower(s[0]);
  e = build_word_expressions(s);
  free_X_nodes(sentence[first_word].x);
  sentence[first_word].x = e;
     }
 }
    }
# 533 "main.c"
    return 1;
}



void print_statistics(void) {
    printf("\n");
    printf("%d parse cost\n", parse_cost);
    printf("%d mark cost\n", mark_cost);
    printf("%d in hash table\n", N_in_table);
    printf("%d hash lookups\n", N_hash_lookups);
    printf("%f cost per lookup\n",(float)work_in_hash_lookups/N_hash_lookups);




}

void clean_up_string(char * s) {

    char * x, * y;
    y = x = s;
    while(*x != '\0') {
 if (!((*__ctype_b_loc ())[(int) ((*x))] & (unsigned short int) _ISspace)) {
     *y = *x; x++; y++;
 } else {
     x++;
 }
    }
    *y = '\0';
}

struct {char * s; int * p; int isboolean; char * str;} user_variable[] = {
    {"verbosity", &verbosity, 0, "Level of detail to give about the computation"},
    {"width", &screen_width, 0, "The width of your screen"},
    {"limit", &linkage_count_limit, 0, "The maximum number of linkages processed"},


    {"graphics", &display_on, 1, "Graphical link display"},
    {"multiple", &display_multiple, 1, "Expansion of fat (conjunctive) linkages"},
    {"short", &display_short, 1, "Reduced height display"},
    {"postscript", &display_postscript, 1, "Generating of postscript data"},
    {"links", &display_links, 1, "Showing of complete link data"},
    {"bad", &display_bad, 1, "Showing of linkages failing postprocessing"},
    {"fat", &display_fat, 1, "Showing of fat (conjunctive) linkages"},
    {"lsubscripts", &display_link_subscripts, 1, "Showing of complete link labels"},
    {"wsubscripts", &display_word_subscripts, 1, "Showing of word subscripts"},
    {"walls", &display_walls, 1, "Always show the walls"},
    {"null", &null_link_search, 1, "Null link search"},
    {"unknown", &use_unknown_word, 1, "Using of the \"unknown word\" definition"},
    {"echo", &echo_on, 1, "Echoing of input sentence"},
    {"www", &www_mode, 1, "Suppression of prompt"},
    {"justone", &just_one, 1, "Displaying of just one linkage"},
    {"", ((void *)0), 0, ""}
};

struct {char * s; char * str;} user_command[] = {
    {"quit", "Exit the system"},
    {"save", "Save your changes to the dictionary"},
    {"variables", "List user-settable variables and their functions"},
    {"help", "List the commands and what they do"},
    {((void *)0), ((void *)0)}
};

int is_numerical_rhs(char *s) {




    if (*s=='+' || *s == '-') s++;
    do {
 if (!((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISdigit)) return 0;
 s++;
    } while (*s != '\0');
    return 1;
}

void massage_variables(int j) {



    int i;
    for (i=0; user_variable[i].p != ((void *)0); i++) {
 if (user_variable[i].isboolean) {
     (*(user_variable[i].p)) = !!(*(user_variable[i].p));
 }
    }
    if (!display_on && (display_multiple || display_bad || display_fat)) {
 if (user_variable[j].p == &(display_on)) {
     display_multiple = display_bad = display_fat = 0;
 } else {
     display_on = 1;
 }
    } else if (display_on && !(display_multiple || display_bad || display_fat)) {
 if (user_variable[j].p == &(display_on)) {
     display_multiple = 1;
 } else {
     display_on = 0;
 }
    }
}

void special_command(char * line) {
    char *x, *y, *s;
    char myline[1000];
    int i, count, j, k;

    strncpy(myline, line, sizeof(myline));
    myline[sizeof(myline)-1] = '\0';
    clean_up_string(myline);
    s = myline;
    s++;






    j = k = -1;
    count = 0;
    for (i=0; user_variable[i].p != ((void *)0); i++) {
 if (user_variable[i].isboolean && strncasecmp(s, user_variable[i].s, strlen(s)) == 0) {
     count++;
     j = i;
 }
    }
    for (i=0; user_command[i].s != ((void *)0); i++) {
 if (strncasecmp(s, user_command[i].s, strlen(s)) == 0) {
     count++;
     k = i;
 }
    }

    if (count > 1) {
 printf("Ambiguous command.  Type \"!help\" or \"!variables\"\n");
 return;
    } else if (count == 1) {
 if (j >= 0) {
     *(user_variable[j].p) = !(*(user_variable[j].p));
     printf("%s turned %s.\n", user_variable[j].str, (*(user_variable[j].p))?"on":"off");
     massage_variables(j);
     return;
 } else {
     strcpy(s, user_command[k].s);
 }
    }

    if (strcmp(s,"quit") == 0) {
 if (!files_need_saving()) {
     exit(1);
 } else {
     printf("You have changed some files and not saved them.\n");
     printf("Either save your files with \"!save\" and then quit,\n");
     printf("or get out without saving your files with control-C.\n");
 }
 return;
    }

    if (strncmp(s, "mark", 4) == 0) {
 printf("mark: %s", line+6);
 fflush(stdout);
 return;
    }

    if (strcmp(s,"save") == 0) {
 if (files_need_saving()) {
     save_files();
 } else {
     printf("No changes to be saved.\n");
 }
 return;
    }
    if (strcmp(s, "variables")==0) {
 printf(" Variable     Controls                                      Value\n");
 printf(" --------     --------                                      -----\n");
 for (i=0; user_variable[i].p != ((void *)0); i++) {
     printf(" ");
     left_print_string(stdout, user_variable[i].s, "             ");
     left_print_string(stdout, user_variable[i].str, "                                              ");
     printf("%5d", *user_variable[i].p);
     if (user_variable[i].isboolean) {
  if (*user_variable[i].p) printf(" (On)"); else printf(" (Off)");
     }
     printf("\n");
 }
 printf("\n");
 printf("Toggle a boolean variable as in \"!links\", set a variable as in \"!width=100\".\n");
 return;
    }
    if (strcmp(s, "help")==0) {
 printf("Special commands always begin with \"!\".  Command and variable names\n");
 printf("can be abbreviated.  Here is a list of the commands:\n\n");
 for (i=0; user_command[i].s != ((void *)0); i++) {
     printf(" !");
     left_print_string(stdout, user_command[i].s, "                  ");
     left_print_string(stdout, user_command[i].str, "                                                    ");
     printf("\n");
 }
 printf("\n");
 printf(" !!<string>         Print all the dictionary words matching <string>.\n");
 printf("                    Also print the number of disjuncts of each.\n");
 printf("\n");
 printf(" !-<string>         Delete all the dictionary words matching <string>.\n");
 printf("\n");
 printf(" !<string>=<word>   This indicates that a new word (<string>) is to be\n");
 printf("                    added to the dictionary.  Its definition will be the\n");
 printf("                    same as that of <word>, and, if appropriate, it will\n");
 printf("                    be added to the word file of <word>.\n");
 printf("\n");
 printf(" !<var>             Toggle the specified boolean variable.\n");
 printf("\n");
 printf(" !<var>=<val>       Assign that value to that variable.\n");
 return;
    }

    if (s[0] == '!') {

 Dict_node * dn;
 Disjunct * d1, * d2;
 int len;

 if ((dn=dictionary_lookup(s+1)) == ((void *)0)) {
     printf("    \"%s\" matches nothing in the dictionary.\n", s+1);
     return;
 }
 printf("Matches:\n");
 for (;dn != ((void *)0); dn = dn->right) {
     len=0;
     d1 = build_disjuncts_for_dict_node(dn);
     for(d2 = d1 ; d2!=((void *)0); d2 = d2->next){
  len++;
     }
     free_disjuncts(d1);
     printf("          ");
     left_print_string(stdout, dn->string, "                  ");
     printf(" %5d  ", len);
     if (dn->file != ((void *)0)) {
  printf("<%s>", dn->file->file);
     }
     printf("\n");
 }
 return;
    }
    if (*s == '-') {

 Dict_node * dn, *dn1;
 int count;
 dn=abridged_lookup(s+1);
 count = 0;
 if (dn == ((void *)0)) {
     printf("    \"%s\" matches nothing in the dictionary.\n", s+1);
     return;
 }
# 803 "main.c"
        for (dn1 = dn; dn1 != ((void *)0); dn1 = dn1->right) {
     if (dn1->file == ((void *)0)) count++;
 }
 if (count != 0) {
     printf("Note: \"%s\" ", s+1);
     printf("matches the following words in the main dictionary:\n");
     for (dn1 = dn; dn1 != ((void *)0); dn1 = dn1->right) {
  if (dn1->file == ((void *)0)) printf(" %s ", dn1->string);
     }
     printf("\n");
 }
 printf("Deleting:\n");
 for (dn1 = dn; dn1 != ((void *)0); dn1 = dn1->right) {
     printf(" %s ", dn1->string);
 }

 if (!delete_dictionary_words(s+1)) {
     { if (!(0)) { printf("Assertion failed: %s\n", "Attempt to delete a word not in the dictonary."); exit(1); } };
 }
 printf("\n");
 return;
    }

    for (x=s; (*x != '=') && (*x != '\0') ; x++)
      ;
    if (*x == '=') {
 Dict_node * dn, * dn_new;
 *x = '\0';
 y = x+1;
 x = s;


 if (is_numerical_rhs(y)) {
     for (i=0; user_variable[i].p != ((void *)0); i++) {
  if (strcmp(x, user_variable[i].s) == 0) break;
     }
     if (user_variable[i].p == ((void *)0)) {
  printf("There is no user variable called \"%s\".\n", x);
     } else {
  *(user_variable[i].p) = atoi(y);
  printf("%s set to %d\n", x, atoi(y));
  massage_variables(i);
     }
     return;
 }
 if (is_idiom_word(x) || is_idiom_word(y)) {
     printf("    words ending \".Ix\" (x a number) ");
     printf("are reserved for idioms\n");
     return;
 }
 if ((dn=abridged_lookup(x)) != ((void *)0)) {
     printf("    \"%s\" matches words already in the dictionary:\n",s);
     for (;dn != ((void *)0); dn = dn->right) {
  printf("%s ", dn->string);
     }
     printf("\n");
     return;
 }
 if ((dn=abridged_lookup(y)) == ((void *)0)) {
     printf("    \"%s\" is not in the dictionary.\n", y);
     return;
 }
 if ((dn->right != ((void *)0)) || (strcmp(y,dn->string) != 0)) {
     printf("    Please be more precise.  \"%s\" matches:\n", y);
     for (;dn != ((void *)0); dn = dn->right) {
  printf("%s ", dn->string);
     }
     printf("\n");
     return;
 }
 if (dn->file == ((void *)0)) {
     printf("    \"%s\" is in the dictionary but not in a file.\n",y);
     printf("    This word will not be saved.\n");
 }
 dn_new = (Dict_node *) xalloc(sizeof(Dict_node));
 dn_new->string = (char *) xalloc(strlen(x)+1);
 strcpy(dn_new->string, x);
 dn_new->left = dn_new->right = ((void *)0);
 dn_new->file = dn->file;
 dn_new->exp = dn->exp;
 dict_root = insert_dict(dict_root, dn_new);
 printf("    \"%s\" added to the dictionary.\n", x);
 N_dict++;
 if (dn->file != ((void *)0)) dn->file->changed = 1;
 return;
    }
    printf("Try \"!help\".\n");
}

int sentence_in_dictionary(void){
    int w, ok_so_far;
    char * s;

    ok_so_far = 1;
    for (w=0; w<N_words; w++) {
 s = sentence[w].string;
 if (!boolean_dictionary_lookup(s) &&
     !(((*__ctype_b_loc ())[(int) ((s[0]))] & (unsigned short int) _ISupper) && (capitalized_word_defined)) &&
     !ishyphenated(s) &&
     !isnumber(s)) {
     if (ok_so_far) {
  printf("The following words are not in the dictionary:");
  ok_so_far = 0;
     }
     printf(" \"%s\"", sentence[w].string);
 }
    }
    if (!ok_so_far) printf("\n");
    return ok_so_far;
}

int sentence_contains(char * s) {

    int w;
    for (w=0; w<N_words; w++) {
 if (strcmp(sentence[w].string, s) == 0) return 1;
    }
    return 0;
}

void set_is_conjunction(void) {
    int w;
    char * s;
    for (w=0; w<N_words; w++) {
 s = sentence[w].string;
 is_conjunction[w] = ((strcmp(s, "and")==0) || (strcmp(s, "or" )==0) ||
        (strcmp(s, "but")==0) || (strcmp(s, "nor")==0));
    }
}

int sentence_contains_conjunction(void) {



    int w;
    for (w=0; w<N_words; w++) {
 if (is_conjunction[w]) return 1;
    }
    return 0;
}

int conj_in_range(int lw, int rw) {

    for (;lw <= rw; lw++) {
 if (is_conjunction[lw]) return 1;
    }
    return 0;
}
# 968 "main.c"
void build_deletable(void) {
# 981 "main.c"
    int i,j,k;
    for (i=0; i<N_words; i++) {
 deletable[i] = (char *) xalloc(N_words+1);
 for (j=0; j<=( ((i+maxlinklength) < (N_words)) ? (i+maxlinklength) : (N_words)); j++) {
     if (null_links) {
  deletable[i][j] = 1;
     } else if (j == i+1) {
  deletable[i][j] = 1;
     } else if ((j>i+2)&&(is_conjunction[i+1] || is_conjunction[j-1] ||
                                (strcmp(",",sentence[i+1].string)==0 && conj_in_range(i+2,j-1)) ||
                          (strcmp(",",sentence[j-1].string)==0 && conj_in_range(j,N_words-1)))){
  deletable[i][j] = 1;
     } else if (j > i) {
  for (k=i+1; k<j; k++) {
      if ((strcmp("either", sentence[k].string) == 0) ||
   (strcmp("neither", sentence[k].string) == 0) ||
   (strcmp("both", sentence[k].string) == 0) ||
   (strcmp("not", sentence[k].string) == 0)) continue;
      if ((strcmp("only", sentence[k].string)==0) && (k > i+1) &&
                                   (strcmp("not", sentence[k-1].string)==0)) continue;
      break;
  }
  deletable[i][j] = (k==j);
     } else {
  deletable[i][j] = 0;
     }
 }
    }
}

void free_deletable(void) {
    int w;
    for (w=0; w<N_words; w++) {
 xfree((char *)deletable[w],N_words+1);
    }
}

void install_fat_connectors(void) {


    int i;
    for (i=0; i<N_words; i++) {
 if (is_conjunction[i]) {
     sentence[i].d = catenate_disjuncts(sentence[i].d,
          build_AND_disjunct_list(sentence[i].string));
 } else {
     sentence[i].d = catenate_disjuncts(sentence[i].d,
          explode_disjunct_list(sentence[i].d));
     if (strcmp(sentence[i].string, ",") == 0) {
  sentence[i].d = catenate_disjuncts(sentence[i].d,
            build_COMMA_disjunct_list());
     }
 }
    }
}

int compare_parse(Linkage_info * p1, Linkage_info * p2) {

    if (p1->N_violations != p2->N_violations) {
 return (p1->N_violations - p2->N_violations);
    } else if (p1->disjunct_cost != p2->disjunct_cost) {
 return (p1->disjunct_cost - p2->disjunct_cost);
    } else if (p1->and_cost != p2->and_cost) {
 return (p1->and_cost - p2->and_cost);
    } else {
 return (p1->link_cost - p2->link_cost);
    }
}
# 1094 "main.c"
void clear_time(void) {}
void print_time(char * s) {
    if (verbosity > 1) {
 printf("++++%s\n", s);
    }
}
void print_total_time(void) {}
# 1118 "main.c"
void first_prepare_to_parse(void) {
    if (echo_on) print_sentence(stdout, 2);
    if (verbosity > 2) {
 printf("Raw expression sizes:\n");
 print_expression_sizes();
    }
    expression_prune();
    print_time("Done expression pruning");
}

void prepare_to_parse(int cost_cutoff) {



    int i;

    build_sentence_disjuncts(cost_cutoff);
    if (verbosity > 2) {
 printf("After expanding expressions into disjuncts:") ;
 print_disjunct_counts();
    }
    print_time("Built disjuncts");

    for (i=0; i<N_words; i++) {
 sentence[i].d = eliminate_duplicate_disjuncts(sentence[i].d);
    }
    print_time("Eliminated duplicate disjuncts");

    if (verbosity > 2) {
 printf("\nAfter expression pruning and duplicate elimination:\n");
 print_disjunct_counts();
    }

    set_is_conjunction();

    if (sentence_contains_conjunction()) {
 build_deletable();

 power_prune(1);
 if (verbosity > 2) {
     printf("\nAfter Gentle power pruning:\n");
     print_disjunct_counts();
 }
 print_time("Finished gentle power pruning");
 N_in_table = N_hash_lookups = work_in_hash_lookups = mark_cost = 0;
 conjunction_prune();
 if (verbosity > 2) {
     printf("\nAfter conjunction pruning:\n");
     print_disjunct_counts();
     print_statistics();
 }
 free_deletable();
 print_time("Done conjunction pruning");
 build_conjunction_tables();
 install_fat_connectors();
 construct_either();
 construct_neither();
 construct_notonlybut();

 construct_both();
 construct_comma();
 if (verbosity > 2) {
     printf("After conjunctions, disjuncts counts:\n");
     print_disjunct_counts();
 }
 print_time("Constructed fat disjuncts");

 prune();
 print_time("Pruned fat disjuncts");

 for (i=0; i<N_words; i++) {
     sentence[i].d = eliminate_duplicate_disjuncts(sentence[i].d);
 }
 if (verbosity > 2) {
     printf("After pruning and duplicate elimination:\n");
     print_disjunct_counts();
 }
 print_time("Eliminated duplicate disjuncts (again)");

 if (verbosity > 2) print_AND_statistics();
    }

    power_prune(0);

    if (verbosity > 2) {
 printf("\nAfter power-pruning:\n");
 print_disjunct_counts();
    }
    print_time("Ruthlessly power pruned");

    N_in_table = N_hash_lookups = work_in_hash_lookups = parse_cost = 0;

    init_fast_matcher();
    init_table();
    print_time("Initialized fast matcher and hash table");
}

void unprepare_parse(void) {
    free_sentence_disjuncts();
    if (sentence_contains_conjunction()) free_AND_tables();
    free_fast_matcher();
    free_table();
}

void final_unprepare_parse(void) {

    free_sentence_expressions();
    free_strings();
    free_lookup_list();


}

int compute_linkage_arrays(int index, int cost) {




    extract_links(index, cost);
    return (set_has_fat_down());
}

void summary_line(int N_canonical_linkages, int N_valid_linkages, char * stagen, int give_up) {
    if (N_canonical_linkages == 0) {
 if (give_up) {
     printf("Not accepted (no linkage exists) at %s", stagen);
 } else {
     printf("No linkages at %s", stagen);
 }
    } else if (N_canonical_linkages==1) {
 if (N_valid_linkages == 0){
     if (give_up) {
  printf("Not accepted (unique linkage with P.P. violation) at %s", stagen);
     } else {
  printf("Unique linkage with P.P. violation at %s", stagen);
     }
 } else {
     printf("Accepted at %s", stagen);
 }
    } else {
 if (N_valid_linkages == 0) {
     if (give_up) {
  printf("Not accepted (%d linkages, all with P.P. violations) at %s", N_canonical_linkages, stagen);
     }
     else {
  printf("%d linkages (all with P.P. violations) at %s", N_canonical_linkages, stagen);
     }
 } else {
     printf("Accepted (%d linkages, %d with no P.P. violations) at %s", N_canonical_linkages, N_valid_linkages, stagen);
 }
    }
    if (display_bad) {
 printf(" (shown above)\n\n");
    } else {
 printf("\n");
    }
}

char * stage_name(int phase, int cost_cutoff, int null_count) {
    static char answer[100];
    int stage;
    if (phase == 0) {
 if (cost_cutoff <= 1) stage = 1; else stage = 2;
 sprintf(answer, "stage %d", stage);
    } else {
 sprintf(answer, "null count %d", null_count);
    }
    return answer;
}


void loop(void) {
    int i, N_to_display, index;
    int N_linkages;
    int N_canonical_linkages;
    int N_valid_linkages;
    int has_fatlinks;
    Linkage_info * linkage=((void *)0);
    char line[1500], message[80];
    int line_set = 0;
    int cost_cutoff, old_cost_cutoff, maxcost, success, give_up, phase, just_entered_phase_1, null_count;
    char * stagen;


    for(;;) {
 null_links = 0;

 free_lookup_list();
 free_strings();
 max_space_in_use = 0;
 space_in_use = 0;


 clear_time();



 if (!line_set) {
     if (!www_mode) printf("> ");
     if (www_mode) fflush(stdout);
     if (fgets(line, 1500, stdin) == ((void *)0)) exit(1);
 }
 line_set = 0;
 if (line[strlen(line)-1] != '\n') {
     printf("Your sentence is too long\n");
     continue;
 }
 if (line[0] == '!') {
     special_command(line);
     continue;
 }
 if (!separate_sentence(line)) continue;
 if (N_words - left_wall_defined - right_wall_defined > word_count_limit) {
     printf("Try a sentence with at most %d words.\n", word_count_limit);
     continue;
 }
 if (!(unknown_word_defined && use_unknown_word)) {
     if (!sentence_in_dictionary()) continue;
 }
 if (!build_sentence_expressions()) continue;
 maxcost = maxcost_of_sentence();

 print_time("Constructed disjunct expressions");

 first_prepare_to_parse();
 old_cost_cutoff = 1;
 prepare_to_parse(1);

 phase = 0;
 success = give_up = 0;
 cost_cutoff = 0;
 null_count = 0;
 while(!(success || give_up)) {



     just_entered_phase_1 = 0;
     if (phase == 0) {

         if (cost_cutoff == 0) {
      cost_cutoff = 1;
         } else if (cost_cutoff == 1 && maxcost > 1) {
      cost_cutoff = maxcost;
  } else {
      phase = 1;
      null_links = 1;
      cost_cutoff = 1000;
      just_entered_phase_1 = 1;
  }
  if (cost_cutoff == maxcost && !null_link_search) give_up = 1;

     } else {
  null_count++;
  give_up = (null_count >= N_words-1);


     }

     if (verbosity > 2 && phase == 0) printf("Cost cutoff: %d\n", cost_cutoff);

     if (cost_cutoff != old_cost_cutoff) {
  unprepare_parse();
  prepare_to_parse(cost_cutoff);
  old_cost_cutoff = cost_cutoff;
     }

     if (just_entered_phase_1) {

  null_count = 1;
     }
     stagen = stage_name(phase, cost_cutoff, null_count);

     if (phase == 0) {
  N_linkages = parse(0);
     } else {
  N_linkages = parse(null_count);
     }

     if (N_linkages > linkage_count_limit) {
  printf("Warning: only the first %d of %d linkages will be considered.\n", linkage_count_limit, N_linkages);
  N_linkages = linkage_count_limit;
     }

     sprintf(message, "Counted %d linkges", N_linkages);
     print_time(message);

     N_canonical_linkages = N_valid_linkages = 0;

     if (N_linkages != 0) {
  linkage = (Linkage_info *)xalloc(N_linkages * sizeof(Linkage_info));
  for (index=0; index < N_linkages; index++) {
      has_fatlinks = compute_linkage_arrays(index, null_count);
      if (has_fatlinks) {
   if (!is_canonical_linkage()) continue;
   linkage[N_canonical_linkages] = analyze_fat_linkage(0);
      } else {
   linkage[N_canonical_linkages] = analyze_thin_linkage(0);
      }
      if (linkage[N_canonical_linkages].N_violations == 0) {
   N_valid_linkages++;
      }
      linkage[N_canonical_linkages].index = index;
      N_canonical_linkages ++;
  }
  qsort((void *)linkage, N_canonical_linkages,
        sizeof(Linkage_info),
        (int (*)(const void *, const void *))compare_parse);
     }

     { if (!(! ((N_canonical_linkages == 0) && (N_linkages > 0) && (N_linkages < linkage_count_limit)))) { printf("Assertion failed: %s\n", "None of the linkages is canonical"); exit(1); } };


     print_time("Postprocessed all linkages");

     line_set = 0;
     success = (N_valid_linkages > 0);


     if (!display_bad) summary_line(N_canonical_linkages, N_valid_linkages, stagen, give_up);

     if (display_bad) {
  N_to_display = N_canonical_linkages;
     } else {
  N_to_display = N_valid_linkages;
     }

     if (display_on) {
  for (index=0; index < N_to_display; index++) {
      has_fatlinks = compute_linkage_arrays(linkage[index].index, null_count);
      compute_chosen_words();
      if (N_canonical_linkages > 1) {
   printf("  Linkage %d", index+1);
      } else {
   printf("  Unique linkage");
      }
      if (linkage[index].N_violations > 0) {
   printf(" (bad), ");
      } else {
   printf(", ");
      }
      printf("cost vector = (%d, %d, %d)\n",
      linkage[index].disjunct_cost,
      linkage[index].and_cost,
      linkage[index].link_cost);
      if (has_fatlinks) {
   (void) analyze_fat_linkage(1);
      } else {
   (void) analyze_thin_linkage(1);
      }
      if (index == N_to_display-1) break;
      if (just_one) break;
      if (www_mode) continue;
      if (!display_bad) {

   printf("(press return for another)\n");
   printf("> ");
   if (fgets(line, 1500, stdin) == ((void *)0)) exit(1);
   for (i=0; line[i] != '\0'; i++) if (!((*__ctype_b_loc ())[(int) ((line[i]))] & (unsigned short int) _ISspace)) break;
   if (line[i] != '\0') {
       line_set = 1;
       break;
   }
      }
  }
     }

     if (display_bad) summary_line(N_canonical_linkages, N_valid_linkages, stagen, give_up);

     if (N_linkages != 0) {
  xfree((char *) linkage, N_linkages*sizeof(Linkage_info));
     }
 }

 print_time("Displayed linkages");
 unprepare_parse();
 final_unprepare_parse();
 print_time("Freed all data structures");

 if (verbosity > 2) print_statistics();
 if (space_in_use != 0){
     printf("Warning: %d bytes of space leaked.\n", space_in_use);
 }
 print_total_time();
    }
}

void batch_process(void) {
    int i;
    int N_linkages;
    int N_canonical_linkages;
    int N_valid_linkages;
    int index;
    int has_fatlinks;
    Linkage_info * linkage=((void *)0);

    char s[1500];
    int errors;
    int mc;
    int cost_cutoff, old_cost_cutoff, maxcost, last_pass;

    null_links = 0;
    errors = 0;


    for(;;) {
 free_lookup_list();
 free_strings();
 max_space_in_use = 0;
 space_in_use = 0;
 clear_time();


 if (fgets(s, 1500, stdin) == ((void *)0)) break;
 if (s[strlen(s)-1] != '\n') {
     printf("Sentence too long\n");
     continue;
 }

 for (i=0; ((*__ctype_b_loc ())[(int) ((s[i]))] & (unsigned short int) _ISspace); i++);

 if (s[i] == '%') continue;
 if (s[i] == '\0') continue;

 if ((s[i] == '*') || (s[i] == '+') || (s[i] == '#') || (s[i] == ':') || (s[i] == '-')) {
     mc = s[i];
     s[i] = ' ';
 } else {
     mc = ' ';
 }

 if (s[0] == '!') {
     special_command(s);
     continue;
 }
 if (!separate_sentence(s)) continue;
 if (!(unknown_word_defined && use_unknown_word)) {
     if (!sentence_in_dictionary()) {
  errors++;
  printf("--- in the following sentence:\n");
  printf("%c ", mc);
  print_sentence(stdout, 2);
  printf("\n");
  continue;
     }
 }
 if (!build_sentence_expressions()) {
     errors++;
     continue;
 }
 maxcost = maxcost_of_sentence();
 print_time("Constructed disjunct expressions");
 if (echo_on) printf("%c ", mc);

 first_prepare_to_parse();

 last_pass = 0;

 cost_cutoff = 0;
 old_cost_cutoff = 1;
 prepare_to_parse(1);

 while (!last_pass) {
     if (cost_cutoff == 0) {
  cost_cutoff = 1;
     } else if (cost_cutoff == 1 && maxcost > 1) {
  cost_cutoff = maxcost;
     }

     last_pass = (cost_cutoff >= maxcost);

     if (verbosity > 2) printf("Cost cutoff: %d  maxcost: %d\n", cost_cutoff, maxcost) ;

     if (cost_cutoff != old_cost_cutoff) {
  unprepare_parse();
  prepare_to_parse(cost_cutoff);
  old_cost_cutoff = cost_cutoff;
     }

     N_linkages = parse(0);
     print_time("Counted linkages");

     N_canonical_linkages = N_valid_linkages = 0;

     if (N_linkages != 0) {
  linkage = (Linkage_info *)xalloc(N_linkages*
       sizeof(Linkage_info));

  for (index=0;(index < N_linkages) && (N_valid_linkages== 0);
       index++) {


      has_fatlinks = compute_linkage_arrays(index, 0);
      if (has_fatlinks) {
   if (!is_canonical_linkage()) continue;
   linkage[N_canonical_linkages]=
       analyze_fat_linkage(0);
      } else {
   linkage[N_canonical_linkages]=
       analyze_thin_linkage(0);
      }
      if (linkage[N_canonical_linkages].N_violations == 0) {
   N_valid_linkages++;
      }
      linkage[N_canonical_linkages].index = index;
      N_canonical_linkages ++;
  }
  qsort((void *)linkage, N_canonical_linkages,
        sizeof(Linkage_info),
        (int (*)(const void *, const void *))compare_parse);
     }

     print_time("Postprocessed some linkages");

     if (N_canonical_linkages == 0) {
       if (!((mc == '*') || (mc == '#'))) {
  if (last_pass) {
    errors++;
    if (!echo_on) {
      printf("--- No linkage for (%s): ", stage_name(0, cost_cutoff, 0));
      if (echo_on) printf("%c ", mc);
      print_sentence(stdout, 13);
    } else {
      printf("--- No linkage for this (%s)\n", stage_name(0, cost_cutoff, 0));
    }
  } else {
# 1652 "main.c"
  }
       }
     } else if (N_valid_linkages == 0) {
  if (!((mc == '+') || (mc == '*'))) {
      if (last_pass) {
   if (N_canonical_linkages == 1) {
       printf("--- unique linkage, with post-processing violation (%s)\n", stage_name(0, cost_cutoff, 0));
   } else {
       printf("--- %d linkages", N_canonical_linkages);
       printf(", all with post-processing violations");
       printf(" (%s)\n",stage_name(0, cost_cutoff, 0));
   }
   errors++;
   has_fatlinks =
       compute_linkage_arrays(linkage[0].index, 0);
   compute_chosen_words();
   if (has_fatlinks) {
       (void) analyze_fat_linkage(1);
   } else {
       (void) analyze_thin_linkage(1);
   }
      } else {
# 1682 "main.c"
      }
    }
     } else if ((mc == '+') || (mc == '*') || (mc == '#')) {
  errors++;
  if (!echo_on) {
    printf("--- %s Input: ", stage_name(0, cost_cutoff, 0));
    printf("%c ", mc);
    print_sentence(stdout, 13);
  } else {
    printf("--- Accepted %s:\n", stage_name(0, cost_cutoff, 0));
  }
  last_pass = 1;
  has_fatlinks = compute_linkage_arrays(linkage[0].index, 0);
  compute_chosen_words();
  if (has_fatlinks) {
      (void) analyze_fat_linkage(1);
  } else {
      (void) analyze_thin_linkage(1);
  }
     } else if ((linkage[0].disjunct_cost == 0) && (mc == ':')) {
  errors++;
  if (!echo_on) {
    printf("--- %s Input:  ", stage_name(0, cost_cutoff, 0));
    printf("%c ", mc);
    print_sentence(stdout, 13);
  } else {
    printf("--- Accepted %s:\n", stage_name(0, cost_cutoff, 0));
  }
  last_pass = 1;
  printf("p.p. violations: %d, disjunct cost: %d\n",
         linkage[0].N_violations, linkage[0].disjunct_cost);
  has_fatlinks = compute_linkage_arrays(linkage[0].index, 0);
  compute_chosen_words();
  if (has_fatlinks) {
      (void) analyze_fat_linkage(1);
  } else {
      (void) analyze_thin_linkage(1);
  }
     } else if ((cost_cutoff == 1) && (mc == '-')) {
       errors++;
       if (!echo_on) {
  printf("--- %s Input: ", stage_name(0, cost_cutoff, 0));
  printf("%c ", mc);
  print_sentence(stdout, 13);
       } else {
    printf("--- Accepted %s:\n", stage_name(0, cost_cutoff, 0));
  }
  last_pass = 1;
  has_fatlinks = compute_linkage_arrays(linkage[0].index, 0);
  compute_chosen_words();
  if (has_fatlinks) {
      (void) analyze_fat_linkage(1);
  } else {
      (void) analyze_thin_linkage(1);
  }
     } else if (0 && (cost_cutoff > 1) && (mc == ' ')) {




       errors++;
       if (!echo_on) {
    printf("--- %s Input: ", stage_name(0, cost_cutoff, 0));
    printf("%c ", mc);
    print_sentence(stdout, 13);
  } else {
    printf("--- Accepted %s:\n", stage_name(0, cost_cutoff, 0));
  }
       last_pass = 1;
       has_fatlinks = compute_linkage_arrays(linkage[0].index, 0);
       compute_chosen_words();
       if (has_fatlinks) {
    (void) analyze_fat_linkage(1);
       } else {
    (void) analyze_thin_linkage(1);
       }

     } else {
  last_pass = 1;

     }
     if (N_linkages != 0) {
  xfree((char *) linkage, N_linkages*sizeof(Linkage_info));
     }
 }

 fflush(stdout);
 print_time("Displayed linkages");
 unprepare_parse();
 final_unprepare_parse();
 print_time("Freed all data structures");

 if (verbosity > 2) print_statistics();
 if (space_in_use != 0){
     printf("Warning: %d bytes of space leaked.\n", space_in_use);
 }
 print_total_time();
    }
    if (errors == 0) {
 printf("No errors!\n");
    } else if (errors == 1) {
 printf("One error.\n");
    } else {
 printf("%d errors.\n", errors);
    }
}

int main(int argc, char** argv) {
    int batch;
    int prob;
    int i;

    (void) initialize_memory();
    prob = 0;
    batch = 0;
    for (i=2; i<argc && !prob; i++) {
 if (strcmp(argv[i], "-wordlimit") == 0) {
     prob = (i == argc-1 || (sscanf(argv[i+1], "%d", &word_count_limit) != 1));
     i++;
 } else if (strcmp(argv[i], "-linklimit") == 0) {
     prob = (i == argc-1 || (sscanf(argv[i+1], "%d", &linkage_count_limit) != 1));
     i++;
 } else if (strcmp(argv[i], "-batch") == 0) {
     batch = 1;
 }
    }
    if ((argc < 2) || prob) {
 fprintf(stderr, "Usage: %s dictionary-file [-batch] [-wordlimit number] [-linklimit number]\n", argv[0]);
 exit(1);
    }

    open_dictionary(argv[1]);
    printf("\n Reading the dictionary files: ");
    read_dictionary();



    printf("\n\n\n");


    printf("Welcome to the Link Parser -- Version 2.1\n\n");
    printf("          ");
    printf("Copyright (C) 1991-1995 Daniel Sleator and Davy Temperley\n\n");

    init_randtable();

    left_wall_defined = boolean_dictionary_lookup(("LEFT-WALL"));
    right_wall_defined = boolean_dictionary_lookup(("RIGHT-WALL"));
    postprocess_defined = boolean_dictionary_lookup(("POSTPROCESS"));
    andable_defined = boolean_dictionary_lookup(("ANDABLE-CONNECTORS"));
    unknown_word_defined = boolean_dictionary_lookup(("UNKNOWN-WORD"));
    capitalized_word_defined = boolean_dictionary_lookup(("CAPITALIZED-WORDS"));

    if (andable_defined) {
 init_andable_hash_table();
    }

    if (batch) {
 printf("Processing sentences in batch mode\n");
 printf("\n");
 batch_process();
    } else {
 printf("Type your sentence and press Return ");
 printf("(\"!help\" for options).\n");
 printf("\n");
 loop();
    }
    return 0;
}
