processors =8

model=crcw

def pointers[5]
def ppointers[5]

def a[11]
def b[11]
def c[11]
def d[11]


def pa[11]
def pb[11]
def pc[11]
def pd[11]


i=4

thingplus%=pid*2
thing%=thingplus%-1

a[thing%]=thing%
a[thingplus%]=thingplus%


pointers[1]&=a0
pointers[2]&=b0
pointers[3]&=c0
pointers[4]&=d0

ppointers[1]&=pa0
ppointers[2]&=pb0
ppointers[3]&=pc0
ppointers[4]&=pd0

call dosum
sync
call doprefix



proc doprefix
{	
	r=1
	j=8
	round=4
	while (r<=j)
	{	
		if (pid <=r)
		{
			x#=pointers[round]
			if (r >1)
			{
				nextround=round+1
				y#=ppointers[nextround]
			}

			z#=ppointers[round]

			if (pid==1)
			{
				val%=x[pid]
				z[pid]=val%						
			} else {
		
				f%=pid
				call iseven

				if (t%==1)
				{					
					indexy%=pid/2	
					tempval%=y[indexy%]				
					z[pid]=tempval%
				} else {					
					indexy%=pid-1
					indexy%=indexy%/2
					valueofit%=y[indexy%]
					upval%=x[pid]
					valueofit%=valueofit%+upval%
					z[pid]=valueofit%
				}
			}
			
		}
	sync
	round--	
	r=r*2
	
	}
}

proc dosum
{
	round=1
	k=0

	while (i>=pid)
	{
		x#=pointers[round]
		nextround=round+1
	
		y#=pointers[nextround]

		one%=x[thing%]
		two%=x[thingplus%]
		sum%=one%+two%

		y[pid]=sum%

		call testifwasodd
		
		
		b=i
		i=i/2
		round++

		call testeven	

		
	}
}

proc testifwasodd
{
	if (k==1)	
	{
		if (pid==i)
		{
			y[pid]=x[thing%]
		}
	}	
}

proc testeven
{
	c=b.2		
	if (c!=0)
	{
		if (i!=0)
		{	
			i++
			k=1
		}
	} else {

		k=0
	}
}

proc iseven
{
	t%=1
	f%=f%.2
	if (f%!=0)
	{
		t%=0
	}
}
