// File: /workspace/github_c_makefile_star2_O0/jiqingxiaoxi[P]RPA/RPA.c
// Function: calc_hairpin
void calc_hairpin(int i,int j,double *EntropyEnthalpy,int traceback,double hairpinLoopEntropies[],double hairpinLoopEnthalpies[],double tstack2Entropies[],double tstack2Enthalpies[],char *triloopEntropies1,char *triloopEnthalpies1,char *tetraloopEntropies1,char *tetraloopEnthalpies1,double *triloopEntropies2,double *triloopEnthalpies2,double *tetraloopEntropies2,double *tetraloopEnthalpies2,int numTriloops,int numTetraloops,double atpS[],double atpH[],double Initdouble[],int Initint[],double enthalpyDPT[],double entropyDPT[],char numSeq1[])
{
	int pos,loopSize=j-i-1;
	double T1,T2;
	
	if(loopSize < 3)
	{
		EntropyEnthalpy[0]=-1.0;
		EntropyEnthalpy[1]=1.0*INFINITY;
		return;
	}
	if(i<=Initint[0]&&Initint[1]<j)
	{
		EntropyEnthalpy[0]=-1.0;
		EntropyEnthalpy[1]=1.0*INFINITY;
		return;
	}
	else if(i>Initint[1])
	{
		i-= Initint[0];
		j-= Initint[1];
	}
	if(loopSize<=30)
	{
		EntropyEnthalpy[1]=hairpinLoopEnthalpies[loopSize-1];
		EntropyEnthalpy[0]=hairpinLoopEntropies[loopSize-1];
	}
	else
	{
		EntropyEnthalpy[1]=hairpinLoopEnthalpies[29];
		EntropyEnthalpy[0]=hairpinLoopEntropies[29];
	}

	if(loopSize>3) // for loops 4 bp and more in length, terminal mm are accounted
	{
		EntropyEnthalpy[1]+=tstack2Enthalpies[numSeq1[i]*125+numSeq1[i+1]*25+numSeq1[j]*5+numSeq1[j-1]];
		EntropyEnthalpy[0]+=tstack2Entropies[numSeq1[i]*125+numSeq1[i+1]*25+numSeq1[j]*5+numSeq1[j-1]];
	}
	else if(loopSize == 3) // for loops 3 bp in length at-penalty is considered
	{
		EntropyEnthalpy[1]+=atpH[numSeq1[i]*5+numSeq1[j]];
		EntropyEnthalpy[0]+=atpS[numSeq1[i]*5+numSeq1[j]];
	}

	if(loopSize==3) // closing AT-penalty (+), triloop bonus, hairpin of 3 (+) 
	{
		pos=find_pos(numSeq1,i,triloopEnthalpies1,5,numTriloops);
		if(pos!=-1)
			EntropyEnthalpy[1]+=triloopEnthalpies2[pos];

		pos=find_pos(numSeq1,i,triloopEntropies1,5,numTriloops);
		if(pos!=-1)
			EntropyEnthalpy[0]+=triloopEntropies2[pos];
	}
	else if (loopSize == 4) // terminal mismatch, tetraloop bonus, hairpin of 4
	{
		pos=find_pos(numSeq1,i,tetraloopEnthalpies1,6,numTetraloops);
		if(pos!=-1)
			EntropyEnthalpy[1]+=tetraloopEnthalpies2[pos];

		pos=find_pos(numSeq1,i,tetraloopEntropies1,6,numTetraloops);
		if(pos!=-1)
			EntropyEnthalpy[0]+=tetraloopEntropies2[pos];
	}
	if(fabs(EntropyEnthalpy[1])>999999999)
	{
		EntropyEnthalpy[1] =1.0*INFINITY;
		EntropyEnthalpy[0] = -1.0;
	}
	T1 = (EntropyEnthalpy[1] +Initdouble[0]) / ((EntropyEnthalpy[0] +Initdouble[1]+ Initdouble[2]));
	T2 = (enthalpyDPT[(i-1)*Initint[2]+j-1] +Initdouble[0]) / ((entropyDPT[(i-1)*Initint[2]+j-1]) +Initdouble[1]+ Initdouble[2]);
	if(T1 < T2 && traceback == 0)
	{
		EntropyEnthalpy[0] =entropyDPT[(i-1)*Initint[2]+j-1];
		EntropyEnthalpy[1] =enthalpyDPT[(i-1)*Initint[2]+j-1];
	}
	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq 0xa0(%rbp), %rax
movq 0x98(%rbp), %rax
movq 0x90(%rbp), %rax
movq 0x88(%rbp), %rax
movq 0x80(%rbp), %rax
movq 0x78(%rbp), %rax
movq 0x70(%rbp), %rax
movl 0x68(%rbp), %eax
movl 0x60(%rbp), %eax
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movl -0x8(%rbp), %eax
subl -0x4(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x30(%rbp)
cmpl $0x3, -0x30(%rbp)
jge 0x522e
movq -0x10(%rbp), %rax
movsd 0x11f2c(%rip), %xmm0    # 0x17140
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rax
movsd 0x11f0c(%rip), %xmm0    # 0x17130
movsd %xmm0, 0x8(%rax)
jmp 0x56fc
movl -0x4(%rbp), %eax
movq 0x88(%rbp), %rcx
cmpl (%rcx), %eax
jg 0x5271
movq 0x88(%rbp), %rax
movl 0x4(%rax), %eax
cmpl -0x8(%rbp), %eax
jge 0x5271
movq -0x10(%rbp), %rax
movsd 0x11ee9(%rip), %xmm0    # 0x17140
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rax
movsd 0x11ec9(%rip), %xmm0    # 0x17130
movsd %xmm0, 0x8(%rax)
jmp 0x56fc
movl -0x4(%rbp), %eax
movq 0x88(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jle 0x52a3
movq 0x88(%rbp), %rax
movl (%rax), %ecx
movl -0x4(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x4(%rbp)
movq 0x88(%rbp), %rax
movl 0x4(%rax), %ecx
movl -0x8(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x8(%rbp)
jmp 0x52a5
cmpl $0x1e, -0x30(%rbp)
jg 0x52e2
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x530b
movq -0x28(%rbp), %rax
movsd 0xe8(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x20(%rbp), %rax
movsd 0xe8(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
cmpl $0x3, -0x30(%rbp)
jle 0x53f6
movq 0x18(%rbp), %rax
movq 0xa0(%rbp), %rcx
movslq -0x4(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
imull $0x7d, %ecx, %ecx
movq 0xa0(%rbp), %rdx
movl -0x4(%rbp), %esi
addl $0x1, %esi
movslq %esi, %rsi
movsbl (%rdx,%rsi), %edx
imull $0x19, %edx, %edx
addl %edx, %ecx
movq 0xa0(%rbp), %rdx
movslq -0x8(%rbp), %rsi
movsbl (%rdx,%rsi), %edx
imull $0x5, %edx, %edx
addl %edx, %ecx
movq 0xa0(%rbp), %rdx
movl -0x8(%rbp), %esi
subl $0x1, %esi
movslq %esi, %rsi
movsbl (%rdx,%rsi), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
addsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%rax)
movq 0x10(%rbp), %rax
movq 0xa0(%rbp), %rcx
movslq -0x4(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
imull $0x7d, %ecx, %ecx
movq 0xa0(%rbp), %rdx
movl -0x4(%rbp), %esi
addl $0x1, %esi
movslq %esi, %rsi
movsbl (%rdx,%rsi), %edx
imull $0x19, %edx, %edx
addl %edx, %ecx
movq 0xa0(%rbp), %rdx
movslq -0x8(%rbp), %rsi
movsbl (%rdx,%rsi), %edx
imull $0x5, %edx, %edx
addl %edx, %ecx
movq 0xa0(%rbp), %rdx
movl -0x8(%rbp), %esi
subl $0x1, %esi
movslq %esi, %rsi
movsbl (%rdx,%rsi), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
jmp 0x5476
cmpl $0x3, -0x30(%rbp)
jne 0x5474
movq 0x78(%rbp), %rax
movq 0xa0(%rbp), %rcx
movslq -0x4(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
imull $0x5, %ecx, %ecx
movq 0xa0(%rbp), %rdx
movslq -0x8(%rbp), %rsi
movsbl (%rdx,%rsi), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
addsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%rax)
movq 0x70(%rbp), %rax
movq 0xa0(%rbp), %rcx
movslq -0x4(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
imull $0x5, %ecx, %ecx
movq 0xa0(%rbp), %rdx
movslq -0x8(%rbp), %rsi
movsbl (%rdx,%rsi), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
jmp 0x5476
cmpl $0x3, -0x30(%rbp)
jne 0x5503
movq 0xa0(%rbp), %rdi
movl -0x4(%rbp), %esi
movq 0x28(%rbp), %rdx
movl 0x60(%rbp), %r8d
movl $0x5, %ecx
callq 0x50d0
movl %eax, -0x2c(%rbp)
cmpl $-0x1, -0x2c(%rbp)
je 0x54c0
movq 0x48(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
addsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%rax)
movq 0xa0(%rbp), %rdi
movl -0x4(%rbp), %esi
movq 0x20(%rbp), %rdx
movl 0x60(%rbp), %r8d
movl $0x5, %ecx
callq 0x50d0
movl %eax, -0x2c(%rbp)
cmpl $-0x1, -0x2c(%rbp)
je 0x54fe
movq 0x40(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
jmp 0x558f
cmpl $0x4, -0x30(%rbp)
jne 0x558d
movq 0xa0(%rbp), %rdi
movl -0x4(%rbp), %esi
movq 0x38(%rbp), %rdx
movl 0x68(%rbp), %r8d
movl $0x6, %ecx
callq 0x50d0
movl %eax, -0x2c(%rbp)
cmpl $-0x1, -0x2c(%rbp)
je 0x554d
movq 0x58(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
addsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%rax)
movq 0xa0(%rbp), %rdi
movl -0x4(%rbp), %esi
movq 0x30(%rbp), %rdx
movl 0x68(%rbp), %r8d
movl $0x6, %ecx
callq 0x50d0
movl %eax, -0x2c(%rbp)
cmpl $-0x1, -0x2c(%rbp)
je 0x558b
movq 0x50(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
jmp 0x558d
jmp 0x558f
movq -0x10(%rbp), %rax
movsd 0x8(%rax), %xmm0
movaps 0x11c51(%rip), %xmm1    # 0x171f0
pand %xmm1, %xmm0
movsd 0x11b8d(%rip), %xmm1    # 0x17138
ucomisd %xmm1, %xmm0
jbe 0x55d2
movq -0x10(%rbp), %rax
movsd 0x11b73(%rip), %xmm0    # 0x17130
movsd %xmm0, 0x8(%rax)
movq -0x10(%rbp), %rax
movsd 0x11b72(%rip), %xmm0    # 0x17140
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq 0x80(%rbp), %rax
addsd (%rax), %xmm0
movq -0x10(%rbp), %rax
movsd (%rax), %xmm1
movq 0x80(%rbp), %rax
addsd 0x8(%rax), %xmm1
movq 0x80(%rbp), %rax
addsd 0x10(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x90(%rbp), %rax
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
movq 0x88(%rbp), %rdx
imull 0x8(%rdx), %ecx
addl -0x8(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x80(%rbp), %rax
addsd (%rax), %xmm0
movq 0x98(%rbp), %rax
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
movq 0x88(%rbp), %rdx
imull 0x8(%rdx), %ecx
addl -0x8(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x80(%rbp), %rax
addsd 0x8(%rax), %xmm1
movq 0x80(%rbp), %rax
addsd 0x10(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x38(%rbp), %xmm1
movsd -0x40(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x56fa
cmpl $0x0, -0x14(%rbp)
jne 0x56fa
movq 0x98(%rbp), %rax
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
movq 0x88(%rbp), %rdx
imull 0x8(%rdx), %ecx
addl -0x8(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
movq 0x90(%rbp), %rax
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
movq 0x88(%rbp), %rdx
imull 0x8(%rdx), %ecx
addl -0x8(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0x56fc
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)