// File: /workspace/github_c_makefile_star2_O2/jiqingxiaoxi[P]RPA/RPA.c
// Function: calc_bulge_internal
void calc_bulge_internal(int i,int j,int ii,int jj,double* EntropyEnthalpy,int traceback,double stackEntropies[],double stackEnthalpies[],double stackint2Entropies[],double stackint2Enthalpies[],double interiorLoopEntropies[],double bulgeLoopEntropies[],double interiorLoopEnthalpies[],double bulgeLoopEnthalpies[],double tstackEntropies[],double tstackEnthalpies[],double atpS[],double atpH[],double Initdouble[],int Initint[],double enthalpyDPT[],double entropyDPT[],char numSeq1[],char numSeq2[])
{
	int loopSize1,loopSize2,loopSize,N,N_loop;
	double T1,T2,S,H;

	S=-3224.0;
	H=0;
	loopSize1=ii-i-1;
	loopSize2=jj-j-1;
	if(ii<jj)
	{
		N=i;
		N_loop=N;
		if(loopSize1>2)
			N_loop-=(loopSize1-2);
		if(loopSize2>2)
			N_loop-=(loopSize2-2);
	}
	else
	{
		N=j;
		N_loop=2*jj;
		if(loopSize1>2)
			N_loop-=(loopSize1-2);
		if(loopSize2>2)
			N_loop-=(loopSize2-2);
		N_loop=(N_loop/2)-1;
	}

	loopSize=loopSize1+loopSize2-1;
	if((loopSize1==0&&loopSize2>0)||(loopSize2==0&&loopSize1>0))// only bulges have to be considered
	{
		if(loopSize2==1||loopSize1==1) // bulge loop of size one is treated differently the intervening nn-pair must be added
		{
			if((loopSize2==1&&loopSize1==0)||(loopSize2==0&&loopSize1==1))
			{
				H=bulgeLoopEnthalpies[loopSize]+stackEnthalpies[numSeq1[i]*125+numSeq1[ii]*25+numSeq2[j]*5+numSeq2[jj]];
				S=bulgeLoopEntropies[loopSize]+stackEntropies[numSeq1[i]*125+numSeq1[ii]*25+numSeq2[j]*5+numSeq2[jj]];
			}
			H+=enthalpyDPT[(i-1)*Initint[2]+j-1];
			S+=entropyDPT[(i-1)*Initint[2]+j-1];
			if(fabs(H)>999999999)
			{
				H=1.0*INFINITY;
				S=-1.0;
			}

			T1=(H+Initdouble[0])/((S+Initdouble[1])+Initdouble[2]);
			T2=(enthalpyDPT[(ii-1)*Initint[2]+jj-1]+Initdouble[0])/((entropyDPT[(ii-1)*Initint[2]+jj-1])+Initdouble[1]+Initdouble[2]);
			if((T1>T2)||((traceback&&T1>=T2)||(traceback==1)))
			{
				EntropyEnthalpy[0]=S;
				EntropyEnthalpy[1]=H;
			}
		}
		else // we have _not_ implemented Jacobson-Stockaymayer equation; the maximum bulgeloop size is 30
		{
			H=bulgeLoopEnthalpies[loopSize]+atpH[numSeq1[i]*5+numSeq2[j]]+atpH[numSeq1[ii]*5+numSeq2[jj]];
			H+=enthalpyDPT[(i-1)*Initint[2]+j-1];

			S=bulgeLoopEntropies[loopSize]+atpS[numSeq1[i]*5+numSeq2[j]]+atpS[numSeq1[ii]*5+numSeq2[jj]];
			S+=entropyDPT[(i-1)*Initint[2]+j-1];
			if(fabs(H)>999999999)
			{
				H=1.0*INFINITY;
				S=-1.0;
			}
			T1=(H+Initdouble[0])/((S+Initdouble[1])+Initdouble[2]);
			T2=(enthalpyDPT[(ii-1)*Initint[2]+jj-1]+Initdouble[0])/(entropyDPT[(ii-1)*Initint[2]+jj-1]+Initdouble[1]+Initdouble[2]);
			if((T1>T2)||((traceback&&T1>=T2)||(traceback==1)))
			{
				EntropyEnthalpy[0]=S;
				EntropyEnthalpy[1]=H;
			}
		}
	}
	else if(loopSize1==1&&loopSize2==1)
	{
		S=stackint2Entropies[numSeq1[i]*125+numSeq1[i+1]*25+numSeq2[j]*5+numSeq2[j+1]]+stackint2Entropies[numSeq2[jj]*125+numSeq2[jj-1]*25+numSeq1[ii]*5+numSeq1[ii-1]];
		S+=entropyDPT[(i-1)*Initint[2]+j-1];

		H=stackint2Enthalpies[numSeq1[i]*125+numSeq1[i+1]*25+numSeq2[j]*5+numSeq2[j+1]]+stackint2Enthalpies[numSeq2[jj]*125+numSeq2[jj-1]*25+numSeq1[ii]*5+numSeq1[ii-1]];
		H+=enthalpyDPT[(i-1)*Initint[2]+j-1];
		if(fabs(H)>999999999)
		{
			H=1.0*INFINITY;
			S=-1.0;
		}
		T1=(H+Initdouble[0])/((S+Initdouble[1])+Initdouble[2]);
		T2=(enthalpyDPT[(ii-1)*Initint[2]+jj-1]+Initdouble[0])/(entropyDPT[(ii-1)*Initint[2]+jj-1]+Initdouble[1]+Initdouble[2]);
		if((T1-T2>=0.000001)||traceback==1)
		{
			if((T1>T2)||(traceback&&T1>=T2))
			{
				EntropyEnthalpy[0]=S;
				EntropyEnthalpy[1]=H;
			}
		}
		return;
	}
	else // only internal loops
	{
		H=interiorLoopEnthalpies[loopSize]+tstackEnthalpies[numSeq1[i]*125+numSeq1[i+1]*25+numSeq2[j]*5+numSeq2[j+1]]+tstackEnthalpies[numSeq2[jj]*125+numSeq2[jj-1]*25+numSeq1[ii]*5+numSeq1[ii-1]];
		H+=enthalpyDPT[(i-1)*Initint[2]+j-1];

		S=interiorLoopEntropies[loopSize]+tstackEntropies[numSeq1[i]*125+numSeq1[i+1]*25+numSeq2[j]*5+numSeq2[j+1]]+tstackEntropies[numSeq2[jj]*125+numSeq2[jj-1]*25+numSeq1[ii]*5+numSeq1[ii-1]]+(-300/310.15*abs(loopSize1-loopSize2));
		S+=entropyDPT[(i-1)*Initint[2]+j-1];
		if(fabs(H)>999999999)
		{
			H=1.0*INFINITY;
			S=-1.0;
		}
		T1=(H+Initdouble[0])/((S+Initdouble[1])+Initdouble[2]);
		T2=(enthalpyDPT[(ii-1)*Initint[2]+jj-1]+Initdouble[0])/((entropyDPT[(ii-1)*Initint[2]+jj-1])+Initdouble[1]+Initdouble[2]);
		if((T1>T2)||((traceback&&T1>=T2)||(traceback==1)))
		{
			EntropyEnthalpy[0]=S;
			EntropyEnthalpy[1]=H;
		}
	}
	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %r9d, -0x2c(%rbp)
movq %r8, %rbx
movq 0x98(%rbp), %r15
movq 0x90(%rbp), %r14
movq 0x88(%rbp), %r11
movl %edi, %r12d
notl %r12d
addl %edx, %r12d
movl %esi, %r13d
notl %r13d
addl %ecx, %r13d
movl %r12d, %eax
subl $0x1, %eax
setb %r10b
leal (%rax,%r13), %r9d
testl %r13d, %r13d
setg %al
testb %al, %r10b
jne 0x6ad4
testl %r13d, %r13d
setne %al
testl %r12d, %r12d
setle %r10b
orb %al, %r10b
jne 0x6bdc
movq %rbx, %rax
movq 0x48(%rbp), %rbx
cmpl $0x1, %r13d
setne %r10b
cmpl $0x1, %r12d
setne %r8b
testb %r10b, %r8b
jne 0x6b28
movl %r12d, %r8d
xorl $0x1, %r8d
movl %r13d, %r11d
xorl $0x1, %r11d
orl %r13d, %r8d
sete %r10b
orl %r12d, %r11d
je 0x6d53
testb %r10b, %r10b
jne 0x6d53
xorpd %xmm1, %xmm1
movsd 0x6515(%rip), %xmm0     # 0xd038
jmp 0x6daf
movq 0x68(%rbp), %r8
movslq %r9d, %r10
movsd (%rbx,%r10,8), %xmm1
movslq %edi, %r9
movsbq (%r14,%r9), %r9
leaq (%r9,%r9,4), %r9
movslq %esi, %r11
movsbq (%r15,%r11), %r12
addq %r9, %r12
addsd (%r8,%r12,8), %xmm1
movslq %edx, %r9
movsbq (%r14,%r9), %r9
leaq (%r9,%r9,4), %r9
movslq %ecx, %r11
movsbq (%r15,%r11), %rbx
addq %r9, %rbx
addsd (%r8,%rbx,8), %xmm1
decl %edi
movq 0x78(%rbp), %r8
movl 0x8(%r8), %r9d
imull %r9d, %edi
addl %edi, %esi
decl %esi
movslq %esi, %rsi
movq 0x80(%rbp), %r8
addsd (%r8,%rsi,8), %xmm1
movapd 0x6547(%rip), %xmm3     # 0xd0e0
andpd %xmm1, %xmm3
movsd 0x648b(%rip), %xmm2     # 0xd030
ucomisd %xmm2, %xmm3
ja 0x6dfa
movq 0x60(%rbp), %rdi
movq 0x38(%rbp), %r11
movsd (%r11,%r10,8), %xmm0
addsd (%rdi,%r12,8), %xmm0
addsd (%rdi,%rbx,8), %xmm0
movq 0x88(%rbp), %rdi
addsd (%rdi,%rsi,8), %xmm0
movq %rax, %rbx
jmp 0x6e0c
movl %r12d, %eax
xorl $0x1, %eax
movl %r13d, %r8d
xorl $0x1, %r8d
orl %eax, %r8d
jne 0x6ed6
movslq %edi, %rax
movsbq (%r14,%rax), %r8
imulq $0x7d, %r8, %r8
movsbq 0x1(%r14,%rax), %rax
imulq $0x19, %rax, %rax
addq %r8, %rax
movslq %esi, %r8
movsbq (%r15,%r8), %r9
leaq (%r9,%r9,4), %r10
movsbq 0x1(%r15,%r8), %r9
addq %r10, %r9
addq %rax, %r9
movslq %ecx, %rax
movsbq (%r15,%rax), %r8
movsbq -0x1(%r15,%rax), %rax
imulq $0x7d, %r8, %r8
imulq $0x19, %rax, %r10
addq %r8, %r10
movslq %edx, %rax
movsbq (%r14,%rax), %rdx
leaq (%rdx,%rdx,4), %rdx
movsbq -0x1(%r14,%rax), %r8
addq %rdx, %r8
addq %r10, %r8
movq 0x20(%rbp), %rdx
movsd (%rdx,%r9,8), %xmm2
addsd (%rdx,%r8,8), %xmm2
movq 0x28(%rbp), %rdx
movsd (%rdx,%r9,8), %xmm1
addsd (%rdx,%r8,8), %xmm1
decl %edi
movq 0x78(%rbp), %rdx
movl 0x8(%rdx), %edx
imull %edx, %edi
addl %edi, %esi
decl %esi
movslq %esi, %rsi
addsd (%r11,%rsi,8), %xmm2
movq 0x80(%rbp), %rdi
addsd (%rdi,%rsi,8), %xmm1
decq %rax
movapd 0x643c(%rip), %xmm0     # 0xd0e0
andpd %xmm1, %xmm0
movsd 0x6380(%rip), %xmm3     # 0xd030
ucomisd %xmm3, %xmm0
cmpltsd %xmm0, %xmm3
movsd 0x637f(%rip), %xmm0     # 0xd040
andpd %xmm3, %xmm0
andnpd %xmm2, %xmm3
orpd %xmm3, %xmm0
jbe 0x6cd7
movsd 0x6351(%rip), %xmm1     # 0xd028
movq 0x70(%rbp), %rsi
movsd (%rsi), %xmm2
movsd 0x8(%rsi), %xmm4
movapd %xmm2, %xmm3
addsd %xmm1, %xmm3
movapd %xmm4, %xmm5
addsd %xmm0, %xmm5
movsd 0x10(%rsi), %xmm6
addsd %xmm6, %xmm5
imull %eax, %edx
leal (%rcx,%rdx), %eax
decl %eax
cltq
addsd (%rdi,%rax,8), %xmm2
addsd (%r11,%rax,8), %xmm4
divsd %xmm5, %xmm3
addsd %xmm6, %xmm4
divsd %xmm4, %xmm2
movl -0x2c(%rbp), %eax
cmpl $0x1, %eax
je 0x6d3c
movapd %xmm3, %xmm4
subsd %xmm2, %xmm4
ucomisd 0x6322(%rip), %xmm4     # 0xd058
jb 0x706c
ucomisd %xmm2, %xmm3
ja 0x704f
testl %eax, %eax
jne 0x7066
jmp 0x706c
movq 0x18(%rbp), %r8
movslq %r9d, %r9
movsd (%rbx,%r9,8), %xmm1
movslq %edi, %r10
movsbq (%r14,%r10), %r10
imulq $0x7d, %r10, %r10
movslq %edx, %r11
movsbq (%r14,%r11), %r11
imulq $0x19, %r11, %r11
addq %r10, %r11
movslq %esi, %r10
movsbq (%r15,%r10), %r10
leaq (%r10,%r10,4), %r10
movslq %ecx, %rbx
movsbq (%r15,%rbx), %rbx
addq %r10, %rbx
addq %r11, %rbx
addsd (%r8,%rbx,8), %xmm1
movq 0x10(%rbp), %r8
movq 0x38(%rbp), %r10
movsd (%r10,%r9,8), %xmm0
addsd (%r8,%rbx,8), %xmm0
movq %rax, %rbx
movq 0x88(%rbp), %r8
decl %edi
movq 0x78(%rbp), %rax
movl 0x8(%rax), %eax
imull %eax, %edi
addl %edi, %esi
decl %esi
movslq %esi, %rsi
movq 0x80(%rbp), %rdi
addsd (%rdi,%rsi,8), %xmm1
movapd 0x6300(%rip), %xmm3     # 0xd0e0
andpd %xmm1, %xmm3
movsd 0x6244(%rip), %xmm2     # 0xd030
ucomisd %xmm2, %xmm3
ja 0x6e6c
addsd (%r8,%rsi,8), %xmm0
jmp 0x6e74
movsd 0x623e(%rip), %xmm0     # 0xd040
movq %rax, %rbx
movq 0x88(%rbp), %rdi
cmpltsd %xmm3, %xmm2
movapd %xmm2, %xmm3
andnpd %xmm1, %xmm3
movsd 0x6207(%rip), %xmm1     # 0xd028
andpd %xmm2, %xmm1
orpd %xmm3, %xmm1
movq 0x70(%rbp), %rax
movsd (%rax), %xmm2
movsd 0x8(%rax), %xmm4
movapd %xmm1, %xmm3
addsd %xmm2, %xmm3
movapd %xmm0, %xmm5
addsd %xmm4, %xmm5
movsd 0x10(%rax), %xmm6
addsd %xmm6, %xmm5
divsd %xmm5, %xmm3
decl %edx
imull %edx, %r9d
leal (%rcx,%r9), %eax
decl %eax
cltq
addsd (%r8,%rax,8), %xmm2
jmp 0x703c
movsd 0x61cc(%rip), %xmm0     # 0xd040
cmpltsd %xmm3, %xmm2
movapd %xmm2, %xmm3
andnpd %xmm1, %xmm3
movsd 0x619f(%rip), %xmm1     # 0xd028
andpd %xmm2, %xmm1
orpd %xmm3, %xmm1
movq 0x70(%rbp), %rsi
movsd (%rsi), %xmm2
movsd 0x8(%rsi), %xmm4
movapd %xmm1, %xmm3
addsd %xmm2, %xmm3
movapd %xmm4, %xmm5
addsd %xmm0, %xmm5
movsd 0x10(%rsi), %xmm6
addsd %xmm6, %xmm5
divsd %xmm5, %xmm3
decl %edx
imull %edx, %eax
addl %ecx, %eax
decl %eax
cltq
addsd (%rdi,%rax,8), %xmm2
addsd (%r8,%rax,8), %xmm4
jmp 0x7041
movq 0x40(%rbp), %rax
movslq %r9d, %r9
movsd (%rax,%r9,8), %xmm1
movslq %edi, %rax
movsbq (%r14,%rax), %r8
imulq $0x7d, %r8, %r8
movsbq 0x1(%r14,%rax), %rax
imulq $0x19, %rax, %rax
addq %r8, %rax
movslq %esi, %r8
movsbq (%r15,%r8), %r10
leaq (%r10,%r10,4), %r11
movsbq 0x1(%r15,%r8), %r10
addq %r11, %r10
addq %rax, %r10
movslq %ecx, %rax
movsbq (%r15,%rax), %r8
movsbq -0x1(%r15,%rax), %rax
imulq $0x7d, %r8, %r8
imulq $0x19, %rax, %r11
addq %r8, %r11
movslq %edx, %rax
movsbq (%r14,%rax), %rdx
leaq (%rdx,%rdx,4), %rdx
movsbq -0x1(%r14,%rax), %r14
addq %rdx, %r14
addq %r11, %r14
movq 0x58(%rbp), %rdx
addsd (%rdx,%r10,8), %xmm1
addsd (%rdx,%r14,8), %xmm1
decl %edi
movq 0x78(%rbp), %rdx
movl 0x8(%rdx), %edx
imull %edx, %edi
addl %edi, %esi
decl %esi
decq %rax
subl %r13d, %r12d
movl %r12d, %edi
negl %edi
cmovsl %r12d, %edi
movslq %esi, %rsi
movq 0x80(%rbp), %r15
addsd (%r15,%rsi,8), %xmm1
movapd 0x6154(%rip), %xmm3     # 0xd0e0
andpd %xmm1, %xmm3
movsd 0x6098(%rip), %xmm2     # 0xd030
ucomisd %xmm2, %xmm3
ja 0x6fd6
movq 0x50(%rbp), %r8
movq 0x30(%rbp), %r11
movsd (%r11,%r9,8), %xmm4
addsd (%r8,%r10,8), %xmm4
addsd (%r8,%r14,8), %xmm4
cvtsi2sd %edi, %xmm0
mulsd 0x608c(%rip), %xmm0     # 0xd050
addsd %xmm4, %xmm0
movq 0x88(%rbp), %rdi
addsd (%rdi,%rsi,8), %xmm0
jmp 0x6fe5
movsd 0x6062(%rip), %xmm0     # 0xd040
movq 0x88(%rbp), %rdi
cmpltsd %xmm3, %xmm2
movapd %xmm2, %xmm3
andnpd %xmm1, %xmm3
movsd 0x602e(%rip), %xmm1     # 0xd028
andpd %xmm2, %xmm1
orpd %xmm3, %xmm1
movq 0x70(%rbp), %rsi
movsd (%rsi), %xmm2
movsd 0x8(%rsi), %xmm4
movapd %xmm1, %xmm3
addsd %xmm2, %xmm3
movapd %xmm4, %xmm5
addsd %xmm0, %xmm5
movsd 0x10(%rsi), %xmm6
addsd %xmm6, %xmm5
divsd %xmm5, %xmm3
imull %eax, %edx
leal (%rcx,%rdx), %eax
decl %eax
cltq
addsd (%r15,%rax,8), %xmm2
addsd (%rdi,%rax,8), %xmm4
addsd %xmm6, %xmm4
divsd %xmm4, %xmm2
ucomisd %xmm2, %xmm3
jbe 0x705a
movsd %xmm0, (%rbx)
movsd %xmm1, 0x8(%rbx)
jmp 0x706c
movl -0x2c(%rbp), %eax
testl %eax, %eax
je 0x706c
cmpl $0x1, %eax
je 0x704f
ucomisd %xmm2, %xmm3
jae 0x704f
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq