// File: /workspace/github_c_makefile_star2_O0/asford[P]tmalign/./TMalign.h
// Function: score_matrix_rmsd(double**, double**, int, int, int*)
void score_matrix_rmsd(  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);
	//do_rotation(x, xt, x_len, 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(&xt[ii][0], &y[jj][0]);   
			dij=dist(xx, &y[jj][0]); 
			score[ii+1][jj+1] = 1.0/(1+dij/d02);
			//	cout << ii+1 << " " << jj+1 << " " << score[ii+1][jj+1]<< endl;
		}
	}		
}

// Assembly:
subq $0xe8, %rsp
movq %rdi, 0xe0(%rsp)
movq %rsi, 0xd8(%rsp)
movl %edx, 0xd4(%rsp)
movl %ecx, 0xd0(%rsp)
movq %r8, 0xc8(%rsp)
movsd 0x18064b(%rip), %xmm0   # 0x58c090
addsd 0x1feb33(%rip), %xmm0   # 0x60a580
movsd %xmm0, 0x48(%rsp)
movsd 0x48(%rsp), %xmm1
movsd 0x1feb07(%rip), %xmm0   # 0x60a568
ucomisd %xmm1, %xmm0
jbe 0x40ba75
movsd 0x1feaf9(%rip), %xmm0   # 0x60a568
movsd %xmm0, 0x48(%rsp)
movsd 0x48(%rsp), %xmm0
mulsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movl $0x0, 0x18(%rsp)
movl $0x0, 0x14(%rsp)
movl 0x14(%rsp), %eax
cmpl 0xd0(%rsp), %eax
jge 0x40bbe2
movq 0xc8(%rsp), %rax
movslq 0x14(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x1c(%rsp)
cmpl $0x0, 0x1c(%rsp)
jl 0x40bbd0
movq 0xe0(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd (%rax), %xmm0
movq 0x1feb35(%rip), %rax    # 0x60a618
movslq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, (%rax)
movq 0xe0(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd 0x8(%rax), %xmm0
movq 0x1feb0b(%rip), %rax    # 0x60a618
movslq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, 0x8(%rax)
movq 0xe0(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd 0x10(%rax), %xmm0
movq 0x1feae0(%rip), %rax    # 0x60a618
movslq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, 0x10(%rax)
movq 0xd8(%rsp), %rax
movslq 0x14(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd (%rax), %xmm0
movq 0x1feabe(%rip), %rax    # 0x60a620
movslq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, (%rax)
movq 0xd8(%rsp), %rax
movslq 0x14(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd 0x8(%rax), %xmm0
movq 0x1fea94(%rip), %rax    # 0x60a620
movslq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, 0x8(%rax)
movq 0xd8(%rsp), %rax
movslq 0x14(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd 0x10(%rax), %xmm0
movq 0x1fea69(%rip), %rax    # 0x60a620
movslq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, 0x10(%rax)
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x40bbd2
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x40ba97
movq 0x1fea2f(%rip), %rdi    # 0x60a618
movq 0x1fea30(%rip), %rsi    # 0x60a620
movl 0x18(%rsp), %edx
leaq 0xb0(%rsp), %r9
leaq 0x60(%rsp), %rax
movl $0x1, %ecx
leaq 0x58(%rsp), %r8
movq %rax, (%rsp)
callq 0x4070f0
movl $0x0, 0x10(%rsp)
movl 0x10(%rsp), %eax
cmpl 0xd4(%rsp), %eax
jge 0x40bcf5
leaq 0xb0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
movq 0xe0(%rsp), %rax
movslq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x20(%rsp), %rcx
callq 0x4060e0
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0xd0(%rsp), %eax
jge 0x40bce3
leaq 0x20(%rsp), %rdi
movq 0xd8(%rsp), %rax
movslq 0xc(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x406000
movsd %xmm0, 0x50(%rsp)
movsd 0x50(%rsp), %xmm0
divsd 0x40(%rsp), %xmm0
movsd 0x180369(%rip), %xmm1   # 0x58c008
addsd %xmm0, %xmm1
movsd 0x18035d(%rip), %xmm0   # 0x58c008
divsd %xmm1, %xmm0
movq 0x1fe8e2(%rip), %rax    # 0x60a598
movl 0x10(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl 0xc(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x40bc5d
jmp 0x40bce5
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x40bc1c
addq $0xe8, %rsp
retq
nopl (%rax)