// File: /workspace/github_c_makefile_star2_O1/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, -0x40(%rbp)
movq 0x98(%rbp), %r15
movq 0x90(%rbp), %r14
movl %edi, %r12d
notl %r12d
addl %edx, %r12d
movl %esi, %r13d
notl %r13d
addl %ecx, %r13d
movl %r12d, %eax
subl $0x1, %eax
setb %bl
leal (%rax,%r13), %r10d
testl %r13d, %r13d
setg %al
movq 0x70(%rbp), %r11
testb %al, %bl
jne 0x7845
testl %r13d, %r13d
setne %al
testl %r12d, %r12d
setle %bl
orb %al, %bl
jne 0x7947
movq 0x48(%rbp), %rbx
movq 0x38(%rbp), %rax
cmpl $0x1, %r13d
setne %r9b
cmpl $0x1, %r12d
setne %r8b
testb %r9b, %r8b
jne 0x789a
movl %r12d, %r8d
xorl $0x1, %r8d
movl %r13d, %r9d
xorl $0x1, %r9d
orl %r13d, %r8d
sete %r13b
orl %r12d, %r9d
je 0x7acc
testb %r13b, %r13b
jne 0x7acc
xorpd %xmm1, %xmm1
movsd 0x67ab(%rip), %xmm0     # 0xe040
jmp 0x7b28
movq 0x68(%rbp), %r8
movslq %r10d, %r12
movsd (%rbx,%r12,8), %xmm1
movslq %edi, %r9
movsbq (%r14,%r9), %r9
leaq (%r9,%r9,4), %r9
movslq %esi, %r10
movsbq (%r15,%r10), %r13
addq %r9, %r13
addsd (%r8,%r13,8), %xmm1
movslq %edx, %r9
movsbq (%r14,%r9), %r9
leaq (%r9,%r9,4), %r9
movslq %ecx, %r10
movsbq (%r15,%r10), %rbx
addq %r9, %rbx
addsd (%r8,%rbx,8), %xmm1
decl %edi
movq 0x78(%rbp), %r8
movl 0x8(%r8), %r10d
imull %r10d, %edi
addl %edi, %esi
decl %esi
movslq %esi, %rsi
movq 0x80(%rbp), %r8
addsd (%r8,%rsi,8), %xmm1
movapd 0x67a5(%rip), %xmm3     # 0xe0b0
andpd %xmm1, %xmm3
movsd 0x6719(%rip), %xmm2     # 0xe030
ucomisd %xmm2, %xmm3
ja 0x7b70
movq 0x60(%rbp), %rdi
movsd (%rax,%r12,8), %xmm0
addsd (%rdi,%r13,8), %xmm0
addsd (%rdi,%rbx,8), %xmm0
movq 0x88(%rbp), %rdi
addsd (%rdi,%rsi,8), %xmm0
jmp 0x7b7f
movl %r12d, %eax
xorl $0x1, %eax
movl %r13d, %r8d
xorl $0x1, %r8d
orl %eax, %r8d
jne 0x7c78
movslq %edi, %rax
movsbq 0x1(%r14,%rax), %r8
leaq (%r8,%r8,4), %r8
leaq (%r8,%r8,4), %r8
movslq %esi, %r9
movsbq (%r15,%r9), %r10
leaq (%r10,%r10,4), %rbx
addq %r8, %rbx
movsbq (%r14,%rax), %rax
imulq $0x7d, %rax, %rax
addq %rax, %rbx
movsbq 0x1(%r15,%r9), %r10
addq %rbx, %r10
movslq %ecx, %rax
movsbq (%r15,%rax), %r8
movsbq -0x1(%r15,%rax), %rax
leaq (%rax,%rax,4), %rax
leaq (%rax,%rax,4), %r9
movslq %edx, %rax
movsbq (%r14,%rax), %rdx
leaq (%rdx,%rdx,4), %rdx
addq %r9, %rdx
imulq $0x7d, %r8, %r8
addq %r8, %rdx
movsbq -0x1(%r14,%rax), %r8
addq %rdx, %r8
movq 0x20(%rbp), %rdx
movsd (%rdx,%r10,8), %xmm2
addsd (%rdx,%r8,8), %xmm2
movq 0x28(%rbp), %rdx
movsd (%rdx,%r10,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
movq 0x88(%rbp), %rdi
addsd (%rdi,%rsi,8), %xmm2
movq 0x80(%rbp), %r8
addsd (%r8,%rsi,8), %xmm1
decq %rax
movapd 0x6692(%rip), %xmm0     # 0xe0b0
andpd %xmm1, %xmm0
movsd 0x6606(%rip), %xmm3     # 0xe030
ucomisd %xmm3, %xmm0
cmpltsd %xmm0, %xmm3
movsd 0x65fd(%rip), %xmm0     # 0xe038
andpd %xmm3, %xmm0
andnpd %xmm2, %xmm3
orpd %xmm3, %xmm0
jbe 0x7a51
movsd 0x65d7(%rip), %xmm1     # 0xe028
movsd (%r11), %xmm2
movsd 0x8(%r11), %xmm4
movapd %xmm2, %xmm3
addsd %xmm1, %xmm3
movapd %xmm4, %xmm5
addsd %xmm0, %xmm5
movsd 0x10(%r11), %xmm6
addsd %xmm6, %xmm5
imull %eax, %edx
leal (%rcx,%rdx), %eax
decl %eax
cltq
addsd (%r8,%rax,8), %xmm2
addsd (%rdi,%rax,8), %xmm4
divsd %xmm5, %xmm3
addsd %xmm6, %xmm4
divsd %xmm4, %xmm2
movl -0x2c(%rbp), %eax
cmpl $0x1, %eax
je 0x7ab5
movapd %xmm3, %xmm4
subsd %xmm2, %xmm4
ucomisd 0x65a9(%rip), %xmm4     # 0xe058
jb 0x7c6d
ucomisd %xmm2, %xmm3
ja 0x7c4c
testl %eax, %eax
jne 0x7c67
jmp 0x7c6d
movq 0x18(%rbp), %r8
movslq %r10d, %r9
movsd (%rbx,%r9,8), %xmm1
movslq %edi, %r10
movsbq (%r14,%r10), %r10
imulq $0x7d, %r10, %r10
movslq %edx, %rbx
movsbq (%r14,%rbx), %rbx
leaq (%rbx,%rbx,4), %rbx
leaq (%rbx,%rbx,4), %rbx
movslq %esi, %r14
movsbq (%r15,%r14), %r14
leaq (%r14,%r14,4), %r14
addq %rbx, %r14
addq %r10, %r14
movslq %ecx, %r10
movsbq (%r15,%r10), %r10
addq %r14, %r10
addsd (%r8,%r10,8), %xmm1
movq 0x10(%rbp), %r8
movsd (%rax,%r9,8), %xmm0
addsd (%r8,%r10,8), %xmm0
decl %edi
movq 0x78(%rbp), %rax
movl 0x8(%rax), %eax
imull %eax, %edi
addl %edi, %esi
decl %esi
movslq %esi, %rsi
movq 0x80(%rbp), %r8
addsd (%r8,%rsi,8), %xmm1
movapd 0x6560(%rip), %xmm3     # 0xe0b0
andpd %xmm1, %xmm3
movsd 0x64d4(%rip), %xmm2     # 0xe030
ucomisd %xmm2, %xmm3
ja 0x7bd3
movq 0x88(%rbp), %rdi
addsd (%rdi,%rsi,8), %xmm0
jmp 0x7be2
movsd 0x64c0(%rip), %xmm0     # 0xe038
movq 0x88(%rbp), %rdi
cmpltsd %xmm3, %xmm2
movapd %xmm2, %xmm3
andnpd %xmm1, %xmm3
movsd 0x6494(%rip), %xmm1     # 0xe028
andpd %xmm2, %xmm1
orpd %xmm3, %xmm1
movsd (%r11), %xmm2
movsd 0x8(%r11), %xmm4
movapd %xmm1, %xmm3
addsd %xmm2, %xmm3
movapd %xmm0, %xmm5
addsd %xmm4, %xmm5
movsd 0x10(%r11), %xmm6
addsd %xmm6, %xmm5
divsd %xmm5, %xmm3
decl %edx
imull %edx, %r10d
leal (%rcx,%r10), %eax
decl %eax
jmp 0x7c31
movsd 0x645d(%rip), %xmm0     # 0xe038
movq 0x88(%rbp), %rdi
cmpltsd %xmm3, %xmm2
movapd %xmm2, %xmm3
andnpd %xmm1, %xmm3
movsd 0x6431(%rip), %xmm1     # 0xe028
andpd %xmm2, %xmm1
orpd %xmm3, %xmm1
movsd (%r11), %xmm2
movsd 0x8(%r11), %xmm4
movapd %xmm1, %xmm3
addsd %xmm2, %xmm3
movapd %xmm4, %xmm5
addsd %xmm0, %xmm5
movsd 0x10(%r11), %xmm6
addsd %xmm6, %xmm5
divsd %xmm5, %xmm3
decl %edx
imull %edx, %eax
addl %ecx, %eax
decl %eax
cltq
addsd (%r8,%rax,8), %xmm2
addsd (%rdi,%rax,8), %xmm4
addsd %xmm6, %xmm4
divsd %xmm4, %xmm2
ucomisd %xmm2, %xmm3
jbe 0x7c5b
movq -0x40(%rbp), %rax
movsd %xmm0, (%rax)
movsd %xmm1, 0x8(%rax)
jmp 0x7c6d
movl -0x2c(%rbp), %eax
testl %eax, %eax
je 0x7c6d
cmpl $0x1, %eax
je 0x7c4c
ucomisd %xmm2, %xmm3
jae 0x7c4c
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x40(%rbp), %rax
movslq %r10d, %r8
movq %r8, -0x38(%rbp)
movsd (%rax,%r8,8), %xmm1
movslq %edi, %rax
movsbq 0x1(%r14,%rax), %r8
leaq (%r8,%r8,4), %r8
leaq (%r8,%r8,4), %r8
movslq %esi, %r9
movsbq (%r15,%r9), %r10
leaq (%r10,%r10,4), %rbx
addq %r8, %rbx
movsbq (%r14,%rax), %rax
imulq $0x7d, %rax, %rax
addq %rax, %rbx
movsbq 0x1(%r15,%r9), %r10
addq %rbx, %r10
movslq %ecx, %rax
movsbq (%r15,%rax), %r8
movsbq -0x1(%r15,%rax), %rax
leaq (%rax,%rax,4), %rax
leaq (%rax,%rax,4), %r9
movslq %edx, %rax
movsbq (%r14,%rax), %rdx
leaq (%rdx,%rdx,4), %rdx
addq %r9, %rdx
imulq $0x7d, %r8, %r8
addq %r8, %rdx
movsbq -0x1(%r14,%rax), %r14
addq %rdx, %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), %rbx
addsd (%rbx,%rsi,8), %xmm1
movapd 0x6377(%rip), %xmm3     # 0xe0b0
andpd %xmm1, %xmm3
movsd 0x62eb(%rip), %xmm2     # 0xe030
ucomisd %xmm2, %xmm3
ja 0x7d87
movq 0x50(%rbp), %r8
movq 0x30(%rbp), %r9
movq -0x38(%rbp), %r15
movsd (%r9,%r15,8), %xmm4
addsd (%r8,%r10,8), %xmm4
addsd (%r8,%r14,8), %xmm4
cvtsi2sd %edi, %xmm0
mulsd 0x62db(%rip), %xmm0     # 0xe050
addsd %xmm4, %xmm0
movq 0x88(%rbp), %rdi
addsd (%rdi,%rsi,8), %xmm0
jmp 0x7d96
movsd 0x62a9(%rip), %xmm0     # 0xe038
movq 0x88(%rbp), %rdi
cmpltsd %xmm3, %xmm2
movapd %xmm2, %xmm3
andnpd %xmm1, %xmm3
movsd 0x627d(%rip), %xmm1     # 0xe028
andpd %xmm2, %xmm1
orpd %xmm3, %xmm1
movsd (%r11), %xmm2
movsd 0x8(%r11), %xmm4
movapd %xmm1, %xmm3
addsd %xmm2, %xmm3
movapd %xmm4, %xmm5
addsd %xmm0, %xmm5
movsd 0x10(%r11), %xmm6
addsd %xmm6, %xmm5
divsd %xmm5, %xmm3
imull %eax, %edx
leal (%rcx,%rdx), %eax
decl %eax
cltq
addsd (%rbx,%rax,8), %xmm2
jmp 0x7c39