// File: /workspace/github_c_makefile_star2_O1/ugobas[P]tnm/McLachlan_float.c
// Function: rmsd_mclachlan_f
double rmsd_mclachlan_f(float *x1, float *x2, float *wt1, int n)
{

    int i=0,j=0,m=0;
    double cent1[3], cent2[3], rm[3][3];
    double tmpcent[3];
    double rmsd;

    // compute centre of masses for the reference
    // and the mobile proteins
    center_of_mass(cent1,x1,n,wt1);
    center_of_mass(cent2,x2,n,wt1);

    // centre both structures in their centres of masses
    tmpcent[0] = -1.0 * cent1[0];
    tmpcent[1] = -1.0 * cent1[1];
    tmpcent[2] = -1.0 * cent1[2];

    float *tmpatom1=(float *)malloc(3*n*sizeof(float));
    float *x=tmpatom1, *y=x1;
    for(i=0; i<(3*n); i++){*x=*y; x++; y++;}
    TranslateVector(tmpatom1,tmpcent,n);

    tmpcent[0] = -1.0 * cent2[0];
    tmpcent[1] = -1.0 * cent2[1];
    tmpcent[2] = -1.0 * cent2[2];
    TranslateVector(x2,tmpcent,n);

    // compute the superposition
    matfit(tmpatom1,x2,rm,n,wt1,1);
    free(tmpatom1);

    // Print rotation matrix
    if(DBG){
      double sum=0;
      for(i=0; i<n; i++)sum+=wt1[i];
      printf("Average mass: %.2f\n", sum/n);
      printf("Centre of Mass for str1\n");
      printf("\t%.4f %.4f %.4f\n",cent1[0],cent1[1],cent1[2]);
      printf("Centre of Mass for str2\n");
      printf("\t%.4f %.4f %.4f\n",cent2[0],cent2[1],cent2[2]);
      printf("Rotation Matrix\n");
      for (i=0;i<3;i++){
	printf("\t");
	for (j=0;j<3;j++)printf("%.4f ",rm[i][j]);
	printf("\n");
      }
    }

    for (i=0;i<n;i++){
      Apply3Matrix2dot(x2+m,rm);
      m+=3;
    }
    TranslateVector(x2,cent1,n);

    if(0){
      printf("Translation vector (between Centres of masses)\n");
      printf("\t%.4f %.4f %.4f\n",cent1[0]-cent2[0],
	     cent1[1]-cent2[1],cent1[2]-cent2[2]);
    }

    // computes weighted rmsd
    rmsd=rmsd_w(x1,x2,n,wt1);

    if(0)printf("\t mass-weighted RMS: %.4f\n", rmsd);


    return (rmsd);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
movl %ecx, %r12d
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x1f0(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movl %ecx, %edx
movq %rbx, %rcx
callq 0x4ea45
leaq 0x1d0(%rsp), %rdi
movq %r14, %rsi
movl %r12d, %edx
movq %rbx, %rcx
callq 0x4ea45
movaps 0x302e(%rip), %xmm1     # 0x51090
movaps (%r13), %xmm0
xorps %xmm1, %xmm0
movaps %xmm0, 0x1b0(%rsp)
movsd 0x10(%r13), %xmm0
xorps %xmm1, %xmm0
movlps %xmm0, 0x1c0(%rsp)
leal (%r12,%r12,2), %ebp
movslq %ebp, %rdi
shlq $0x2, %rdi
callq 0x21d0
movq %rax, %r13
movq %r12, 0x18(%rsp)
testl %r12d, %r12d
jle 0x4e0ba
cmpl $0x2, %ebp
movl $0x1, %edx
cmovgel %ebp, %edx
shlq $0x2, %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0x21a0
leaq 0x1b0(%rsp), %r12
movq %r13, %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rbp
movl %ebp, %edx
callq 0x4eae8
movapd 0x1d0(%rsp), %xmm0
movapd 0x2fab(%rip), %xmm1     # 0x51090
xorpd %xmm1, %xmm0
movapd %xmm0, (%r12)
movsd 0x1e0(%rsp), %xmm0
xorpd %xmm1, %xmm0
movlpd %xmm0, 0x10(%r12)
movq %r14, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x4eae8
cmpl $0x2, %ebp
jl 0x4e8d7
testq %rbx, %rbx
je 0x4e23a
movl %ebp, %eax
leaq 0x8(%r14), %rcx
movq %r13, %rdx
addq $0x8, %rdx
xorl %esi, %esi
xorpd %xmm0, %xmm0
leaq (%rsi,%rsi,2), %rdi
leaq (%rsp,%rdi,8), %rdi
addq $0x80, %rdi
movupd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq %rdx, %r8
movq %rcx, %r9
xorl %r10d, %r10d
xorl %r11d, %r11d
cmpl $0x2, %esi
je 0x4e1bb
cmpl $0x1, %esi
je 0x4e1ad
testl %esi, %esi
jne 0x4e210
movss (%rbx,%r10,4), %xmm1
mulss -0x8(%r8), %xmm1
movss -0x8(%r9), %xmm2
mulss %xmm1, %xmm2
cvtss2sd %xmm2, %xmm2
addsd (%rdi), %xmm2
movsd %xmm2, (%rdi)
movss -0x4(%r9), %xmm2
mulss %xmm1, %xmm2
cvtss2sd %xmm2, %xmm2
addsd 0x8(%rdi), %xmm2
movsd %xmm2, 0x8(%rdi)
movq %r9, %r12
jmp 0x4e1fc
movss (%rbx,%r10,4), %xmm1
mulss -0x4(%r8), %xmm1
jmp 0x4e1c6
movss (%rbx,%r10,4), %xmm1
mulss (%r8), %xmm1
movss -0x8(%r9), %xmm2
mulss %xmm1, %xmm2
cvtss2sd %xmm2, %xmm2
addsd (%rdi), %xmm2
movsd %xmm2, (%rdi)
movss -0x4(%r9), %xmm2
mulss %xmm1, %xmm2
cvtss2sd %xmm2, %xmm2
addsd 0x8(%rdi), %xmm2
movsd %xmm2, 0x8(%rdi)
leaq (%r14,%r11,4), %r12
addq $0x8, %r12
mulss (%r12), %xmm1
cvtss2sd %xmm1, %xmm1
addsd 0x10(%rdi), %xmm1
movsd %xmm1, 0x10(%rdi)
addq $0x3, %r11
incq %r10
addq $0xc, %r9
addq $0xc, %r8
cmpq %r10, %rax
jne 0x4e15c
incq %rsi
cmpq $0x3, %rsi
jne 0x4e135
jmp 0x4e32a
leaq 0x8(%r14), %rax
xorl %ecx, %ecx
xorpd %xmm0, %xmm0
xorl %edx, %edx
leaq (%rcx,%rcx,2), %rsi
leaq (%rsp,%rsi,8), %rsi
addq $0x80, %rsi
movupd %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movslq %edx, %rdx
leaq (%rax,%rdx,4), %rdi
movl %ebp, %r8d
cmpl $0x2, %ecx
je 0x4e2be
cmpl $0x1, %ecx
je 0x4e2b5
testl %ecx, %ecx
jne 0x4e30c
movss (%r13,%rdx,4), %xmm1
movss -0x8(%rdi), %xmm2
mulss %xmm1, %xmm2
cvtss2sd %xmm2, %xmm2
addsd (%rsi), %xmm2
movsd %xmm2, (%rsi)
movss -0x4(%rdi), %xmm2
mulss %xmm1, %xmm2
cvtss2sd %xmm2, %xmm2
addsd 0x8(%rsi), %xmm2
movsd %xmm2, 0x8(%rsi)
movq %rdi, %r9
jmp 0x4e2f9
movss 0x4(%r13,%rdx,4), %xmm1
jmp 0x4e2c5
movss 0x8(%r13,%rdx,4), %xmm1
movss -0x8(%rdi), %xmm2
mulss %xmm1, %xmm2
cvtss2sd %xmm2, %xmm2
addsd (%rsi), %xmm2
movsd %xmm2, (%rsi)
movss -0x4(%rdi), %xmm2
mulss %xmm1, %xmm2
cvtss2sd %xmm2, %xmm2
addsd 0x8(%rsi), %xmm2
movsd %xmm2, 0x8(%rsi)
leaq (%r14,%rdx,4), %r9
addq $0x8, %r9
mulss (%r9), %xmm1
cvtss2sd %xmm1, %xmm1
addsd 0x10(%rsi), %xmm1
movsd %xmm1, 0x10(%rsi)
addq $0x3, %rdx
addq $0xc, %rdi
decl %r8d
jne 0x4e26b
incq %rcx
cmpq $0x3, %rcx
jne 0x4e246
leaq 0x160(%rsp), %rax
xorl %ecx, %ecx
xorpd %xmm0, %xmm0
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
movupd %xmm0, 0x160(%rsp,%rcx)
movq $0x0, 0x170(%rsp,%rcx)
movq %rdx, (%rax)
addq $0x18, %rcx
addq $0x20, %rax
cmpq $0x48, %rcx
jne 0x4e342
leaq 0x80(%rsp), %rbp
movsd (%rbp), %xmm1
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
addsd 0x20(%rbp), %xmm1
addsd 0x40(%rbp), %xmm1
movsd %xmm1, 0x28(%rsp)
xorpd %xmm6, %xmm6
xorl %r10d, %r10d
leaq 0xf0(%rsp), %r12
xorpd %xmm4, %xmm4
imull $0xaaaaaaab, %r10d, %eax # imm = 0xAAAAAAAB
cmpl $0x55555555, %eax       # imm = 0x55555555
ja 0x4e3d4
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
movsd 0x2c6c(%rip), %xmm4     # 0x51040
movsd 0x88(%rsp), %xmm7
movsd 0xa8(%rsp), %xmm1
subsd 0xb8(%rsp), %xmm1
movsd %xmm1, 0x140(%rsp)
movsd 0xb0(%rsp), %xmm0
subsd 0x90(%rsp), %xmm0
subsd 0x98(%rsp), %xmm7
movsd %xmm0, 0x148(%rsp)
movsd %xmm7, 0x150(%rsp)
movsd %xmm0, 0x78(%rsp)
mulsd %xmm0, %xmm0
movsd %xmm1, 0x10(%rsp)
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
movapd %xmm7, %xmm0
mulsd %xmm7, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm6, %xmm0
movapd %xmm7, 0x50(%rsp)
jb 0x4e45b
sqrtsd %xmm0, %xmm3
jmp 0x4e494
movq %r12, %rbp
movq %r13, %r12
movq %r10, %r13
movsd %xmm4, 0x8(%rsp)
callq 0x2290
movsd 0x8(%rsp), %xmm4
movapd 0x50(%rsp), %xmm7
movq %r13, %r10
movq %r12, %r13
movq %rbp, %r12
leaq 0x80(%rsp), %rbp
xorpd %xmm6, %xmm6
movapd %xmm0, %xmm3
movsd 0xfe6c(%rip), %xmm0     # 0x5e308
ucomisd %xmm3, %xmm0
ja 0x4e894
movapd %xmm3, %xmm1
divsd %xmm4, %xmm1
mulsd %xmm1, %xmm1
xorpd %xmm0, %xmm0
xorl %eax, %eax
movsd 0x60(%rsp,%rax,8), %xmm2
mulsd %xmm1, %xmm2
addsd 0x140(%rsp,%rax,8), %xmm2
movsd %xmm2, 0x60(%rsp,%rax,8)
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
incq %rax
cmpq $0x3, %rax
jne 0x4e4b8
ucomisd %xmm6, %xmm0
movq %r10, 0x20(%rsp)
movsd %xmm3, 0x8(%rsp)
jb 0x4e4f9
sqrtsd %xmm0, %xmm0
jmp 0x4e508
callq 0x2290
movapd 0x50(%rsp), %xmm7
xorpd %xmm6, %xmm6
movsd 0x2b30(%rip), %xmm1     # 0x51040
divsd %xmm0, %xmm1
xorl %eax, %eax
movsd 0x60(%rsp,%rax,8), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp,%rax,8)
incq %rax
cmpq $0x3, %rax
jne 0x4e516
movsd 0x30(%rsp), %xmm2
movsd 0x38(%rsp), %xmm3
xorpd %xmm0, %xmm0
movsd 0x40(%rsp), %xmm1
movq %rbp, %rax
xorl %ecx, %ecx
movsd 0x30(%rsp,%rcx,8), %xmm4
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm5
mulsd %xmm4, %xmm5
mulsd 0x30(%rsp,%rdx,8), %xmm5
addsd %xmm5, %xmm0
incq %rdx
cmpq $0x3, %rdx
jne 0x4e552
incq %rcx
addq $0x18, %rax
cmpq $0x3, %rcx
jne 0x4e54a
movsd 0x78(%rsp), %xmm4
mulsd %xmm3, %xmm4
movsd 0x10(%rsp), %xmm3
mulsd %xmm2, %xmm3
addsd %xmm4, %xmm3
mulsd %xmm1, %xmm7
addsd %xmm3, %xmm7
movsd 0x80(%rsp), %xmm5
addsd 0xa0(%rsp), %xmm5
addsd 0xc0(%rsp), %xmm5
subsd %xmm0, %xmm5
movapd %xmm7, %xmm1
mulsd %xmm7, %xmm1
movapd %xmm5, %xmm0
mulsd %xmm5, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm6, %xmm0
jb 0x4e5da
sqrtsd %xmm0, %xmm0
jmp 0x4e5fb
movapd %xmm7, 0x50(%rsp)
movsd %xmm5, 0x10(%rsp)
callq 0x2290
movsd 0x10(%rsp), %xmm5
movapd 0x50(%rsp), %xmm7
xorpd %xmm6, %xmm6
movq 0x20(%rsp), %r10
leaq 0x160(%rsp), %rdi
movsd 0x8(%rsp), %xmm4
divsd %xmm0, %xmm5
divsd %xmm0, %xmm7
ucomisd %xmm6, %xmm5
jbe 0x4e63e
movapd %xmm7, %xmm0
xorpd 0x2a68(%rip), %xmm0     # 0x51090
maxsd %xmm7, %xmm0
movsd 0xfcdc(%rip), %xmm1     # 0x5e310
ucomisd %xmm0, %xmm1
ja 0x4e894
movsd 0x29fa(%rip), %xmm0     # 0x51040
subsd %xmm5, %xmm0
movq %r12, %rax
xorl %ecx, %ecx
movsd 0x30(%rsp,%rcx,8), %xmm1
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
movsd %xmm2, 0xd0(%rsp,%rcx,8)
xorl %edx, %edx
movsd 0x30(%rsp,%rdx,8), %xmm3
mulsd %xmm2, %xmm3
movsd %xmm3, (%rax,%rdx,8)
incq %rdx
cmpq $0x3, %rdx
jne 0x4e668
leaq (%rcx,%rcx,2), %rdx
leaq (%rsp,%rdx,8), %rdx
addq $0xf0, %rdx
movsd (%rdx,%rcx,8), %xmm2
addsd %xmm5, %xmm2
movsd %xmm2, (%rdx,%rcx,8)
mulsd %xmm7, %xmm1
movsd %xmm1, 0xd0(%rsp,%rcx,8)
incq %rcx
addq $0x18, %rax
cmpq $0x3, %rcx
jne 0x4e64f
movsd 0xe0(%rsp), %xmm0
movsd 0xf8(%rsp), %xmm1
movsd 0x118(%rsp), %xmm2
subsd %xmm0, %xmm1
movsd %xmm1, 0xf8(%rsp)
movsd 0xd0(%rsp), %xmm1
movsd 0xd8(%rsp), %xmm3
subsd %xmm1, %xmm2
movsd %xmm2, 0x118(%rsp)
movsd 0x120(%rsp), %xmm2
subsd %xmm3, %xmm2
movsd %xmm2, 0x120(%rsp)
addsd 0x108(%rsp), %xmm0
movsd %xmm0, 0x108(%rsp)
addsd 0x128(%rsp), %xmm1
movsd %xmm1, 0x128(%rsp)
addsd 0x100(%rsp), %xmm3
movsd %xmm3, 0x100(%rsp)
movq %r12, %rax
xorl %ecx, %ecx
movq %rdi, %rdx
xorl %esi, %esi
leaq (%rcx,%rcx,2), %r8
leaq (%rsp,%r8,8), %r8
addq $0x210, %r8             # imm = 0x210
leaq (%r8,%rsi,8), %r11
movq $0x0, (%r11)
xorpd %xmm0, %xmm0
movq %rdx, %r8
xorl %r9d, %r9d
movsd (%rax,%r9,8), %xmm1
mulsd (%r8), %xmm1
addsd %xmm1, %xmm0
incq %r9
addq $0x18, %r8
cmpq $0x3, %r9
jne 0x4e778
movsd %xmm0, (%r11)
incq %rsi
addq $0x8, %rdx
cmpq $0x3, %rsi
jne 0x4e754
incq %rcx
addq $0x18, %rax
cmpq $0x3, %rcx
jne 0x4e74f
movl $0x9, %ecx
leaq 0x210(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rax
xorl %ecx, %ecx
movq %rbp, %rdx
xorl %esi, %esi
leaq (%rcx,%rcx,2), %rdi
leaq (%rsp,%rdi,8), %rdi
addq $0x210, %rdi            # imm = 0x210
leaq (%rdi,%rsi,8), %rdi
movq $0x0, (%rdi)
xorpd %xmm0, %xmm0
movq %rdx, %r8
xorl %r9d, %r9d
movsd (%rax,%r9,8), %xmm1
mulsd (%r8), %xmm1
addsd %xmm1, %xmm0
incq %r9
addq $0x18, %r8
cmpq $0x3, %r9
jne 0x4e7f1
movsd %xmm0, (%rdi)
incq %rsi
addq $0x8, %rdx
cmpq $0x3, %rsi
jne 0x4e7cd
incq %rcx
addq $0x18, %rax
cmpq $0x3, %rcx
jne 0x4e7c8
movl $0x9, %ecx
movq %rbp, %rdi
leaq 0x210(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movsd 0x80(%rsp), %xmm0
addsd 0xa0(%rsp), %xmm0
addsd 0xc0(%rsp), %xmm0
movapd %xmm0, %xmm1
subsd 0x28(%rsp), %xmm1
movapd %xmm1, %xmm2
xorpd 0x2821(%rip), %xmm2     # 0x51090
maxsd %xmm1, %xmm2
movsd 0xfa8d(%rip), %xmm1     # 0x5e308
ucomisd %xmm2, %xmm1
ja 0x4e894
incl %r10d
movsd %xmm0, 0x28(%rsp)
cmpl $0x1e, %r10d
jne 0x4e3ab
leaq 0x260(%rsp), %rax
leaq 0x160(%rsp), %rcx
xorl %edx, %edx
movq 0x18(%rsp), %rbp
movq %rax, %rsi
xorl %edi, %edi
movsd (%rcx,%rdi,8), %xmm0
movsd %xmm0, (%rsi)
incq %rdi
addq $0x18, %rsi
cmpq $0x3, %rdi
jne 0x4e8b0
incq %rdx
addq $0x8, %rax
addq $0x18, %rcx
cmpq $0x3, %rdx
jne 0x4e8ab
movq %r13, %rdi
callq 0x2050
testl %ebp, %ebp
jle 0x4e993
xorl %eax, %eax
leaq 0x270(%rsp), %rcx
xorl %edx, %edx
xorps %xmm0, %xmm0
cvtss2sd (%r14,%rax,4), %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x4(%r14,%rax,4), %xmm1
xorps %xmm2, %xmm2
cvtss2sd 0x8(%r14,%rax,4), %xmm2
movq %rcx, %rsi
xorl %edi, %edi
movsd -0x8(%rsi), %xmm3
mulsd %xmm1, %xmm3
movsd -0x10(%rsi), %xmm4
mulsd %xmm0, %xmm4
addsd %xmm3, %xmm4
movsd (%rsi), %xmm3
mulsd %xmm2, %xmm3
addsd %xmm4, %xmm3
movsd %xmm3, 0x160(%rsp,%rdi,8)
incq %rdi
addq $0x18, %rsi
cmpq $0x3, %rdi
jne 0x4e915
xorps %xmm0, %xmm0
cvtsd2ss 0x160(%rsp), %xmm0
movss %xmm0, (%r14,%rax,4)
xorps %xmm0, %xmm0
cvtsd2ss 0x168(%rsp), %xmm0
movss %xmm0, 0x4(%r14,%rax,4)
xorps %xmm0, %xmm0
cvtsd2ss 0x170(%rsp), %xmm0
movss %xmm0, 0x8(%r14,%rax,4)
addq $0x3, %rax
incl %edx
cmpl %ebp, %edx
jne 0x4e8f3
leaq 0x1f0(%rsp), %rsi
movq %r14, %rdi
movl %ebp, %edx
callq 0x4eae8
testl %ebp, %ebp
jle 0x4ea07
movl %ebp, %eax
xorpd %xmm0, %xmm0
xorl %ecx, %ecx
xorpd %xmm1, %xmm1
movss (%rbx,%rcx,4), %xmm3
xorps %xmm2, %xmm2
cvtss2sd %xmm3, %xmm2
xorl %edx, %edx
movss (%r15,%rdx,4), %xmm4
subss (%r14,%rdx,4), %xmm4
movaps %xmm3, %xmm5
mulss %xmm4, %xmm5
mulss %xmm4, %xmm5
xorps %xmm4, %xmm4
cvtss2sd %xmm5, %xmm4
addsd %xmm4, %xmm0
incq %rdx
cmpl $0x3, %edx
jne 0x4e9c3
addq $0xc, %r15
addsd %xmm2, %xmm1
addq $0xc, %r14
incq %rcx
cmpq %rax, %rcx
jne 0x4e9b5
divsd %xmm1, %xmm0
jmp 0x4ea0f
movsd 0x76d9(%rip), %xmm0     # 0x560e8
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x4ea2f
sqrtsd %xmm0, %xmm0
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2290