// File: /workspace/github_c_makefile_star2_O2/jiqingxiaoxi[P]RPA/RPA.c
// Function: END5_1
double END5_1(int i,int hs,double atpS[],double atpH[],double Initdouble[],int Initint[],double enthalpyDPT[],double entropyDPT[],double send5[],double hend5[],char numSeq1[])
{
	int k;
	double max_tm,T1,T2,H,S,H_max,S_max;

	max_tm=-1.0*INFINITY;
	H_max=1.0*INFINITY;
	S_max=-1.0;
	for(k=0;k<=i-5;++k)
	{
		T1=(hend5[k]+Initdouble[0])/(send5[k]+Initdouble[1]+Initdouble[2]);
		T2=Initdouble[0]/(Initdouble[1]+Initdouble[2]);
		if(T1>=T2)
		{
			H=hend5[k]+atpH[numSeq1[k+1]*5+numSeq1[i]]+enthalpyDPT[k*Initint[2]+i-1];
			S=send5[k]+atpS[numSeq1[k+1]*5+numSeq1[i]]+entropyDPT[k*Initint[2]+i-1];
			if(fabs(H)>999999999||H>0||S>0)  // H and S must be greater than 0 to avoid BS
			{
				H=1.0*INFINITY;
				S=-1.0;
			}
			T1=(H+Initdouble[0])/(S+Initdouble[1]+Initdouble[2]);
		}
		else
		{
			H=atpH[numSeq1[k+1]*5+numSeq1[i]]+enthalpyDPT[k*Initint[2]+i-1];
			S=atpS[numSeq1[k+1]*5+numSeq1[i]]+entropyDPT[k*Initint[2]+i-1];
			if(fabs(H)>999999999||H>0||S>0)
			{
				H=1.0*INFINITY;
				S=-1.0;
			}
			T1=(H+Initdouble[0])/(S+Initdouble[1]+Initdouble[2]);
		}

		if(max_tm<T1)
		{
			if(S>-2500.0)
			{
				H_max=H;
				S_max=S;
				max_tm=T1;
			}
		}
	}
	if(hs==1)
		return H_max;
	return S_max;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %esi, -0x2c(%rbp)
movq 0x30(%rbp), %rax
movq 0x20(%rbp), %r11
movq 0x18(%rbp), %rbx
movq 0x10(%rbp), %r14
movslq %edi, %rdi
cmpl $0x5, %edi
movl $0x4, %r15d
cmovgel %edi, %r15d
leal -0x1(%rdi), %r12d
addl $-0x4, %r15d
movsd 0x8b45(%rip), %xmm1     # 0xd040
movsd 0x8b25(%rip), %xmm2     # 0xd028
movsd 0x8b55(%rip), %xmm3     # 0xd060
xorpd %xmm4, %xmm4
movsd 0x8b19(%rip), %xmm5     # 0xd030
movsd 0x8b29(%rip), %xmm6     # 0xd048
movapd %xmm2, %xmm0
movapd %xmm1, %xmm8
xorl %r13d, %r13d
cmpq %r13, %r15
je 0x46a0
movq 0x28(%rbp), %rsi
movsd (%rsi,%r13,8), %xmm13
movsd (%r8), %xmm7
movsd 0x8(%r8), %xmm10
movapd %xmm13, %xmm14
addsd %xmm7, %xmm14
movsd (%r11,%r13,8), %xmm12
movapd %xmm12, %xmm15
addsd %xmm10, %xmm15
movsd 0x10(%r8), %xmm11
addsd %xmm11, %xmm15
divsd %xmm15, %xmm14
movapd %xmm10, %xmm15
addsd %xmm11, %xmm15
movapd %xmm7, %xmm9
divsd %xmm15, %xmm9
movsbq 0x1(%rax,%r13), %rsi
leaq (%rsi,%rsi,4), %rsi
movsbq (%rax,%rdi), %r10
addq %rsi, %r10
ucomisd %xmm9, %xmm14
movsd (%rcx,%r10,8), %xmm14
jae 0x45c7
movl 0x8(%r9), %esi
imull %r13d, %esi
addl %r12d, %esi
movslq %esi, %rsi
addsd (%r14,%rsi,8), %xmm14
movsd (%rdx,%r10,8), %xmm12
movapd %xmm14, %xmm13
jmp 0x45e6
addsd %xmm14, %xmm13
movl 0x8(%r9), %esi
imull %r13d, %esi
addl %r12d, %esi
movslq %esi, %rsi
addsd (%r14,%rsi,8), %xmm13
addsd (%rdx,%r10,8), %xmm12
addsd (%rbx,%rsi,8), %xmm12
movapd %xmm13, %xmm9
andpd 0x8ae6(%rip), %xmm9     # 0xd0e0
movapd %xmm5, %xmm14
cmpltpd %xmm9, %xmm14
xorpd %xmm9, %xmm9
cmpltpd %xmm13, %xmm9
orpd %xmm14, %xmm9
ucomisd %xmm4, %xmm12
seta %sil
movd %xmm9, %r10d
orb %r10b, %sil
movapd %xmm2, %xmm14
testb $0x1, %sil
jne 0x4636
movapd %xmm13, %xmm14
movapd %xmm1, %xmm13
jne 0x4642
movapd %xmm12, %xmm13
addsd %xmm14, %xmm7
addsd %xmm13, %xmm10
addsd %xmm10, %xmm11
divsd %xmm11, %xmm7
movapd %xmm3, %xmm9
cmpltpd %xmm7, %xmm9
movapd %xmm6, %xmm10
cmpltpd %xmm13, %xmm10
andpd %xmm9, %xmm10
movd %xmm10, %esi
testb $0x1, %sil
jne 0x468a
movapd %xmm3, %xmm7
movapd %xmm0, %xmm14
movapd %xmm8, %xmm13
incq %r13
movapd %xmm7, %xmm3
movapd %xmm14, %xmm0
movapd %xmm13, %xmm8
jmp 0x452b
cmpl $0x1, -0x2c(%rbp)
je 0x46ab
movapd %xmm8, %xmm0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq