// File: /workspace/github_c_makefile_star2_O3/asford[P]tmalign/./Kabsch.h
// Function: Kabsch(double**, double**, int, int, double*, double*, double (*) [3])
bool Kabsch(double **x, 
            double **y, 
            int n, 
            int mode,
            double *rms,
            double t[3],
            double u[3][3]
            )
{	
    int i, j, m, m1, l, k;
    double e0, rms1, d, h, g;
    double cth, sth, sqrth, p, det, sigma;  
    double xc[3], yc[3];
    double a[3][3], b[3][3], r[3][3], e[3], rr[6], ss[6];
    double sqrt3=1.73205080756888, tol=0.01;
    int ip[]={0, 1, 3, 1, 2, 4, 3, 4, 5};
    int ip2312[]={1, 2, 0, 1};
    
    int a_failed=0, b_failed=0;
	double epsilon=0.00000001;
    
    //initializtation
	*rms=0;
    rms1=0;
    e0=0;
    for(i=0; i<3; i++)
    {
        xc[i]=0.0;
        yc[i]=0.0;
        t[i]=0.0;
        for(j=0; j<3; j++)
        {
            u[i][j]=0.0;
            r[i][j]=0.0;
            a[i][j]=0.0;
            if(i==j)
            {
                u[i][j]=1.0;
                a[i][j]=1.0;
            }
        }
    }
    
    if(n<1)
    {
		return false;
    } 
    
    //compute centers for vector sets x, y
    for(i=0; i<n; i++)
    {
        xc[0] += x[i][0];
        xc[1] += x[i][1];
        xc[2] += x[i][2];
        
        yc[0] += y[i][0];
        yc[1] += y[i][1];
        yc[2] += y[i][2];
    }
    for(i=0; i<3; i++)
    {
        xc[i] = xc[i]/n;
        yc[i] = yc[i]/n;        
    }
    
    //compute e0 and matrix r
    for(m=0; m<n; m++)
    {
        for (i=0; i<3; i++)
        {
            e0 += (x[m][i]-xc[i])*(x[m][i]-xc[i])+\
                  (y[m][i]-yc[i])*(y[m][i]-yc[i]);
            d = y[m][i] - yc[i];
            for(j=0; j<3; j++)
            {
                r[i][j] += d*(x[m][j] - xc[j]);
            }
        }        
    }
    //compute determinat of matrix r
    det = r[0][0] * ( r[1][1]*r[2][2] - r[1][2]*r[2][1] )\
        - r[0][1] * ( r[1][0]*r[2][2] - r[1][2]*r[2][0] )\
        + r[0][2] * ( r[1][0]*r[2][1] - r[1][1]*r[2][0] ); 
    sigma=det;
    
    //compute tras(r)*r
    m = 0;
    for(j=0; j<3; j++)
    {
        for (i=0; i<=j; i++)
        {            
            rr[m]=r[0][i]*r[0][j]+r[1][i]*r[1][j]+r[2][i]*r[2][j];
            m++;
        }
    }
    
    double spur=(rr[0]+rr[2]+rr[5]) / 3.0;
    double cof = (((((rr[2]*rr[5] - rr[4]*rr[4]) + rr[0]*rr[5])\
          - rr[3]*rr[3]) + rr[0]*rr[2]) - rr[1]*rr[1]) / 3.0;
    det = det*det; 
    
    for (i=0; i<3; i++)
    {
        e[i]=spur;
    }
    
    if(spur>0) 
    {
        d = spur*spur;
        h = d - cof;
        g = (spur*cof - det)/2.0 - spur*h;
        
        if(h>0)
        {
            sqrth = sqrt(h);
            d = h*h*h - g*g;
            if(d<0.0) d=0.0;
            d = atan2( sqrt(d), -g ) / 3.0;			
            cth = sqrth * cos(d);
            sth = sqrth*sqrt3*sin(d);
            e[0]= (spur + cth) + cth;
            e[1]= (spur - cth) + sth;            
            e[2]= (spur - cth) - sth;
			
            if(mode!=0)
            {//compute a                
                for(l=0; l<3; l=l+2)
                {
                    d = e[l];  
                    ss[0] = (d-rr[2]) * (d-rr[5])  - rr[4]*rr[4];
                    ss[1] = (d-rr[5]) * rr[1]      + rr[3]*rr[4];
                    ss[2] = (d-rr[0]) * (d-rr[5])  - rr[3]*rr[3];
                    ss[3] = (d-rr[2]) * rr[3]      + rr[1]*rr[4];
                    ss[4] = (d-rr[0]) * rr[4]      + rr[1]*rr[3];                
                    ss[5] = (d-rr[0]) * (d-rr[2])  - rr[1]*rr[1]; 

					if(fabs(ss[0])<=epsilon) ss[0]=0.0;
					if(fabs(ss[1])<=epsilon) ss[1]=0.0;
					if(fabs(ss[2])<=epsilon) ss[2]=0.0;
					if(fabs(ss[3])<=epsilon) ss[3]=0.0;
					if(fabs(ss[4])<=epsilon) ss[4]=0.0;
					if(fabs(ss[5])<=epsilon) ss[5]=0.0;
                    
                    if( fabs(ss[0]) >= fabs(ss[2]) )
                    {
                        j=0;                    
                        if( fabs(ss[0]) < fabs(ss[5])) 
                        {
                            j = 2;
                        }
                    }
                    else if ( fabs(ss[2]) >= fabs(ss[5]) )
                    {
                        j = 1;
                    }
                    else
                    {
                        j = 2;
                    }  
                    
                    d = 0.0;
                    j = 3 * j;
                    for(i=0; i<3; i++)
                    {
                        k=ip[i+j];
                        a[i][l] = ss[k];
                        d = d + ss[k]*ss[k];						
                    } 
                   

					//if( d > 0.0 ) d = 1.0 / sqrt(d);
                    if( d > epsilon ) d = 1.0 / sqrt(d);
					else d=0.0;
                    for(i=0; i<3; i++)
                    {
                        a[i][l] = a[i][l] * d;
                    }               
                }//for l
                
                d = a[0][0]*a[0][2] + a[1][0]*a[1][2] + a[2][0]*a[2][2];
                if ((e[0] - e[1]) > (e[1] - e[2]))
                {
                    m1=2;
                    m=0;
                }
                else
                {
                    m1=0;
                    m=2;                
                }
                p=0;
                for(i=0; i<3; i++)
                {
                    a[i][m1] = a[i][m1] - d*a[i][m];
                    p = p + a[i][m1]*a[i][m1];
                }
                if( p <= tol )
                {
                    p = 1.0;
                    for(i=0; i<3; i++)
                    {
                        if (p < fabs(a[i][m])) 
                        {
                            continue;
                        }
                        p = fabs( a[i][m] );
                        j = i;                    
                    }
                    k = ip2312[j];
                    l = ip2312[j+1];
                    p = sqrt( a[k][m]*a[k][m] + a[l][m]*a[l][m] ); 
                    if( p > tol )  
                    {
                        a[j][m1] = 0.0;
                        a[k][m1] = -a[l][m]/p;
                        a[l][m1] =  a[k][m]/p;                                                       
                    }   
                    else
                    {//goto 40
                        a_failed=1;
                    }     
                }//if p<=tol
                else
                {
                    p = 1.0 / sqrt(p);
                    for(i=0; i<3; i++)
                    {
                        a[i][m1] = a[i][m1]*p;
                    }                                  
                }//else p<=tol  
                if(a_failed!=1)
                {
                    a[0][1] = a[1][2]*a[2][0] - a[1][0]*a[2][2];
                    a[1][1] = a[2][2]*a[0][0] - a[2][0]*a[0][2];
                    a[2][1] = a[0][2]*a[1][0] - a[0][0]*a[1][2];       
                }                                   
            }//if(mode!=0)       
        }//h>0
        
        //compute b anyway
        if(mode!=0 && a_failed!=1)//a is computed correctly
        {
            //compute b
            for(l=0; l<2; l++)
            {
                d=0.0;
                for(i=0; i<3; i++)
                {
                    b[i][l] = r[i][0]*a[0][l] + r[i][1]*a[1][l] + r[i][2]*a[2][l];
                    d = d + b[i][l]*b[i][l];
                }
                //if( d > 0 ) d = 1.0 / sqrt(d);
				if( d > epsilon ) d = 1.0 / sqrt(d);
				else d=0.0;
                for(i=0; i<3; i++)
                {
                    b[i][l] = b[i][l]*d;
                }                
            }            
            d =b[0][0]*b[0][1] + b[1][0]*b[1][1] + b[2][0]*b[2][1];
            p=0.0;
            
            for(i=0; i<3; i++)
            {
                b[i][1] = b[i][1] - d*b[i][0];
                p += b[i][1]*b[i][1];
            }
            
            if( p <= tol )
            {
                p = 1.0;
                for(i=0; i<3; i++)
                {
                    if(p<fabs(b[i][0]))
                    {
                        continue;
                    }
                    p = fabs( b[i][0] );
                    j=i;
                }
                k = ip2312[j];
                l = ip2312[j+1];
                p = sqrt( b[k][0]*b[k][0] + b[l][0]*b[l][0] ); 
                if( p > tol )  
                {
                    b[j][1] = 0.0;
                    b[k][1] = -b[l][0]/p;
                    b[l][1] =  b[k][0]/p;        
                }
                else
                {
                    //goto 40
                    b_failed=1;
                }                
            }//if( p <= tol )
            else
            {
                p = 1.0 / sqrt(p);
                for(i=0; i<3; i++)
                {
                    b[i][1]=b[i][1]*p;
                }
            }            
            if(b_failed!=1)
            {
                b[0][2] = b[1][0]*b[2][1] - b[1][1]*b[2][0];
                b[1][2] = b[2][0]*b[0][1] - b[2][1]*b[0][0];
                b[2][2] = b[0][0]*b[1][1] - b[0][1]*b[1][0]; 
                //compute u
                for(i=0; i<3; i++)
                {
                    for(j=0; j<3; j++)
                    {
                        u[i][j] = b[i][0]*a[j][0] + b[i][1]*a[j][1]\
                                + b[i][2]*a[j][2];
                    }
                }
            }
            
            //compute t
            for(i=0; i<3; i++)
            {
                t[i] = ((yc[i] - u[i][0]*xc[0]) - u[i][1]*xc[1])\
                        - u[i][2]*xc[2];
            }            
        }//if(mode!=0 && a_failed!=1)
    }//spur>0
    else //just compute t and errors
    {
        //compute t
        for(i=0; i<3; i++)
        {
            t[i] = ((yc[i] - u[i][0]*xc[0]) - u[i][1]*xc[1]) - u[i][2]*xc[2];
        }
    }//else spur>0 
    
    //compute rms
    for(i=0; i<3; i++)
    {
        if( e[i] < 0 ) e[i] = 0;
        e[i] = sqrt( e[i] );           
    }            
    d = e[2];
    if( sigma < 0.0 )
    {
        d = - d;
    }
    d = (d + e[1]) + e[0];
    rms1 = (e0 - d) - d; 
    if( rms1 < 0.0 ) rms1 = 0.0;  
    
    *rms=rms1;

	return true;
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %r9, %r15
movq %r8, %r13
movl %ecx, 0xc(%rsp)
movl %edx, %ebx
movq 0x2d0(%rsp), %rbp
xorl %eax, %eax
movq %rax, (%r8)
movq %rax, 0x150(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x140(%rsp)
movapd %xmm0, 0x130(%rsp)
movapd %xmm0, 0x120(%rsp)
movapd %xmm0, 0x110(%rsp)
leaq 0x70(%rsp), %rcx
leaq 0x78(%rsp), %r14
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
movq %rbp, %r8
xorl %r9d, %r9d
movq %rax, 0x10(%rsp,%r9,8)
movq %rax, 0x50(%rsp,%r9,8)
movq %rax, (%r15,%r9,8)
xorl %r10d, %r10d
movq %rax, (%r8,%r10,8)
movq %rax, (%rcx,%r10,8)
cmpq %r10, %r9
jne 0x4061dc
movq %rdx, (%r8,%r10,8)
movq %rdx, (%rcx,%r10,8)
incq %r10
cmpq $0x3, %r10
jne 0x4061c7
incq %r9
addq $0x18, %r8
addq $0x18, %rcx
cmpq $0x3, %r9
jne 0x4061b6
testl %ebx, %ebx
jle 0x406fdc
movapd 0x10(%rsp), %xmm0
movsd 0x20(%rsp), %xmm2
movapd 0x50(%rsp), %xmm1
movsd 0x60(%rsp), %xmm3
movl %ebx, %eax
xorl %ecx, %ecx
movq (%rdi,%rcx,8), %rdx
movupd (%rdx), %xmm4
addsd 0x10(%rdx), %xmm2
addpd %xmm4, %xmm0
movq (%rsi,%rcx,8), %rdx
movupd (%rdx), %xmm4
addpd %xmm4, %xmm1
addsd 0x10(%rdx), %xmm3
incq %rcx
cmpq %rcx, %rax
jne 0x40621a
movsd %xmm2, 0x20(%rsp)
movsd %xmm3, 0x60(%rsp)
movapd %xmm0, 0x10(%rsp)
movapd %xmm1, 0x50(%rsp)
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
movsd 0x17dd9c(%rip), %xmm13  # 0x584008
movapd %xmm13, %xmm0
divsd %xmm1, %xmm0
xorl %ecx, %ecx
movsd 0x10(%rsp,%rcx,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp,%rcx,8)
movsd 0x50(%rsp,%rcx,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x50(%rsp,%rcx,8)
incq %rcx
cmpq $0x3, %rcx
jne 0x406277
xorpd %xmm11, %xmm11
xorl %ecx, %ecx
leaq 0x110(%rsp), %rdx
movq (%rdi,%rcx,8), %r8
movq (%rsi,%rcx,8), %r9
movq %rdx, %r10
xorl %r11d, %r11d
movapd %xmm11, %xmm0
movsd (%r8,%r11,8), %xmm11
subsd 0x10(%rsp,%r11,8), %xmm11
mulsd %xmm11, %xmm11
addsd %xmm0, %xmm11
movsd (%r9,%r11,8), %xmm0
subsd 0x50(%rsp,%r11,8), %xmm0
xorl %r12d, %r12d
movsd (%r8,%r12,8), %xmm1
subsd 0x10(%rsp,%r12,8), %xmm1
mulsd %xmm0, %xmm1
addsd (%r10,%r12,8), %xmm1
movsd %xmm1, (%r10,%r12,8)
incq %r12
cmpq $0x3, %r12
jne 0x4062e9
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm11
incq %r11
addq $0x18, %r10
cmpq $0x3, %r11
jne 0x4062bd
incq %rcx
cmpq %rax, %rcx
jne 0x4062af
movsd 0x110(%rsp), %xmm1
movsd 0x128(%rsp), %xmm0
movsd 0x140(%rsp), %xmm3
movsd 0x148(%rsp), %xmm4
movsd 0x138(%rsp), %xmm5
movsd 0x150(%rsp), %xmm12
movsd 0x130(%rsp), %xmm6
movapd %xmm0, %xmm2
mulsd %xmm12, %xmm2
mulsd %xmm6, %xmm12
mulsd %xmm4, %xmm0
mulsd %xmm5, %xmm4
mulsd %xmm3, %xmm5
subsd %xmm5, %xmm2
mulsd 0x118(%rsp), %xmm2
mulsd %xmm6, %xmm3
subsd %xmm3, %xmm0
mulsd 0x120(%rsp), %xmm0
subsd %xmm4, %xmm12
movl $0x1, %eax
xorl %ecx, %ecx
xorl %edx, %edx
movsd 0x110(%rsp,%rcx,8), %xmm3
movsd 0x128(%rsp,%rcx,8), %xmm4
movsd 0x140(%rsp,%rcx,8), %xmm5
movslq %edx, %rdx
xorl %esi, %esi
movsd 0x110(%rsp,%rsi,8), %xmm6
mulsd %xmm3, %xmm6
movsd 0x128(%rsp,%rsi,8), %xmm7
mulsd %xmm4, %xmm7
addsd %xmm6, %xmm7
movsd 0x140(%rsp,%rsi,8), %xmm6
mulsd %xmm5, %xmm6
addsd %xmm7, %xmm6
movsd %xmm6, 0x250(%rsp,%rdx,8)
incq %rdx
incq %rsi
cmpq %rsi, %rax
jne 0x4063d3
incq %rcx
incq %rax
cmpq $0x3, %rcx
jne 0x4063b3
mulsd %xmm1, %xmm12
subsd %xmm2, %xmm12
addsd %xmm0, %xmm12
movsd 0x250(%rsp), %xmm15
movsd 0x258(%rsp), %xmm5
movsd 0x260(%rsp), %xmm6
movapd %xmm6, %xmm3
addsd %xmm15, %xmm3
movsd 0x278(%rsp), %xmm7
movapd %xmm3, %xmm4
addsd %xmm7, %xmm4
movsd 0x17dba1(%rip), %xmm0   # 0x584010
mulsd %xmm0, %xmm4
movupd 0x268(%rsp), %xmm8
movsd %xmm4, 0x30(%rsp)
movsd %xmm4, 0x38(%rsp)
movsd %xmm4, 0x40(%rsp)
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm4
jbe 0x406a41
movapd %xmm8, %xmm1
unpckhpd %xmm8, %xmm1            # xmm1 = xmm1[1],xmm8[1]
movapd %xmm1, 0x170(%rsp)
movapd %xmm1, %xmm9
mulsd %xmm1, %xmm9
movapd %xmm8, %xmm10
mulsd %xmm8, %xmm10
mulsd %xmm7, %xmm3
movapd %xmm6, %xmm1
mulsd %xmm15, %xmm1
addsd %xmm3, %xmm1
movapd %xmm5, %xmm14
mulsd %xmm5, %xmm14
movapd %xmm10, 0x230(%rsp)
movapd %xmm10, %xmm3
movapd %xmm14, 0x220(%rsp)
addsd %xmm14, %xmm3
movapd %xmm9, 0x240(%rsp)
addsd %xmm9, %xmm3
subsd %xmm3, %xmm1
mulsd %xmm0, %xmm1
movapd %xmm4, %xmm0
mulsd %xmm4, %xmm0
subsd %xmm1, %xmm0
movl $0x3, %eax
ucomisd %xmm2, %xmm0
jbe 0x406be4
movapd %xmm15, 0x1d0(%rsp)
movapd %xmm8, 0x1c0(%rsp)
movsd %xmm7, 0x1b8(%rsp)
movapd %xmm6, 0x1e0(%rsp)
movapd %xmm5, 0x1f0(%rsp)
movapd %xmm12, %xmm2
mulsd %xmm12, %xmm2
mulsd %xmm4, %xmm1
subsd %xmm2, %xmm1
mulsd 0x17daa0(%rip), %xmm1   # 0x584018
movapd %xmm0, %xmm2
mulsd %xmm4, %xmm2
subsd %xmm2, %xmm1
xorps %xmm2, %xmm2
sqrtsd %xmm0, %xmm2
movapd %xmm2, 0x200(%rsp)
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm2
movapd %xmm1, %xmm0
mulsd %xmm1, %xmm0
subsd %xmm0, %xmm2
xorpd %xmm0, %xmm0
maxsd %xmm2, %xmm0
sqrtsd %xmm0, %xmm0
xorpd 0x17db40(%rip), %xmm1   # 0x584100
movsd %xmm11, 0x1b0(%rsp)
movapd %xmm12, 0x210(%rsp)
movapd %xmm4, 0x160(%rsp)
callq 0x4abaf0
mulsd 0x17da26(%rip), %xmm0   # 0x584010
leaq 0x290(%rsp), %r12
leaq 0x288(%rsp), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x4ab060
movapd 0x160(%rsp), %xmm1
movsd 0x17d9f1(%rip), %xmm13  # 0x584008
movapd 0x210(%rsp), %xmm12
movsd 0x1b0(%rsp), %xmm11
movapd 0x17dadd(%rip), %xmm0   # 0x584110
movlpd (%r14), %xmm0           # xmm0 = mem[0],xmm0[1]
leaq 0x78(%rsp), %r14
movapd 0x200(%rsp), %xmm3
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
mulpd %xmm0, %xmm3
movapd 0x17daca(%rip), %xmm2   # 0x584120
movhpd (%r12), %xmm2           # xmm2 = xmm2[0],mem[0]
mulpd %xmm3, %xmm2
movapd %xmm1, %xmm0
subsd %xmm3, %xmm0
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
addpd %xmm2, %xmm1
movapd %xmm1, 0x30(%rsp)
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
subsd %xmm2, %xmm0
movsd %xmm0, 0x40(%rsp)
cmpl $0x0, 0xc(%rsp)
je 0x406f6b
movapd %xmm1, 0x160(%rsp)
movapd 0x1c0(%rsp), %xmm3
movapd 0x170(%rsp), %xmm0
mulsd %xmm3, %xmm0
movapd %xmm0, 0x170(%rsp)
movapd 0x1f0(%rsp), %xmm15
movapd %xmm15, %xmm0
unpcklpd %xmm15, %xmm0           # xmm0 = xmm0[0],xmm15[0]
shufpd $0x1, %xmm3, %xmm3      # xmm3 = xmm3[1,0]
mulpd %xmm0, %xmm3
movapd 0x1e0(%rsp), %xmm7
unpcklpd 0x1d0(%rsp), %xmm7      # xmm7 = xmm7[0],mem[0]
leaq 0x30(%rsp), %rdi
movb $0x1, %cl
xorl %esi, %esi
movapd 0x17da39(%rip), %xmm0   # 0x584130
movsd 0x17d921(%rip), %xmm4   # 0x584020
movapd 0x17da29(%rip), %xmm5   # 0x584130
leaq 0x17e8f2(%rip), %rdx    # 0x585000
movsd 0x17d8f2(%rip), %xmm1   # 0x584008
leaq 0x40(%rsp), %r11
movsd (%rdi), %xmm8
movapd %xmm8, %xmm6
subsd 0x1b8(%rsp), %xmm6
movapd %xmm6, %xmm10
mulsd %xmm15, %xmm10
addsd 0x170(%rsp), %xmm10
movsd %xmm10, 0x188(%rsp)
unpcklpd %xmm8, %xmm8            # xmm8 = xmm8[0,0]
movapd %xmm7, %xmm14
subpd %xmm7, %xmm8
movapd %xmm8, %xmm7
mulsd %xmm6, %xmm7
subsd 0x240(%rsp), %xmm7
movapd %xmm7, %xmm9
andpd %xmm0, %xmm9
ucomisd %xmm4, %xmm9
movsd %xmm7, 0x180(%rsp)
movapd %xmm8, %xmm9
unpckhpd %xmm8, %xmm9            # xmm9 = xmm9[1],xmm8[1]
mulsd %xmm9, %xmm6
subsd 0x230(%rsp), %xmm6
movsd %xmm6, 0x190(%rsp)
mulsd %xmm8, %xmm9
mulpd 0x1c0(%rsp), %xmm8
addpd %xmm3, %xmm8
movupd %xmm8, 0x198(%rsp)
subsd 0x220(%rsp), %xmm9
movsd %xmm9, 0x1a8(%rsp)
ja 0x4067ea
movq $0x0, 0x180(%rsp)
xorpd %xmm7, %xmm7
andpd %xmm0, %xmm10
ucomisd %xmm4, %xmm10
ja 0x406802
movq $0x0, 0x188(%rsp)
movapd %xmm6, %xmm10
andpd %xmm0, %xmm10
ucomisd %xmm4, %xmm10
ja 0x406823
movq $0x0, 0x190(%rsp)
xorpd %xmm6, %xmm6
movapd %xmm8, %xmm10
andpd %xmm0, %xmm10
ucomisd %xmm4, %xmm10
ja 0x406840
movq $0x0, 0x198(%rsp)
unpckhpd %xmm8, %xmm8            # xmm8 = xmm8[1,1]
andpd %xmm0, %xmm8
ucomisd %xmm4, %xmm8
ja 0x40685d
movq $0x0, 0x1a0(%rsp)
movapd %xmm9, %xmm8
andpd %xmm0, %xmm8
ucomisd %xmm4, %xmm8
ja 0x40687f
movq $0x0, 0x1a8(%rsp)
xorpd %xmm9, %xmm9
andpd %xmm5, %xmm7
andpd %xmm5, %xmm6
ucomisd %xmm6, %xmm7
andpd %xmm5, %xmm9
jae 0x4068a4
xorl %eax, %eax
ucomisd %xmm9, %xmm6
setb %al
leal (%rax,%rax,2), %eax
addl $0x3, %eax
jmp 0x4068b2
xorl %eax, %eax
ucomisd %xmm9, %xmm7
jae 0x4068b2
movl $0x6, %eax
leal (,%rax,4), %edi
leaq (%rsp,%rsi,8), %rsi
addq $0x70, %rsi
xorpd %xmm6, %xmm6
movq %rsi, %r8
xorl %r9d, %r9d
leaq (%rdi,%r9,4), %r10
movslq (%rdx,%r10), %r10
movsd 0x180(%rsp,%r10,8), %xmm7
movsd %xmm7, (%r8)
mulsd %xmm7, %xmm7
addsd %xmm7, %xmm6
incq %r9
addq $0x18, %r8
cmpq $0x3, %r9
jne 0x4068cb
xorps %xmm7, %xmm7
sqrtsd %xmm6, %xmm7
movapd %xmm1, %xmm8
divsd %xmm7, %xmm8
movapd %xmm4, %xmm7
cmpltsd %xmm6, %xmm7
andpd %xmm8, %xmm7
xorl %edi, %edi
movsd (%rsi,%rdi), %xmm6
mulsd %xmm7, %xmm6
movsd %xmm6, (%rsi,%rdi)
addq $0x18, %rdi
cmpq $0x48, %rdi
jne 0x406918
movl $0x2, %esi
movq %r11, %rdi
testb $0x1, %cl
movl $0x0, %ecx
movapd %xmm14, %xmm7
jne 0x40671b
movsd 0x80(%rsp), %xmm3
mulsd 0x70(%rsp), %xmm3
movsd 0x98(%rsp), %xmm4
mulsd 0x88(%rsp), %xmm4
addsd %xmm3, %xmm4
movsd 0xb0(%rsp), %xmm3
mulsd 0xa0(%rsp), %xmm3
addsd %xmm4, %xmm3
movapd 0x160(%rsp), %xmm5
movapd %xmm5, %xmm4
unpckhpd %xmm5, %xmm4            # xmm4 = xmm4[1],xmm5[1]
subsd %xmm4, %xmm5
addsd %xmm2, %xmm2
xorl %edi, %edi
xorl %esi, %esi
ucomisd %xmm2, %xmm5
setbe %dil
seta %sil
leal (%rsi,%rsi), %ecx
leal (%rdi,%rdi), %edx
shll $0x4, %esi
addq %rsp, %rsi
addq $0x70, %rsi
shll $0x4, %edi
addq %rsp, %rdi
addq $0x70, %rdi
xorpd %xmm2, %xmm2
xorl %r8d, %r8d
movsd (%rsi,%r8), %xmm4
movsd (%rdi,%r8), %xmm5
mulsd %xmm3, %xmm5
subsd %xmm5, %xmm4
movsd %xmm4, (%rsi,%r8)
mulsd %xmm4, %xmm4
addsd %xmm4, %xmm2
addq $0x18, %r8
cmpq $0x48, %r8
jne 0x4069d0
ucomisd 0x17d624(%rip), %xmm2   # 0x584028
jbe 0x406aa1
sqrtsd %xmm2, %xmm1
movsd 0x17d5f2(%rip), %xmm0   # 0x584008
divsd %xmm1, %xmm0
leaq (%rsp,%rcx,8), %rcx
addq $0x70, %rcx
xorl %edx, %edx
movsd (%rcx,%rdx), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%rcx,%rdx)
addq $0x18, %rdx
cmpq $0x48, %rdx
jne 0x406a24
jmp 0x406b6d
movsd 0x20(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
xorpd 0x17d6ab(%rip), %xmm1   # 0x584100
movhpd 0x18(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
addq $0x10, %rbp
xorl %eax, %eax
movupd -0x10(%rbp), %xmm2
mulpd %xmm1, %xmm2
movsd (%rbp), %xmm3
mulsd %xmm0, %xmm3
movapd %xmm2, %xmm4
unpckhpd %xmm2, %xmm4            # xmm4 = xmm4[1],xmm2[1]
addsd %xmm3, %xmm4
subsd %xmm4, %xmm2
addsd 0x50(%rsp,%rax,8), %xmm2
movsd %xmm2, (%r15,%rax,8)
incq %rax
addq $0x18, %rbp
cmpq $0x3, %rax
jne 0x406a61
jmp 0x406f6b
leaq (%rsp,%rdx,8), %rsi
addq $0x70, %rsi
xorl %edi, %edi
movsd (%rsi), %xmm2
andpd %xmm0, %xmm2
ucomisd %xmm2, %xmm1
cmovael %edi, %eax
minsd %xmm2, %xmm1
incq %rdi
addq $0x18, %rsi
cmpq $0x3, %rdi
jne 0x406aab
movslq %eax, %r8
leaq 0x17d6bb(%rip), %rsi    # 0x584190
movslq (%rsi,%r8,4), %rdi
movslq 0x4(%rsi,%r8,4), %r9
leaq (%rdi,%rdi,2), %rsi
leaq (%rsp,%rsi,8), %rsi
addq $0x70, %rsi
shll $0x3, %edx
movsd (%rdx,%rsi), %xmm0
mulsd %xmm0, %xmm0
leaq (%r9,%r9,2), %rdi
leaq (%rsp,%rdi,8), %rdi
addq $0x70, %rdi
movsd (%rdx,%rdi), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
ucomisd 0x17d50a(%rip), %xmm0   # 0x584028
jbe 0x406f6b
leaq (%rsi,%rdx), %r9
addq %rdi, %rdx
leaq (%r8,%r8,2), %r8
leaq (%rsp,%r8,8), %r8
addq $0x70, %r8
shll $0x3, %ecx
movq $0x0, (%rcx,%r8)
movsd (%rdx), %xmm1
xorpd 0x17d5b2(%rip), %xmm1   # 0x584100
movsd 0x17d4b2(%rip), %xmm2   # 0x584008
divsd %xmm0, %xmm2
mulsd %xmm2, %xmm1
movsd %xmm1, (%rcx,%rsi)
mulsd (%r9), %xmm2
movsd %xmm2, (%rcx,%rdi)
movsd 0x98(%rsp), %xmm0
movsd 0xa0(%rsp), %xmm1
movapd %xmm1, %xmm2
mulsd %xmm0, %xmm2
movsd 0x88(%rsp), %xmm3
movsd 0xb0(%rsp), %xmm4
movapd %xmm4, %xmm5
mulsd %xmm3, %xmm5
subsd %xmm5, %xmm2
movsd %xmm2, 0x78(%rsp)
movsd 0x70(%rsp), %xmm2
movsd 0x80(%rsp), %xmm5
mulsd %xmm2, %xmm4
mulsd %xmm5, %xmm1
subsd %xmm1, %xmm4
movsd %xmm4, 0x90(%rsp)
mulsd %xmm3, %xmm5
mulsd %xmm0, %xmm2
subsd %xmm2, %xmm5
movsd %xmm5, 0xa8(%rsp)
cmpl $0x0, 0xc(%rsp)
je 0x406f6b
leaq 0x70(%rsp), %rsi
movb $0x1, %cl
xorl %edx, %edx
movsd 0x17d420(%rip), %xmm0   # 0x584020
movsd 0x88(%rsp,%rdx,8), %xmm2
movhpd 0xa0(%rsp,%rdx,8), %xmm2 # xmm2 = xmm2[0],mem[0]
movsd (%rsi), %xmm3
leaq (%rsp,%rdx,8), %rdx
addq $0xc0, %rdx
xorpd %xmm1, %xmm1
xorl %esi, %esi
movsd 0x110(%rsp,%rsi), %xmm4
mulsd %xmm3, %xmm4
movupd 0x118(%rsp,%rsi), %xmm5
mulpd %xmm2, %xmm5
addsd %xmm5, %xmm4
unpckhpd %xmm5, %xmm5            # xmm5 = xmm5[1,1]
addsd %xmm4, %xmm5
movsd %xmm5, (%rdx,%rsi)
mulsd %xmm5, %xmm5
addsd %xmm5, %xmm1
addq $0x18, %rsi
cmpq $0x48, %rsi
jne 0x406c27
xorps %xmm2, %xmm2
sqrtsd %xmm1, %xmm2
movapd %xmm13, %xmm3
divsd %xmm2, %xmm3
movapd %xmm0, %xmm2
cmpltsd %xmm1, %xmm2
andpd %xmm3, %xmm2
xorl %esi, %esi
movsd (%rdx,%rsi), %xmm1
mulsd %xmm2, %xmm1
movsd %xmm1, (%rdx,%rsi)
addq $0x18, %rsi
cmpq $0x48, %rsi
jne 0x406c83
movl $0x1, %edx
movq %r14, %rsi
testb $0x1, %cl
movl $0x0, %ecx
jne 0x406c00
movsd 0xc0(%rsp), %xmm1
movsd 0xd8(%rsp), %xmm0
movsd 0xc8(%rsp), %xmm2
mulsd %xmm1, %xmm2
movsd 0xe0(%rsp), %xmm3
mulsd %xmm0, %xmm3
addsd %xmm2, %xmm3
movsd 0xf0(%rsp), %xmm2
movsd 0xf8(%rsp), %xmm4
mulsd %xmm2, %xmm4
addsd %xmm3, %xmm4
xorpd %xmm3, %xmm3
movl $0x8, %ecx
movsd 0xc0(%rsp,%rcx), %xmm5
movsd 0xb8(%rsp,%rcx), %xmm6
mulsd %xmm4, %xmm6
subsd %xmm6, %xmm5
movsd %xmm5, 0xc0(%rsp,%rcx)
mulsd %xmm5, %xmm5
addsd %xmm5, %xmm3
addq $0x18, %rcx
cmpq $0x50, %rcx
jne 0x406d04
ucomisd 0x17d2e7(%rip), %xmm3   # 0x584028
jbe 0x406d80
xorps %xmm4, %xmm4
sqrtsd %xmm3, %xmm4
movsd 0x17d2b6(%rip), %xmm3   # 0x584008
divsd %xmm4, %xmm3
movl $0x8, %eax
movsd 0xc0(%rsp,%rax), %xmm4
mulsd %xmm3, %xmm4
movsd %xmm4, 0xc0(%rsp,%rax)
addq $0x18, %rax
cmpq $0x50, %rax
jne 0x406d5b
jmp 0x406e52
leaq 0xc0(%rsp), %rcx
xorl %edx, %edx
movapd 0x17d39e(%rip), %xmm3   # 0x584130
movsd (%rcx), %xmm4
andpd %xmm3, %xmm4
ucomisd %xmm4, %xmm13
cmovael %edx, %eax
minsd %xmm4, %xmm13
incq %rdx
addq $0x18, %rcx
cmpq $0x3, %rdx
jne 0x406d92
cltq
leaq 0x17d3d3(%rip), %rcx    # 0x584190
movslq (%rcx,%rax,4), %rdx
movslq 0x4(%rcx,%rax,4), %rsi
leaq (%rdx,%rdx,2), %rcx
movsd 0xc0(%rsp,%rcx,8), %xmm3
movapd %xmm3, %xmm5
mulsd %xmm3, %xmm5
leaq (%rsi,%rsi,2), %rdx
movsd 0xc0(%rsp,%rdx,8), %xmm4
movapd %xmm4, %xmm6
mulsd %xmm4, %xmm6
addsd %xmm5, %xmm6
xorps %xmm5, %xmm5
sqrtsd %xmm6, %xmm5
ucomisd 0x17d225(%rip), %xmm5   # 0x584028
jbe 0x406f10
leaq (%rsp,%rcx,8), %rcx
addq $0xc0, %rcx
leaq 0xc0(%rsp,%rdx,8), %rdx
leaq (%rax,%rax,2), %rax
movq $0x0, 0xc8(%rsp,%rax,8)
xorpd 0x17d2cc(%rip), %xmm4   # 0x584100
movsd 0x17d1cc(%rip), %xmm6   # 0x584008
divsd %xmm5, %xmm6
mulsd %xmm6, %xmm4
movsd %xmm4, 0x8(%rcx)
mulsd %xmm6, %xmm3
movsd %xmm3, 0x8(%rdx)
movsd 0xf8(%rsp), %xmm3
movapd %xmm3, %xmm4
mulsd %xmm0, %xmm4
movsd 0xc8(%rsp), %xmm5
movsd 0xe0(%rsp), %xmm6
movapd %xmm6, %xmm7
mulsd %xmm2, %xmm7
subsd %xmm7, %xmm4
movsd %xmm4, 0xd0(%rsp)
mulsd %xmm5, %xmm2
mulsd %xmm1, %xmm3
subsd %xmm3, %xmm2
movsd %xmm2, 0xe8(%rsp)
mulsd %xmm1, %xmm6
mulsd %xmm0, %xmm5
subsd %xmm5, %xmm6
movsd %xmm6, 0x100(%rsp)
xorl %eax, %eax
movq %rbp, %rcx
leaq (%rax,%rax,2), %rdx
movsd 0xc0(%rsp,%rdx,8), %xmm0
movupd 0xc8(%rsp,%rdx,8), %xmm1
movq %r14, %rdx
xorl %esi, %esi
movsd -0x8(%rdx), %xmm2
mulsd %xmm0, %xmm2
movupd (%rdx), %xmm3
mulpd %xmm1, %xmm3
addsd %xmm3, %xmm2
unpckhpd %xmm3, %xmm3            # xmm3 = xmm3[1,1]
addsd %xmm2, %xmm3
movsd %xmm3, (%rcx,%rsi,8)
incq %rsi
addq $0x18, %rdx
cmpq $0x3, %rsi
jne 0x406ed4
incq %rax
addq $0x18, %rcx
cmpq $0x3, %rax
jne 0x406eb9
movsd 0x20(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
xorpd 0x17d1dc(%rip), %xmm1   # 0x584100
movhpd 0x18(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
addq $0x10, %rbp
xorl %eax, %eax
movupd -0x10(%rbp), %xmm2
mulpd %xmm1, %xmm2
movsd (%rbp), %xmm3
mulsd %xmm0, %xmm3
movapd %xmm2, %xmm4
unpckhpd %xmm2, %xmm4            # xmm4 = xmm4[1],xmm2[1]
addsd %xmm3, %xmm4
subsd %xmm4, %xmm2
addsd 0x50(%rsp,%rax,8), %xmm2
movsd %xmm2, (%r15,%rax,8)
incq %rax
addq $0x18, %rbp
cmpq $0x3, %rax
jne 0x406f30
xorl %eax, %eax
xorpd %xmm0, %xmm0
movsd 0x30(%rsp,%rax,8), %xmm1
maxsd %xmm0, %xmm1
sqrtsd %xmm1, %xmm1
movsd %xmm1, 0x30(%rsp,%rax,8)
incq %rax
cmpq $0x3, %rax
jne 0x406f71
movsd 0x40(%rsp), %xmm0
movapd 0x17d164(%rip), %xmm1   # 0x584100
xorpd %xmm0, %xmm1
xorpd %xmm2, %xmm2
cmpltsd %xmm2, %xmm12
andpd %xmm12, %xmm1
andnpd %xmm0, %xmm12
orpd %xmm1, %xmm12
addsd 0x38(%rsp), %xmm12
addsd 0x30(%rsp), %xmm12
addsd %xmm12, %xmm12
subsd %xmm12, %xmm11
maxsd %xmm2, %xmm11
movsd %xmm11, (%r13)
testl %ebx, %ebx
setg %al
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq