      INTEGER I,LOOKS,ENTRI0,HASHM0,PROBE,HASHW0
      INTEGER MINHA0,FD
      INTEGER GETARG,CTOI,GETLIN,MKTEMP
      INTEGER NAMES(9,1001)
      INTEGER ARG1(102),ARG2(102),BUF(102)
      REAL HASHD0,MINDE0
      INTEGER HASHC0(2)
      INTEGER * 4 LONGH0
      INTEGER AAAAB0
      INTEGER AAAAA0
      INTEGER AAAAC0
      EQUIVALENCE (HASHC0(1),LONGH0)
      IF((GETARG(1,ARG1,102).EQ.-1))GOTO 10002
      IF((GETARG(2,ARG2,102).EQ.-1))GOTO 10002
      GOTO 10001
10002   CALL ERROR('Usage:  hasher <table size> <search width>.')
10001 I=1
      HASHM0=CTOI(ARG1,I)
      IF(((HASHM0.GE.1).AND.(HASHM0.LE.1001)))GOTO 10003
        CALL ERROR('Hash table size < 1 or too large.')
10003 I=1
      HASHW0=CTOI(ARG2,I)
      IF((HASHM0-HASHW0.LT.1))GOTO 10005
      IF((HASHM0+HASHW0.GT.1001))GOTO 10005
      IF((HASHW0.LT.0))GOTO 10005
      GOTO 10004
10005   CALL ERROR('Hash size search width too big.')
10004 FD=MKTEMP(3)
      IF((FD.NE.-3))GOTO 10006
        CALL ERROR('Can''t create temporary file.')
10006 CALL FCOPY(-10,FD)
      AAAAA0=HASHM0-HASHW0
      AAAAB0=1
      GOTO 10000
10007 MINDE0=HASHD0
      MINHA0=HASHM0-HASHW0
      I=HASHM0-HASHW0+1
      GOTO 10010
10008 I=I+(1)
10010 IF((I.GT.HASHM0+HASHW0))GOTO 10009
        AAAAA0=I
        AAAAB0=2
        GOTO 10000
10011   IF((HASHD0.GE.MINDE0))GOTO 10012
          MINDE0=HASHD0
          MINHA0=I
10012 GOTO 10008
10009 AAAAA0=MINHA0
      AAAAB0=3
      GOTO 10000
10013 CALL PRINT(-11,'** Hash table generated by hasher*n.')
      CALL PRINT(-11,'HMOD   DATA  *iL*nHTAB   EQU    ***n.',MINHA0)
      I=1
      GOTO 10016
10014 I=I+1
10016 IF(((I.GT.MINHA0).AND.(NAMES(1,I).EQ.0)))GOTO 10015
        IF((NAMES(1,I).NE.0))GOTO 10017
          CALL PRINT(-11,'***n       BSZ     6*n.')
          GOTO 10018
10017     CALL PRINT(-11,'***n       EXT     *s*n.',NAMES(1,I))
          CALL PRINT(-11,'       DATA    C''*s''*n.',NAMES(1,I))
          CALL PRINT(-11,'       IP      *s*n.',NAMES(1,I))
10018 GOTO 10014
10015 CALL PRINT(-11,'***n       OCT     0*n.')
      CALL PRINT(-15,'entries: *i, table size: *i, search depth: *r*n.',
     *ENTRI0,I-1,MINDE0)
      CALL SWT
10000 CALL REWIND(FD)
      DO 10019 AAAAC0=1,1001
        NAMES(1,AAAAC0)=0
10019 CONTINUE
10020 ENTRI0=0
      LOOKS=0
10021 IF((GETLIN(BUF,FD).EQ.-1))GOTO 10022
        IF((BUF(1).NE.170))GOTO 10023
          GOTO 10021
10023   ENTRI0=ENTRI0+1
        AAAAC0=LENGTH(BUF)
        GOTO 10026
10024   AAAAC0=AAAAC0+1
10026   IF((AAAAC0.GT.8))GOTO 10025
          BUF(AAAAC0)=160
        GOTO 10024
10025   BUF(9)=0
        IF((BUF(3).NE.160))GOTO 10027
        IF((BUF(4).NE.160))GOTO 10027
          HASHC0(1)=0
          HASHC0(2)=XOR(LS(BUF(1),8),BUF(2))
          GOTO 10028
10027     IF((BUF(5).NE.160))GOTO 10029
          IF((BUF(6).NE.160))GOTO 10029
            HASHC0(1)=XOR(LS(BUF(3),8),BUF(4))
            HASHC0(2)=XOR(LS(BUF(1),8),BUF(2))
            GOTO 10030
10029       IF((BUF(7).NE.160))GOTO 10031
            IF((BUF(8).NE.160))GOTO 10031
              HASHC0(1)=XOR(LS(BUF(3),8),BUF(4))
              HASHC0(2)=XOR(XOR(LS(BUF(1),8),BUF(2)),XOR(LS(BUF(5),8),BU
     *F(6)))
              GOTO 10032
10031         HASHC0(1)=XOR(XOR(LS(BUF(3),8),BUF(4)),XOR(LS(BUF(7),8),BU
     *F(8)))
              HASHC0(2)=XOR(XOR(LS(BUF(1),8),BUF(2)),XOR(LS(BUF(5),8),BU
     *F(6)))
10032     CONTINUE
10030   CONTINUE
10028   HASHC0(1)=AND(HASHC0(1),:77777)
        PROBE=MOD(LONGH0,INTL(AAAAA0))+1
10033   IF((NAMES(1,PROBE).EQ.0))GOTO 10034
          LOOKS=LOOKS+1
          PROBE=PROBE+1
          IF((PROBE.LE.1001))GOTO 10035
            CALL ERROR('Hash table overflow -- make mod + width bigger.'
     *)
10035   GOTO 10033
10034   CALL SCOPY(BUF,1,NAMES(1,PROBE),1)
      GOTO 10021
10022 HASHD0=FLOAT(LOOKS)/FLOAT(ENTRI0)+1.0
      GOTO 10036
10036 GOTO(10007,10011,10013),AAAAB0
      GOTO 10036
      END
C ---- Long Name Map ----
C hashmod                        hashm0
C minhash                        minha0
C hashwidth                      hashw0
C entries                        entri0
C mindepth                       minde0
C longhashcalc                   longh0
C hashnames                      hashn0
C hashdepth                      hashd0
C hashcalc                       hashc0