	subroutine squared_me(treeres, loopres, Ecms2,
     +    Hel1from, Hel1to, Hel2from, Hel2to, Hel3from, Hel3to,
     +    Hel4from, Hel4to, reset)
	implicit integer (j)
	implicit character (a-i,k-z)

	double precision treeres, loopres
	double precision Ecms2
	integer Hel1from, Hel1to, Hel2from, Hel2to, Hel3from, Hel3to
	integer Hel4from, Hel4to
	logical reset

#include "vars.h"

	double precision MomSquare
	external MomSquare

	double complex c, m
	integer Cptr, Dptr
	double precision prevS
	save prevS
	data prevS /-1/

	S = Ecms2
	T = MomSquare(1,9)
	U = MomSquare(1,13)

	if(reset .or. S .ne. prevS) then
	  call setcachelast(Ccache, 0)
	  call setcachelast(Dcache, 0)
	  call abbr_s
	  Cptr = getcachelast(Ccache)
	  Dptr = getcachelast(Dcache)
	  reset = .FALSE.
	  prevS = S
	endif

	call abbr_angle

	treeres = 0
	loopres = 0

	do 1 Hel1 = Hel1from, Hel1to
	do 1 Hel2 = Hel2from, Hel2to
	do 1 Hel3 = Hel3from, Hel3to
	do 1 Hel4 = Hel4from, Hel4to

	call abbr_hel

	do j1 = 1, 7
	Ctree(j1) = 0
	enddo

	do j2 = 1, 16
	Cloop(j2) = 0
	enddo

	call bornF
	call boxFa
	call boxFb
	call selfF
	call vertF

	do Gen1 = 1, 3
	call selfF_Gen1
	call vertF_Gen1
	enddo

	do j3 = 1, 7
	c = dconjg(Ctree(j3))

	m = 0
	do j1 = 1, 7
	m = m + Ctree(j1)*MatF(j1,j3)
	enddo
	treeres = treeres + dble(c*m)

	m = 0
	do j2 = 1, 16
	m = m + Cloop(j2)*MatF(j2,j3)
	enddo
	loopres = loopres + 2*dble(c*m)

	enddo

1	continue

	call setcachelast(Ccache, Cptr)
	call setcachelast(Dcache, Dptr)
	end

