c { dg-do compile }
* Date: Thu, 19 Aug 1999 10:02:32 +0200
* From: Frederic Devernay <devernay@istar.fr>
* Organization: ISTAR
* X-Accept-Language: French, fr, en
* To: gcc-bugs@gcc.gnu.org
* Subject: g77 2.95 bug (Internal compiler error in `final_scan_insn')
* X-UIDL: 08443f5c374ffa382a05573281482f4f

* Here's a bug that happens only when I compile with -O (disappears with
* -O2)

* > g77 -v --save-temps -O -c  pcapop.f
* g77 version 2.95 19990728 (release) (from FSF-g77 version 0.5.25
* 19990728 (release))
* Reading specs from
* /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95/specs
* gcc version 2.95 19990728 (release)
*  /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95/f771 pcapop.f -quiet
* -dumpbase pcapop.f -O -version -fversion -o pcapop.s
* GNU F77 version 2.95 19990728 (release) (sparc-sun-solaris2.6) compiled
* by GNU C version 2.95 19990728 (release).
* GNU Fortran Front End version 0.5.25 19990728 (release)
* pcapop.f: In subroutine `pcapop':
* pcapop.f:291: Internal compiler error in `final_scan_insn', at
* final.c:2920
* Please submit a full bug report.
* See <URL:http://egcs.cygnus.com/faq.html#bugreport> for instructions.

C* PCAPOP
	SUBROUTINE PCAPOP(M1,M2,L1,L2,NMEM,N1,N2,IB,IBB,K3,TF,TS,TC,TTO)
	DIMENSION NVA(6),C(6),I(6)
C
C CALCUL DES PARAMETRES OPTIMAUX N1 N2 IB IBB
C
	TACC=.035
	TTRANS=.000004
	RAD=.000001
	RMI=.000001
	RMU=.0000015
	RDI=.000003
	RTE=.000003
	REQ=.000005
	VY1=3*RTE+RDI+8*REQ+3*(RAD+RMI+RMU)
	VY2=REQ+2*RAD
	AR2=M2*(2*(REQ+RMI)+3*RMU+M1*(2*RAD+REQ))
C     VARIATION DE L1,L2,
C
	TTOTOP=1.E+10
	N1CO=0
	N2CO=0
	IBCO=0
	IBBCO=0
	K3CO=0
	TESOP=0.
	TCOP=0.
	TFOP=0.
	 INUN=7
	 INDE=7
	 IF(M1.LT.128)INUN=6
	 IF(M1.LT.64)INUN=5
	 IF(M1.LT.32)INUN=4
	 IF(M2.LT.128)INDE=6
	 IF(M2.LT.64)INDE=5
	 IF(M2.LT.32)INDE=4
	DO 3 NUN =3,INUN
	DO 3 NDE=3,INDE
	N10=2**NUN
	N20=2**NDE
	NDIF=(N10-N20)
	NDIF=IABS(NDIF)
C POUR AVOIR CES RESULTATS FAIRE TOURNER LE PROGRAMME VEFFT1
	 TCFFTU=0.
	IF(N10.EQ.128.AND.N20.EQ.128)TCFFTU=3.35
	IF(N10.EQ.64.AND.N20.EQ.64)TCFFTU=.70
	IF(N10.EQ.32.AND.N20.EQ.32)TCFFTU=.138
	IF(N10.EQ.16.AND.N20.EQ.16)TCFFTU=.0332
	IF(N10.EQ.8.AND.N20.EQ.8)TCFFTU=.00688
	IF(NDIF.EQ.64)TCFFTU=1.566
	IF(NDIF.EQ.96)TCFFTU=.709
	IF(NDIF.EQ.112)TCFFTU=.349
	IF(NDIF.EQ.120)TCFFTU=.160
	IF(NDIF.EQ.32)TCFFTU=.315
	IF(NDIF.EQ.48)TCFFTU=.154
	IF(NDIF.EQ.56)TCFFTU=.07
	IF(NDIF.EQ.16)TCFFTU=.067
	IF(NDIF.EQ.24)TCFFTU=.030
	IF(NDIF.EQ.8)TCFFTU=.016
	N30=N10-L1+1
	N40=N20-L2+1
	WW=VY1+N30*VY2
	NDOU=2*N10*N20
	IF((N10.LT.L1).OR.(N20.LT.L2)) GOTO 3
	NB=NMEM-NDOU-N20*(L1-1)
	NVC=2*N10*(N20-1)+M1
	IF(NB.LT.(NVC)) GOTO 3
	CALL VALENT(M1,N30,K1)
	CALL VALENT(M2,N40,K2)
	IS=K1/2
	IF((2*IS).NE.K1)K1=K1+1
	    TFF=TCFFTU*K1*K2
	CALL VALENT(M2,N40,JOFI)
	IF(NB.GE.(K1*N20*N30+2*N20*(L1-1))) GOTO 4
	TIOOP=1.E+10
	IC=1
18    IB1=2*IC
	MAX=(NB-2*N20*(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Q.6) GOTO 11
	K=K+1
	GOTO 10
11    IP1=0
	IP2=0
	IP3=0
	POFI=JOFI
	IF(POFI.LE.2)POFI=2
	TIOL=(I(2)+(IOFI-1)*I(1)+(POFI-2)*(IOFI-1)*I(3)+(POFI-
     %2)*I(4)+(IOFI-1)*I(5)+I(6))*TACC+(IOFI*M1*N40+(POFI-2)*IOFI*
     %M1*N20+(M2-(JOFI-1)*N40+L2-1)*M1*IOFI)*TTRANS
	IF(IBB1.EQ.0) GOTO 33
	IF(IB1.EQ.IBB1) GOTO 33
	IF(IBB1.EQ.2)GOTO 34
	IP3=1
	INL=NMEM/((IOFI-1)*IB1*N30+IBB1*N30)
55    IF(INL.GT.N40)INL=N40
	GOTO 35
33    IF(IB1.GT.2) GOTO 36
	IF((M1-(IOFI-1)*IB1*N30).GE.N30) GOTO 36
34    IP1=1
	INL=NMEM/(2*M1-(IOFI-1)*IB1*N30)
	GOTO 55
36    IP2=1
	INL=NMEM/(IOFI*IB1*N30)
	IF(INL.GT.N40)INL=N40
35    CALL VALENT(N40,INL,KN1)
	CALL VALENT(M2-(JOFI-1)*N40,INL,KN2)
	CALL VALENT(INL*IBB1,IB1,KN3)
	CALL VALENT((N40-(KN1-1)*INL)*IBB1,IB1,KN4)
	IF((IP1+IP2+IP3).NE.1) CALL ERMESF(14)
	TIO1=0.
	IF(IP3.EQ.1)TIO1=N30*M2*TTRANS*(IB1*(IOFI-1)+IBB1)
	IF(IP1.EQ.1)TIO1=M1*M2*TTRANS
	IF(IP2.EQ.1) TIO1=(IB1*N30*M2*IOFI*TTRANS)
	TTIO=2.*TIO1+(KN1*IOFI*(JOFI-1)+KN2*IOFI+(KN1-1)*(
     %JOFI-1)+IOFI*(JOFI-1)+KN2-1.+IOFI+(KN1*(JOFI-1)+KN2))*TACC
     %+M1*M2*TTRANS+TIOL
	IF((IP1.EQ.1).AND.(IRZ.EQ.0))TCPU=TCPU+AT1+AT2+AT3
	IF((IP1.EQ.1).AND.(IRZ.NE.0))TCP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