// File: /workspace/github_c_makefile_star2_O3/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)
cmpl $0x5, %edi
jge 0x46b0
movsd 0x998d(%rip), %xmm15    # 0xe030
movsd 0x996d(%rip), %xmm0     # 0xe018
jmp 0x4876
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rsi
movq 0x20(%rbp), %r11
movq 0x18(%rbp), %rbx
movq 0x10(%rbp), %r14
movsd (%r8), %xmm1
movsd 0x8(%r8), %xmm2
movsd 0x10(%r8), %xmm3
movapd %xmm2, %xmm0
addsd %xmm3, %xmm0
movapd %xmm1, %xmm4
divsd %xmm0, %xmm4
movl %edi, %r10d
leal -0x1(%rdi), %r8d
addl $-0x4, %edi
movsbq (%rax,%r10), %r15
movsd 0x9953(%rip), %xmm11    # 0xe050
movsd 0x9913(%rip), %xmm5     # 0xe018
movsd 0x9923(%rip), %xmm6     # 0xe030
xorl %r12d, %r12d
movsd 0x9907(%rip), %xmm9     # 0xe020
movsd 0x9916(%rip), %xmm8     # 0xe038
movapd %xmm6, %xmm12
movapd %xmm5, %xmm13
movsd (%rsi,%r12,8), %xmm15
movapd %xmm15, %xmm0
addsd %xmm1, %xmm0
movsd (%r11,%r12,8), %xmm7
movapd %xmm7, %xmm14
addsd %xmm2, %xmm14
addsd %xmm3, %xmm14
divsd %xmm14, %xmm0
movsbq 0x1(%rax,%r12), %r10
leaq (%r10,%r10,4), %r13
addq %r15, %r13
ucomisd %xmm4, %xmm0
movsd (%rcx,%r13,8), %xmm0
jae 0x478f
movl 0x8(%r9), %r10d
imull %r12d, %r10d
addl %r8d, %r10d
movslq %r10d, %r10
addsd (%r14,%r10,8), %xmm0
movsd (%rdx,%r13,8), %xmm7
movapd %xmm0, %xmm15
jmp 0x47ae
addsd %xmm0, %xmm15
movl 0x8(%r9), %r10d
imull %r12d, %r10d
addl %r8d, %r10d
movslq %r10d, %r10
addsd (%r14,%r10,8), %xmm15
addsd (%rdx,%r13,8), %xmm7
addsd (%rbx,%r10,8), %xmm7
movapd %xmm15, %xmm0
andpd 0x98ff(%rip), %xmm0     # 0xe0c0
movapd %xmm9, %xmm14
cmpltpd %xmm0, %xmm14
xorpd %xmm0, %xmm0
cmpltpd %xmm15, %xmm0
orpd %xmm14, %xmm0
ucomisd 0x9875(%rip), %xmm7     # 0xe058
seta %r10b
movd %xmm0, %r13d
orb %r13b, %r10b
movapd %xmm5, %xmm0
testb $0x1, %r10b
jne 0x47fe
movapd %xmm15, %xmm0
movapd %xmm6, %xmm15
jne 0x480a
movapd %xmm7, %xmm15
movapd %xmm1, %xmm14
addsd %xmm0, %xmm14
movapd %xmm15, %xmm7
addsd %xmm2, %xmm7
addsd %xmm3, %xmm7
divsd %xmm7, %xmm14
movapd %xmm11, %xmm7
cmpltpd %xmm14, %xmm7
movapd %xmm8, %xmm10
cmpltpd %xmm15, %xmm10
andpd %xmm7, %xmm10
movd %xmm10, %r10d
testb $0x1, %r10b
jne 0x485b
movapd %xmm11, %xmm14
movapd %xmm13, %xmm0
movapd %xmm12, %xmm15
incq %r12
movapd %xmm15, %xmm12
movapd %xmm0, %xmm13
movapd %xmm14, %xmm11
cmpq %r12, %rdi
jne 0x472c
cmpl $0x1, -0x2c(%rbp)
je 0x4881
movapd %xmm15, %xmm0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq