// File: /workspace/github_c_makefile_star2_O1/asford[P]tmalign/./TMalign.h
// Function: score_matrix_rmsd_sec(double**, double**, int, int, int*)
void score_matrix_rmsd_sec(  double **x, 
							 double **y, 
							 int x_len,
							 int y_len,
							 int *y2x
							 )
{
	double t[3], u[3][3];
	double rmsd, dij;
	double d01=d0+1.5;
	if(d01 < D0_MIN) d01=D0_MIN;
	double d02=d01*d01;

	double xx[3];
	int i, k=0;
	for(int j=0; j<y_len; j++)
	{
		i=y2x[j];
		if(i>=0)
		{
			r1[k][0]=x[i][0];  
			r1[k][1]=x[i][1]; 
			r1[k][2]=x[i][2];   
            
			r2[k][0]=y[j][0];  
			r2[k][1]=y[j][1]; 
			r2[k][2]=y[j][2];
			
			k++;
		}
	}
	Kabsch(r1, r2, k, 1, &rmsd, t, u);

	
	for(int ii=0; ii<x_len; ii++)
	{		
		transform(t, u, &x[ii][0], xx);
		for(int jj=0; jj<y_len; jj++)
		{
			dij=dist(xx, &y[jj][0]); 
			if(secx[ii]==secy[jj])
			{
				score[ii+1][jj+1] = 1.0/(1+dij/d02) + 0.5;
			}
			else
			{
				score[ii+1][jj+1] = 1.0/(1+dij/d02);
			}		
		}
	}		
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x80, %rsp
movl %ecx, %ebx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
movsd 0x1f985a(%rip), %xmm0   # 0x602580
addsd 0x17b352(%rip), %xmm0   # 0x584080
maxsd 0x1f9832(%rip), %xmm0   # 0x602568
movsd %xmm0, 0x8(%rsp)
movl %ecx, %r12d
testl %ecx, %ecx
jle 0x408dbb
movq 0x1f98ce(%rip), %rax    # 0x602618
movq 0x1f98cf(%rip), %rcx    # 0x602620
xorl %esi, %esi
xorl %edx, %edx
movslq (%r8,%rsi,4), %rdi
testq %rdi, %rdi
js 0x408db1
movq (%r15,%rdi,8), %rdi
movsd (%rdi), %xmm0
movslq %edx, %rdx
movq (%rax,%rdx,8), %r9
movsd %xmm0, (%r9)
movsd 0x8(%rdi), %xmm0
movsd %xmm0, 0x8(%r9)
movsd 0x10(%rdi), %xmm0
movsd %xmm0, 0x10(%r9)
movq (%r14,%rsi,8), %rdi
movsd (%rdi), %xmm0
movq (%rcx,%rdx,8), %r9
movsd %xmm0, (%r9)
movsd 0x8(%rdi), %xmm0
movsd %xmm0, 0x8(%r9)
movsd 0x10(%rdi), %xmm0
movsd %xmm0, 0x10(%r9)
incl %edx
incq %rsi
cmpq %rsi, %r12
jne 0x408d55
jmp 0x408dbd
xorl %edx, %edx
movq 0x1f9854(%rip), %rdi    # 0x602618
movq 0x1f9855(%rip), %rsi    # 0x602620
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
leaq 0x78(%rsp), %r8
leaq 0x60(%rsp), %r9
movl $0x1, %ecx
callq 0x406168
testl %ebp, %ebp
jle 0x408f76
movsd 0x8(%rsp), %xmm10
mulsd %xmm10, %xmm10
movsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
movsd 0x20(%rsp), %xmm3
movupd 0x28(%rsp), %xmm4
movapd 0x30(%rsp), %xmm5
movupd 0x38(%rsp), %xmm6
movupd 0x68(%rsp), %xmm7
movq 0x1f97cf(%rip), %rax    # 0x602608
movq 0x1f97d0(%rip), %rcx    # 0x602610
movhpd 0x40(%rsp), %xmm4       # xmm4 = xmm4[0],mem[0]
movhpd 0x48(%rsp), %xmm5       # xmm5 = xmm5[0],mem[0]
movl %ebp, %edx
movhpd 0x50(%rsp), %xmm6       # xmm6 = xmm6[0],mem[0]
movsd 0x17b1ab(%rip), %xmm8   # 0x584008
movapd %xmm8, %xmm9
divsd %xmm10, %xmm9
xorl %esi, %esi
movsd 0x17b1a6(%rip), %xmm10  # 0x584018
testl %ebx, %ebx
jle 0x408f6a
movq (%r15,%rsi,8), %rdi
movsd (%rdi), %xmm13
movsd 0x8(%rdi), %xmm14
movapd %xmm13, %xmm15
mulsd %xmm1, %xmm15
addsd 0x8(%rsp), %xmm15
movapd %xmm14, %xmm0
mulsd %xmm2, %xmm0
movsd 0x10(%rdi), %xmm11
movapd %xmm11, %xmm12
mulsd %xmm3, %xmm12
addsd %xmm0, %xmm12
addsd %xmm15, %xmm12
unpcklpd %xmm13, %xmm13          # xmm13 = xmm13[0,0]
mulpd %xmm4, %xmm13
addpd %xmm7, %xmm13
unpcklpd %xmm14, %xmm14          # xmm14 = xmm14[0,0]
mulpd %xmm5, %xmm14
unpcklpd %xmm11, %xmm11          # xmm11 = xmm11[0,0]
mulpd %xmm6, %xmm11
addpd %xmm14, %xmm11
addpd %xmm13, %xmm11
movl (%rax,%rsi,4), %edi
movq 0x1f96a4(%rip), %r8     # 0x602598
movq 0x8(%r8,%rsi,8), %r8
xorl %r9d, %r9d
movq (%r14,%r9,8), %r10
movapd %xmm12, %xmm0
subsd (%r10), %xmm0
mulsd %xmm0, %xmm0
movupd 0x8(%r10), %xmm13
movapd %xmm11, %xmm14
subpd %xmm13, %xmm14
mulpd %xmm14, %xmm14
addsd %xmm14, %xmm0
unpckhpd %xmm14, %xmm14          # xmm14 = xmm14[1,1]
addsd %xmm0, %xmm14
mulsd %xmm9, %xmm14
addsd %xmm8, %xmm14
movapd %xmm8, %xmm13
divsd %xmm14, %xmm13
movapd %xmm13, %xmm14
addsd %xmm10, %xmm14
cmpl (%rcx,%r9,4), %edi
je 0x408f5b
movapd %xmm13, %xmm14
movsd %xmm14, 0x8(%r8,%r9,8)
incq %r9
cmpq %r9, %r12
jne 0x408efc
incq %rsi
cmpq %rdx, %rsi
jne 0x408e72
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq