// File: /workspace/github_c_makefile_star2_O2/jiqingxiaoxi[P]RPA/RPA.c
// Function: maxTM
void maxTM(int i,int j,double stackEntropies[],double stackEnthalpies[],double Initdouble[],int Initint[],double enthalpyDPT[],double entropyDPT[],char numSeq1[],char numSeq2[])
{
	double T0,T1,S0,S1,H0,H1;

	S0=entropyDPT[(i-1)*Initint[2]+j-1];
	H0=enthalpyDPT[(i-1)*Initint[2]+j-1];
	T0=(H0+Initdouble[0])/(S0+Initdouble[1]+Initdouble[2]); // at current position 
	if(fabs(enthalpyDPT[(i-2)*Initint[2]+j-2])<999999999&&fabs(Hs(i-1,j-1,1,stackEnthalpies,Initint,numSeq1,numSeq2))<999999999)
	{
		S1=(entropyDPT[(i-2)*Initint[2]+j-2]+Ss(i-1,j-1,1,stackEntropies,Initint,numSeq1,numSeq2));
		H1=(enthalpyDPT[(i-2)*Initint[2]+j-2]+Hs(i-1,j-1,1,stackEnthalpies,Initint,numSeq1,numSeq2));
	}
	else
	{
		S1=-1.0;
		H1=1.0*INFINITY;
	}
	T1=(H1+Initdouble[0])/(S1+Initdouble[1]+Initdouble[2]);

	if(S1<-2500.0)
	{
// to not give dH any value if dS is unreasonable
		S1=-3224.0;
		H1=0.0;
	}
	if(S0<-2500.0)
	{
// to not give dH any value if dS is unreasonable
		S0=-3224.0;
		H0=0.0;
	}
	if((T1>T0)||(S0>0&&H0>0)) // T1 on suurem 
	{
		entropyDPT[(i-1)*Initint[2]+j-1]=S1;
		enthalpyDPT[(i-1)*Initint[2]+j-1]=H1;
	}
	else if(T0>=T1)
	{
		entropyDPT[(i-1)*Initint[2]+j-1]=S0;
		enthalpyDPT[(i-1)*Initint[2]+j-1]=H0;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq 0x18(%rbp), %r10
movq 0x10(%rbp), %rax
movslq %edi, %rbx
leaq -0x1(%rbx), %r11
movl 0x8(%r9), %edi
addl $-0x2, %ebx
imull %edi, %ebx
imull %r11d, %edi
addl %esi, %edi
movslq %edi, %rdi
movsd -0x8(%r10,%rdi,8), %xmm1
movsd -0x8(%rax,%rdi,8), %xmm2
movsd (%r8), %xmm0
movsd 0x8(%r8), %xmm3
movapd %xmm1, %xmm4
addsd %xmm3, %xmm4
movsd 0x10(%r8), %xmm5
addl %esi, %ebx
movslq %ebx, %r8
movsd -0x10(%rax,%r8,8), %xmm7
movapd 0x67d0(%rip), %xmm10    # 0xd0e0
andpd %xmm7, %xmm10
movsd 0x670a(%rip), %xmm8     # 0xd028
movsd 0x671a(%rip), %xmm6     # 0xd040
movsd 0x6701(%rip), %xmm9     # 0xd030
ucomisd %xmm10, %xmm9
jbe 0x69a9
movq 0x28(%rbp), %r9
movq 0x20(%rbp), %rbx
movsbq (%rbx,%r11), %r14
movsbq 0x1(%rbx,%r11), %r11
movslq %esi, %rsi
movsbq -0x1(%r9,%rsi), %rbx
movsbq (%r9,%rsi), %rsi
imulq $0x3e8, %r14, %r9       # imm = 0x3E8
addq %r9, %rcx
imulq $0xc8, %r11, %r14
imulq $0x28, %rbx, %r11
addq %r14, %r11
addq %r11, %rcx
movsd (%rcx,%rsi,8), %xmm10
movapd 0x675f(%rip), %xmm11    # 0xd0e0
andpd %xmm10, %xmm11
ucomisd %xmm11, %xmm9
jbe 0x69a9
movsd -0x10(%r10,%r8,8), %xmm6
addq %r9, %rdx
addq %r11, %rdx
addsd (%rdx,%rsi,8), %xmm6
addsd %xmm10, %xmm7
movapd %xmm7, %xmm8
movapd %xmm2, %xmm7
addsd %xmm0, %xmm7
addsd %xmm5, %xmm4
addsd %xmm8, %xmm0
addsd %xmm6, %xmm3
addsd %xmm5, %xmm3
movsd 0x667d(%rip), %xmm11    # 0xd048
ucomisd %xmm6, %xmm11
movapd %xmm6, %xmm5
cmpltsd %xmm11, %xmm5
movsd 0x6655(%rip), %xmm10    # 0xd038
movapd %xmm5, %xmm9
andpd %xmm10, %xmm9
andnpd %xmm6, %xmm5
orpd %xmm9, %xmm5
xorpd %xmm9, %xmm9
xorpd %xmm6, %xmm6
ja 0x6a06
movapd %xmm8, %xmm6
divsd %xmm4, %xmm7
divsd %xmm3, %xmm0
ucomisd %xmm1, %xmm11
ja 0x6a1a
movapd %xmm2, %xmm9
ucomisd %xmm7, %xmm0
ja 0x6a58
movapd %xmm1, %xmm2
cmpltsd %xmm11, %xmm2
andpd %xmm2, %xmm10
andnpd %xmm1, %xmm2
orpd %xmm10, %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm2
jbe 0x6a49
ucomisd %xmm1, %xmm9
ja 0x6a58
ucomisd %xmm0, %xmm7
movapd %xmm2, %xmm5
movapd %xmm9, %xmm6
jb 0x6a65
movsd %xmm5, -0x8(%r10,%rdi,8)
movsd %xmm6, -0x8(%rax,%rdi,8)
popq %rbx
popq %r14
popq %rbp
retq