C     This is a test run of the fsrch routine generated by the
C     vcg.  We search for the pattern "123" in the pattern "121236789".
C     Note that we have replaces the parameter ASIZE& with 128.
C     To run this on a bsd unix and see the answer, which is 3, you incant
C     % f77 fsrch.f
C     % a.out
C     % cat fort.23      
      INTEGER DELTA1
      DIMENSION DELTA1(128)
      COMMON /BLK/DELTA1
      INTEGER PAT(3)
      INTEGER STR(10)
      INTEGER X
      PAT(1) = 1
      PAT(2) = 2
      PAT(3) = 3
      STR(1) = 1
      STR(2) = 2
      STR(3) = 1
      STR(4) = 2
      STR(5) = 3
      STR(6) = 6
      STR(7) = 7
      STR(8) = 8
      STR(9) = 9
      STR(10) = 10
      CALL FSRCH(PAT,STR,3,10,X)
      WRITE (23, 17) X
 17   FORMAT (I10.10)
      END
      SUBROUTINE SETUP(A, MAXI)
      INTEGER DELTA1
      INTEGER A
      INTEGER MAXI
      INTEGER I
      INTEGER C
      DIMENSION DELTA1(128)
      DIMENSION A(MAXI)
      COMMON /BLK/DELTA1
      DO 50 I = 1, 128
C     DOJUNK PASS1
      DELTA1(I) = MAXI
50    CONTINUE
      DO 100 I = 1, MAXI
C     DOJUNK PASS2
      C = A(I)
      DELTA1(C) = (MAXI - I)
100   CONTINUE
      RETURN
      END
      SUBROUTINE FSRCH(PAT, STR, PATLEN, STRLEN, X)
      INTEGER DELTA1
      INTEGER MAX0
      INTEGER PATLEN
      INTEGER STRLEN
      INTEGER PAT
      INTEGER STR
      INTEGER I
      INTEGER J
      INTEGER C
      INTEGER NEXTI
      INTEGER X
      DIMENSION DELTA1(128)
      DIMENSION PAT(PATLEN)
      DIMENSION STR(STRLEN)
      COMMON /BLK/DELTA1
      CALL SETUP(PAT, PATLEN)
      I = PATLEN
200   CONTINUE
C     XXX INNER-TO-OUTER-HINTS
      CONTINUE
C     ASSERTION OUTER-INVRT
      IF ((I .GT. STRLEN)) GOTO 500
      J = PATLEN
      NEXTI = (1 + I)
300   CONTINUE
C     ASSERTION INNER-INVRT
      C = STR(I)
      IF ((C .NE. PAT(J))) GOTO 400
      IF ((J .EQ. 1)) GOTO 600
      J = (J - 1)
      I = (I - 1)
C     XXX INNER-TO-INNER-HINTS
      GOTO 300
400   I = MAX0((I + DELTA1(C)), NEXTI)
      GOTO 200
500   X = (STRLEN + 1)
      RETURN
600   CONTINUE
C     XXX INNER-TO-EXIT-HINTS
      X = I
      RETURN
      END
