// File: /workspace/github_c_makefile_star2_O3/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 $0x2c8, %rsp            # imm = 0x2C8
movl %ecx, %r12d
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x180(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movl %ecx, %edx
movq %r14, %rcx
callq 0x4e98e
leaq 0x160(%rsp), %rdi
movq %rbx, %rsi
movl %r12d, %edx
movq %r14, %rcx
callq 0x4e98e
movaps 0x309e(%rip), %xmm1     # 0x51090
movaps (%r13), %xmm0
xorps %xmm1, %xmm0
movaps %xmm0, 0x140(%rsp)
movsd 0x10(%r13), %xmm0
xorps %xmm1, %xmm0
movlps %xmm0, 0x150(%rsp)
leal (%r12,%r12,2), %ebp
movslq %ebp, %rdi
shlq $0x2, %rdi
callq 0x21e0
movq %r12, 0x8(%rsp)
testl %r12d, %r12d
movq %rax, (%rsp)
jle 0x4e047
movl %ebp, %edx
shlq $0x2, %rdx
movq (%rsp), %rdi
movq %r15, %rsi
callq 0x21b0
movq (%rsp), %rax
leaq 0x140(%rsp), %r13
movq %rax, %rdi
movq %r13, %rsi
movq 0x8(%rsp), %r12
movl %r12d, %edx
callq 0x4ea12
movapd 0x160(%rsp), %xmm0
movapd 0x301d(%rip), %xmm1     # 0x51090
xorpd %xmm1, %xmm0
movapd %xmm0, (%r13)
movsd 0x170(%rsp), %xmm0
xorpd %xmm1, %xmm0
movlpd %xmm0, 0x10(%r13)
movq %rbx, %rdi
movq %r13, %rsi
movl %r12d, %edx
callq 0x4ea12
cmpl $0x2, %r12d
jl 0x4e822
testq %r14, %r14
movq (%rsp), %rcx
je 0x4e1b2
movl %r12d, %eax
addq $0x8, %rcx
leaq 0x8(%rbx), %rdx
xorl %esi, %esi
xorpd %xmm0, %xmm0
movapd 0x2fc2(%rip), %xmm6     # 0x51090
leaq (%rsi,%rsi,2), %rdi
leaq (%rsp,%rdi,8), %rdi
addq $0x70, %rdi
movupd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq %rdx, %r8
movq %rcx, %r9
xorl %r10d, %r10d
xorl %r11d, %r11d
cmpl $0x2, %esi
je 0x4e142
cmpl $0x1, %esi
je 0x4e134
testl %esi, %esi
jne 0x4e188
movss (%r14,%r10,4), %xmm1
mulss -0x8(%r9), %xmm1
movsd -0x8(%r8), %xmm2
movaps %xmm1, %xmm3
shufps $0x0, %xmm1, %xmm3      # xmm3 = xmm3[0,0],xmm1[0,0]
mulps %xmm2, %xmm3
cvtps2pd %xmm3, %xmm2
movupd (%rdi), %xmm3
addpd %xmm2, %xmm3
movupd %xmm3, (%rdi)
movq %r8, %r12
jmp 0x4e174
movss (%r14,%r10,4), %xmm1
mulss -0x4(%r9), %xmm1
jmp 0x4e14d
movss (%r14,%r10,4), %xmm1
mulss (%r9), %xmm1
movsd -0x8(%r8), %xmm2
movaps %xmm1, %xmm3
shufps $0x0, %xmm1, %xmm3      # xmm3 = xmm3[0,0],xmm1[0,0]
mulps %xmm2, %xmm3
cvtps2pd %xmm3, %xmm2
movupd (%rdi), %xmm3
addpd %xmm2, %xmm3
movupd %xmm3, (%rdi)
leaq (%rbx,%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 0x4e0f2
incq %rsi
cmpq $0x3, %rsi
jne 0x4e0ce
jmp 0x4e294
movq %rcx, %rax
addq $0x8, %rax
leaq 0x8(%rbx), %rcx
xorl %edx, %edx
xorpd %xmm0, %xmm0
xorl %esi, %esi
movapd 0x2ec3(%rip), %xmm6     # 0x51090
leaq (%rdx,%rdx,2), %rdi
leaq (%rsp,%rdi,8), %rdi
addq $0x70, %rdi
movupd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq %esi, %rsi
leaq (%rax,%rsi,4), %r8
leaq (%rcx,%rsi,4), %r9
movl %r12d, %r10d
cmpl $0x2, %edx
je 0x4e233
cmpl $0x1, %edx
je 0x4e22b
testl %edx, %edx
jne 0x4e272
movss -0x8(%r8), %xmm1
movsd -0x8(%r9), %xmm2
movaps %xmm1, %xmm3
shufps $0x0, %xmm1, %xmm3      # xmm3 = xmm3[0,0],xmm1[0,0]
mulps %xmm2, %xmm3
cvtps2pd %xmm3, %xmm2
movupd (%rdi), %xmm3
addpd %xmm2, %xmm3
movupd %xmm3, (%rdi)
movq %r9, %r11
jmp 0x4e25f
movss -0x4(%r8), %xmm1
jmp 0x4e238
movss (%r8), %xmm1
movsd -0x8(%r9), %xmm2
movaps %xmm1, %xmm3
shufps $0x0, %xmm1, %xmm3      # xmm3 = xmm3[0,0],xmm1[0,0]
mulps %xmm2, %xmm3
cvtps2pd %xmm3, %xmm2
movupd (%rdi), %xmm3
addpd %xmm2, %xmm3
movupd %xmm3, (%rdi)
leaq (%rbx,%rsi,4), %r11
addq $0x8, %r11
mulss (%r11), %xmm1
cvtss2sd %xmm1, %xmm1
addsd 0x10(%rdi), %xmm1
movsd %xmm1, 0x10(%rdi)
addq $0x3, %rsi
addq $0xc, %r8
addq $0xc, %r9
decl %r10d
jne 0x4e1f3
incq %rdx
cmpq $0x3, %rdx
jne 0x4e1cd
leaq 0x1e0(%rsp), %rax
xorl %ecx, %ecx
xorpd %xmm0, %xmm0
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
movupd %xmm0, 0x1e0(%rsp,%rcx)
movq $0x0, 0x1f0(%rsp,%rcx)
movq %rdx, (%rax)
addq $0x18, %rcx
addq $0x20, %rax
cmpq $0x48, %rcx
jne 0x4e2ac
leaq 0x70(%rsp), %rbp
movsd (%rbp), %xmm14
movsd 0x20(%rbp), %xmm13
movapd %xmm14, %xmm10
addsd %xmm13, %xmm10
movsd 0x40(%rbp), %xmm12
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
addsd %xmm12, %xmm10
xorpd %xmm7, %xmm7
xorl %r10d, %r10d
movsd 0x2e2d(%rip), %xmm8     # 0x51148
movsd 0xfccc(%rip), %xmm9     # 0x5dff0
leaq 0xc0(%rsp), %r9
leaq 0x1e0(%rsp), %r12
leaq 0x230(%rsp), %r13
xorpd %xmm11, %xmm11
imull $-0x55, %r10d, %eax
movapd %xmm11, %xmm0
cmpb $0x55, %al
ja 0x4e366
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movapd %xmm8, %xmm0
movupd 0xa8(%rsp), %xmm1
movhpd 0x80(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
movupd 0x98(%rsp), %xmm3
subpd %xmm1, %xmm3
movapd %xmm3, 0x1c0(%rsp)
movsd 0x78(%rsp), %xmm15
subsd 0x88(%rsp), %xmm15
movsd %xmm15, 0x1d0(%rsp)
movapd %xmm3, %xmm4
unpckhpd %xmm3, %xmm4            # xmm4 = xmm4[1],xmm3[1]
movapd %xmm4, %xmm1
mulsd %xmm4, %xmm1
movapd %xmm3, %xmm2
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
movapd %xmm15, %xmm1
mulsd %xmm15, %xmm1
addsd %xmm2, %xmm1
xorps %xmm11, %xmm11
sqrtsd %xmm1, %xmm11
ucomisd %xmm11, %xmm9
ja 0x4e7df
movapd %xmm11, %xmm1
divsd %xmm0, %xmm1
mulsd %xmm1, %xmm1
xorpd %xmm0, %xmm0
xorl %eax, %eax
movsd 0x30(%rsp,%rax,8), %xmm2
mulsd %xmm1, %xmm2
addsd 0x1c0(%rsp,%rax,8), %xmm2
movsd %xmm2, 0x30(%rsp,%rax,8)
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
incq %rax
cmpq $0x3, %rax
jne 0x4e3fa
movapd %xmm4, 0x120(%rsp)
ucomisd %xmm7, %xmm0
movapd %xmm3, 0x130(%rsp)
jb 0x4e445
sqrtsd %xmm0, %xmm0
jmp 0x4e4d8
movq %r10, %r12
movsd %xmm10, 0x68(%rsp)
movsd %xmm11, 0x60(%rsp)
movsd %xmm12, 0x58(%rsp)
movsd %xmm13, 0x50(%rsp)
movsd %xmm14, 0x48(%rsp)
movapd %xmm15, 0x110(%rsp)
callq 0x22a0
movapd 0x110(%rsp), %xmm15
movsd 0x48(%rsp), %xmm14
movsd 0x50(%rsp), %xmm13
movsd 0x58(%rsp), %xmm12
movsd 0x60(%rsp), %xmm11
movsd 0x68(%rsp), %xmm10
movq %r12, %r10
leaq 0x1e0(%rsp), %r12
leaq 0xc0(%rsp), %r9
movsd 0xfb2d(%rip), %xmm9     # 0x5dff0
movsd 0x2c7c(%rip), %xmm8     # 0x51148
xorpd %xmm7, %xmm7
movapd 0x2bb8(%rip), %xmm6     # 0x51090
movapd %xmm8, %xmm1
divsd %xmm0, %xmm1
xorl %eax, %eax
movsd 0x30(%rsp,%rax,8), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp,%rax,8)
incq %rax
cmpq $0x3, %rax
jne 0x4e4e3
movsd 0x10(%rsp), %xmm2
movsd 0x18(%rsp), %xmm3
xorpd %xmm0, %xmm0
movsd 0x20(%rsp), %xmm1
movq %rbp, %rax
xorl %ecx, %ecx
movsd 0x10(%rsp,%rcx,8), %xmm4
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm5
mulsd %xmm4, %xmm5
mulsd 0x10(%rsp,%rdx,8), %xmm5
addsd %xmm5, %xmm0
incq %rdx
cmpq $0x3, %rdx
jne 0x4e51f
incq %rcx
addq $0x18, %rax
cmpq $0x3, %rcx
jne 0x4e517
movapd 0x120(%rsp), %xmm4
mulsd %xmm3, %xmm4
movapd 0x130(%rsp), %xmm3
mulsd %xmm2, %xmm3
addsd %xmm4, %xmm3
mulsd %xmm1, %xmm15
addsd %xmm3, %xmm15
addsd %xmm14, %xmm13
addsd %xmm13, %xmm12
subsd %xmm0, %xmm12
movapd %xmm15, %xmm0
mulsd %xmm15, %xmm0
movapd %xmm12, %xmm1
mulsd %xmm12, %xmm1
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
divsd %xmm0, %xmm12
divsd %xmm0, %xmm15
ucomisd %xmm7, %xmm12
jbe 0x4e5cf
movapd %xmm15, %xmm0
xorpd %xmm6, %xmm0
maxsd %xmm15, %xmm0
movsd 0xfd23(%rip), %xmm1     # 0x5e2e8
ucomisd %xmm0, %xmm1
ja 0x4e7df
movapd %xmm8, %xmm0
subsd %xmm12, %xmm0
movq %r9, %rax
xorl %ecx, %ecx
movsd 0x10(%rsp,%rcx,8), %xmm1
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
xorl %edx, %edx
movsd 0x10(%rsp,%rdx,8), %xmm3
mulsd %xmm2, %xmm3
movsd %xmm3, (%rax,%rdx,8)
incq %rdx
cmpq $0x3, %rdx
jne 0x4e5ee
leaq (%rcx,%rcx,2), %rdx
leaq (%rsp,%rdx,8), %rdx
addq $0xc0, %rdx
movsd (%rdx,%rcx,8), %xmm2
addsd %xmm12, %xmm2
movsd %xmm2, (%rdx,%rcx,8)
mulsd %xmm15, %xmm1
movsd %xmm1, 0x1a0(%rsp,%rcx,8)
incq %rcx
addq $0x18, %rax
cmpq $0x3, %rcx
jne 0x4e5de
movsd 0xc8(%rsp), %xmm0
movsd 0x1a0(%rsp), %xmm1
movsd 0xf8(%rsp), %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, 0xf8(%rsp)
movupd 0x1a8(%rsp), %xmm2
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
subsd %xmm3, %xmm0
movsd %xmm0, 0xc8(%rsp)
movupd 0xe8(%rsp), %xmm0
unpcklpd %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0]
subpd %xmm1, %xmm0
movupd %xmm0, 0xe8(%rsp)
addpd 0xd0(%rsp), %xmm2
movapd %xmm2, 0xd0(%rsp)
movq %r9, %rax
xorl %ecx, %ecx
movq %r12, %rdx
xorl %esi, %esi
xorpd %xmm0, %xmm0
movq %rdx, %rdi
xorl %r8d, %r8d
movsd (%rax,%r8,8), %xmm1
mulsd (%rdi), %xmm1
addsd %xmm1, %xmm0
incq %r8
addq $0x18, %rdi
cmpq $0x3, %r8
jne 0x4e6c5
leaq (%rcx,%rcx,2), %rdi
leaq (%rsp,%rdi,8), %rdi
addq $0x230, %rdi            # imm = 0x230
movsd %xmm0, (%rdi,%rsi,8)
incq %rsi
addq $0x8, %rdx
cmpq $0x3, %rsi
jne 0x4e6bb
incq %rcx
addq $0x18, %rax
cmpq $0x3, %rcx
jne 0x4e6b6
movl $0x9, %ecx
movq %r12, %rdi
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r9, %rax
xorl %ecx, %ecx
movq %rbp, %rdx
xorl %esi, %esi
xorpd %xmm0, %xmm0
movq %rdx, %rdi
xorl %r8d, %r8d
movsd (%rax,%r8,8), %xmm1
mulsd (%rdi), %xmm1
addsd %xmm1, %xmm0
incq %r8
addq $0x18, %rdi
cmpq $0x3, %r8
jne 0x4e730
leaq (%rcx,%rcx,2), %rdi
leaq (%rsp,%rdi,8), %rdi
addq $0x230, %rdi            # imm = 0x230
movsd %xmm0, (%rdi,%rsi,8)
incq %rsi
addq $0x8, %rdx
cmpq $0x3, %rsi
jne 0x4e726
incq %rcx
addq $0x18, %rax
cmpq $0x3, %rcx
jne 0x4e721
movl $0x9, %ecx
movq %rbp, %rdi
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
movsd 0x70(%rsp), %xmm14
movsd 0x90(%rsp), %xmm13
movapd %xmm14, %xmm0
addsd %xmm13, %xmm0
movsd 0xb0(%rsp), %xmm12
addsd %xmm12, %xmm0
movapd %xmm0, %xmm1
subsd %xmm10, %xmm1
movapd %xmm1, %xmm2
xorpd %xmm6, %xmm2
maxsd %xmm1, %xmm2
ucomisd %xmm2, %xmm9
ja 0x4e7df
incl %r10d
movapd %xmm0, %xmm10
cmpl $0x1e, %r10d
jne 0x4e341
leaq 0x280(%rsp), %rax
leaq 0x1e0(%rsp), %rcx
xorl %edx, %edx
movq 0x8(%rsp), %r12
movq %rax, %rsi
xorl %edi, %edi
movsd (%rcx,%rdi,8), %xmm0
movsd %xmm0, (%rsi)
incq %rdi
addq $0x18, %rsi
cmpq $0x3, %rdi
jne 0x4e7fb
incq %rdx
addq $0x8, %rax
addq $0x18, %rcx
cmpq $0x3, %rdx
jne 0x4e7f6
movq (%rsp), %rdi
callq 0x2050
testl %r12d, %r12d
jle 0x4e93d
xorl %eax, %eax
leaq 0x290(%rsp), %rcx
xorl %edx, %edx
xorps %xmm0, %xmm0
cvtss2sd (%rbx,%rax,4), %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x4(%rbx,%rax,4), %xmm1
xorps %xmm2, %xmm2
cvtss2sd 0x8(%rbx,%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, 0x1e0(%rsp,%rdi,8)
incq %rdi
addq $0x18, %rsi
cmpq $0x3, %rdi
jne 0x4e85f
cvtpd2ps 0x1e0(%rsp), %xmm0
movlpd %xmm0, (%rbx,%rax,4)
xorps %xmm0, %xmm0
cvtsd2ss 0x1f0(%rsp), %xmm0
movss %xmm0, 0x8(%rbx,%rax,4)
addq $0x3, %rax
incl %edx
cmpl %r12d, %edx
jne 0x4e840
leaq 0x180(%rsp), %rsi
movq %rbx, %rdi
movl %r12d, %edx
callq 0x4ea12
testl %r12d, %r12d
jle 0x4e950
movl %r12d, %eax
xorpd %xmm0, %xmm0
xorl %ecx, %ecx
xorpd %xmm1, %xmm1
movss (%r14,%rcx,4), %xmm3
xorps %xmm2, %xmm2
cvtss2sd %xmm3, %xmm2
xorl %edx, %edx
movss (%r15,%rdx,4), %xmm4
subss (%rbx,%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 0x4e8fa
addq $0xc, %r15
addsd %xmm2, %xmm1
addq $0xc, %rbx
incq %rcx
cmpq %rax, %rcx
jne 0x4e8eb
divsd %xmm1, %xmm0
jmp 0x4e958
leaq 0x180(%rsp), %rsi
movq %rbx, %rdi
movl %r12d, %edx
callq 0x4ea12
movsd 0x7798(%rip), %xmm0     # 0x560f0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x4e978
sqrtsd %xmm0, %xmm0
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22a0