// File: /workspace/github_c_makefile_star2_O2/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 $0x288, %rsp            # imm = 0x288
movq %r9, %r15
movq %r8, %r14
movl %ecx, %r13d
movl %edx, %ebx
movq 0x2c0(%rsp), %rbp
andq $0x0, (%r8)
leaq 0x100(%rsp), %rax
leaq 0x40(%rsp), %rcx
xorl %edx, %edx
movabsq $0x3ff0000000000000, %r8 # imm = 0x3FF0000000000000
movq %rbp, %r9
cmpq $0x3, %rdx
je 0x405cd5
andq $0x0, (%rsp,%rdx,8)
andq $0x0, 0x20(%rsp,%rdx,8)
andq $0x0, (%r15,%rdx,8)
xorl %r10d, %r10d
cmpq $0x3, %r10
je 0x405cc4
andq $0x0, (%r9,%r10,8)
andq $0x0, (%rax,%r10,8)
andq $0x0, (%rcx,%r10,8)
cmpq %r10, %rdx
jne 0x405cbf
movq %r8, (%r9,%r10,8)
movq %r8, (%rcx,%r10,8)
incq %r10
jmp 0x405c9d
incq %rdx
addq $0x18, %r9
addq $0x18, %rax
addq $0x18, %rcx
jmp 0x405c84
testl %ebx, %ebx
jle 0x406a72
movapd (%rsp), %xmm0
movsd 0x10(%rsp), %xmm2
movapd 0x20(%rsp), %xmm1
movsd 0x30(%rsp), %xmm3
movl %ebx, %eax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x405d24
movq (%rdi,%rcx,8), %rdx
movupd (%rdx), %xmm4
addpd %xmm4, %xmm0
addsd 0x10(%rdx), %xmm2
movq (%rsi,%rcx,8), %rdx
movupd (%rdx), %xmm4
addpd %xmm4, %xmm1
addsd 0x10(%rdx), %xmm3
incq %rcx
jmp 0x405cf8
movsd %xmm2, 0x10(%rsp)
movsd %xmm3, 0x30(%rsp)
movapd %xmm0, (%rsp)
movapd %xmm1, 0x20(%rsp)
cvtsi2sd %ebx, %xmm1
movsd 0x17d2c0(%rip), %xmm14  # 0x583008
movapd %xmm14, %xmm0
divsd %xmm1, %xmm0
xorl %ecx, %ecx
cmpq $0x3, %rcx
je 0x405d7c
movsd (%rsp,%rcx,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%rsp,%rcx,8)
movsd 0x20(%rsp,%rcx,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rsp,%rcx,8)
incq %rcx
jmp 0x405d53
xorpd %xmm12, %xmm12
xorl %ecx, %ecx
leaq 0x100(%rsp), %rdx
cmpq %rax, %rcx
je 0x405e0b
movq (%rdi,%rcx,8), %r8
movq (%rsi,%rcx,8), %r9
movq %rdx, %r10
xorl %r11d, %r11d
cmpq $0x3, %r11
je 0x405e06
movsd (%r8,%r11,8), %xmm0
subsd (%rsp,%r11,8), %xmm0
mulsd %xmm0, %xmm0
movsd (%r9,%r11,8), %xmm1
subsd 0x20(%rsp,%r11,8), %xmm1
addsd %xmm12, %xmm0
xorl %r12d, %r12d
cmpq $0x3, %r12
je 0x405df0
movsd (%r8,%r12,8), %xmm2
subsd (%rsp,%r12,8), %xmm2
mulsd %xmm1, %xmm2
addsd (%r10,%r12,8), %xmm2
movsd %xmm2, (%r10,%r12,8)
incq %r12
jmp 0x405dc9
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %r11
addq $0x18, %r10
movapd %xmm0, %xmm12
jmp 0x405d9e
incq %rcx
jmp 0x405d8b
movsd 0x100(%rsp), %xmm1
movsd 0x118(%rsp), %xmm0
movsd 0x120(%rsp), %xmm3
movsd 0x140(%rsp), %xmm2
movapd %xmm2, %xmm13
mulsd %xmm3, %xmm13
movsd 0x128(%rsp), %xmm4
movsd 0x138(%rsp), %xmm5
mulsd %xmm0, %xmm2
mulsd %xmm5, %xmm0
mulsd %xmm4, %xmm5
movsd 0x130(%rsp), %xmm6
mulsd %xmm6, %xmm4
subsd %xmm4, %xmm2
mulsd 0x108(%rsp), %xmm2
mulsd %xmm3, %xmm6
subsd %xmm6, %xmm0
mulsd 0x110(%rsp), %xmm0
subsd %xmm5, %xmm13
pushq $0x1
popq %rax
xorl %ecx, %ecx
xorl %edx, %edx
cmpq $0x3, %rcx
je 0x405f08
movsd 0x100(%rsp,%rcx,8), %xmm3
movsd 0x118(%rsp,%rcx,8), %xmm4
movsd 0x130(%rsp,%rcx,8), %xmm5
movslq %edx, %rdx
leaq (%rsp,%rdx,8), %rdi
addq $0x250, %rdi            # imm = 0x250
xorl %esi, %esi
cmpq %rsi, %rax
je 0x405efd
movsd 0x100(%rsp,%rsi,8), %xmm6
mulsd %xmm3, %xmm6
movsd 0x118(%rsp,%rsi,8), %xmm7
mulsd %xmm4, %xmm7
addsd %xmm6, %xmm7
movsd 0x130(%rsp,%rsi,8), %xmm6
mulsd %xmm5, %xmm6
addsd %xmm7, %xmm6
movsd %xmm6, (%rdi,%rsi,8)
incq %rsi
jmp 0x405ebf
incq %rcx
incq %rax
addq %rsi, %rdx
jmp 0x405e8e
mulsd %xmm1, %xmm13
subsd %xmm2, %xmm13
addsd %xmm0, %xmm13
movsd 0x250(%rsp), %xmm8
movsd 0x258(%rsp), %xmm4
movsd 0x260(%rsp), %xmm1
movapd %xmm1, %xmm0
addsd %xmm8, %xmm0
movsd 0x278(%rsp), %xmm5
movapd %xmm0, %xmm3
addsd %xmm5, %xmm3
movsd 0x17d0bb(%rip), %xmm2   # 0x583010
mulsd %xmm2, %xmm3
movupd 0x268(%rsp), %xmm6
movapd %xmm6, %xmm9
unpckhpd %xmm6, %xmm9            # xmm9 = xmm9[1],xmm6[1]
movapd %xmm9, %xmm7
mulsd %xmm9, %xmm7
movapd %xmm6, 0x1b0(%rsp)
mulsd %xmm6, %xmm6
movsd %xmm5, 0x1a0(%rsp)
mulsd %xmm5, %xmm0
movapd %xmm1, 0x150(%rsp)
mulsd %xmm8, %xmm1
addsd %xmm0, %xmm1
movapd %xmm4, 0x1c0(%rsp)
mulsd %xmm4, %xmm4
movapd %xmm6, 0x230(%rsp)
movapd %xmm6, %xmm0
movapd %xmm4, 0x220(%rsp)
addsd %xmm4, %xmm0
movapd %xmm7, 0x240(%rsp)
addsd %xmm7, %xmm0
subsd %xmm0, %xmm1
mulsd %xmm2, %xmm1
xorl %eax, %eax
cmpq $0x3, %rax
je 0x405ff4
movsd %xmm3, 0x90(%rsp,%rax,8)
incq %rax
jmp 0x405fe0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm3
jbe 0x406400
movapd %xmm3, %xmm0
mulsd %xmm3, %xmm0
subsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jbe 0x406460
movapd %xmm9, 0x1d0(%rsp)
movapd %xmm8, 0x1e0(%rsp)
movapd %xmm13, %xmm2
mulsd %xmm13, %xmm2
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
mulsd 0x17cfd2(%rip), %xmm1   # 0x583018
movapd %xmm0, %xmm2
mulsd %xmm3, %xmm2
subsd %xmm2, %xmm1
sqrtsd %xmm0, %xmm2
movapd %xmm2, 0x1f0(%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 0x17d085(%rip), %xmm1   # 0x583110
movsd %xmm12, 0x198(%rsp)
movapd %xmm13, 0x210(%rsp)
movapd %xmm3, 0x200(%rsp)
callq 0x4aa760
mulsd 0x17cf5b(%rip), %xmm0   # 0x583010
leaq 0x1a8(%rsp), %rdi
leaq 0x280(%rsp), %r12
movq %r12, %rsi
callq 0x4a9cd0
movapd 0x200(%rsp), %xmm15
movsd 0x17cf28(%rip), %xmm14  # 0x583008
movapd 0x210(%rsp), %xmm13
movsd 0x198(%rsp), %xmm12
movapd 0x17d024(%rip), %xmm0   # 0x583120
movlpd (%r12), %xmm0           # xmm0 = mem[0],xmm0[1]
movapd 0x1f0(%rsp), %xmm1
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm0, %xmm1
movapd 0x17d015(%rip), %xmm2   # 0x583130
leaq 0x1a8(%rsp), %rax
movhpd (%rax), %xmm2           # xmm2 = xmm2[0],mem[0]
mulpd %xmm1, %xmm2
movapd %xmm15, %xmm0
subsd %xmm1, %xmm0
unpcklpd %xmm0, %xmm15           # xmm15 = xmm15[0],xmm0[0]
addpd %xmm2, %xmm15
movapd %xmm15, 0x90(%rsp)
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
subsd %xmm2, %xmm0
movsd %xmm0, 0xa0(%rsp)
testl %r13d, %r13d
je 0x4069f1
movapd 0x1b0(%rsp), %xmm4
movapd %xmm4, %xmm3
mulsd 0x1d0(%rsp), %xmm3
movapd 0x1c0(%rsp), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
shufpd $0x1, %xmm4, %xmm4      # xmm4 = xmm4[1,0]
mulpd %xmm0, %xmm4
movaps 0x150(%rsp), %xmm0
unpcklpd 0x1e0(%rsp), %xmm0      # xmm0 = xmm0[0],mem[0]
movaps %xmm0, 0x150(%rsp)
pushq $0x3
popq %rax
leaq 0x40(%rsp), %rcx
xorl %edx, %edx
movapd 0x17cf87(%rip), %xmm0   # 0x583140
movsd 0x17ce67(%rip), %xmm5   # 0x583028
movapd 0x17cf77(%rip), %xmm6   # 0x583140
movsd 0x17ce37(%rip), %xmm1   # 0x583008
leaq 0x17ddf8(%rip), %rsi    # 0x583fd0
pushq $0x6
popq %rdi
cmpq $0x2, %rdx
ja 0x406468
movsd 0x90(%rsp,%rdx,8), %xmm9
movapd %xmm9, %xmm7
subsd 0x1a0(%rsp), %xmm7
movapd %xmm7, %xmm11
mulsd 0x1c0(%rsp), %xmm11
addsd %xmm3, %xmm11
movsd %xmm11, 0x168(%rsp)
unpcklpd %xmm9, %xmm9            # xmm9 = xmm9[0,0]
subpd 0x150(%rsp), %xmm9
movapd %xmm9, %xmm8
mulsd %xmm7, %xmm8
subsd 0x240(%rsp), %xmm8
movapd %xmm8, %xmm10
andpd %xmm0, %xmm10
ucomisd %xmm5, %xmm10
movsd %xmm8, 0x160(%rsp)
movapd %xmm9, %xmm10
unpckhpd %xmm9, %xmm10           # xmm10 = xmm10[1],xmm9[1]
mulsd %xmm10, %xmm7
subsd 0x230(%rsp), %xmm7
movsd %xmm7, 0x170(%rsp)
mulsd %xmm9, %xmm10
mulpd 0x1b0(%rsp), %xmm9
addpd %xmm4, %xmm9
movupd %xmm9, 0x178(%rsp)
subsd 0x220(%rsp), %xmm10
movsd %xmm10, 0x188(%rsp)
ja 0x4062ba
andq $0x0, 0x160(%rsp)
xorpd %xmm8, %xmm8
andpd %xmm0, %xmm11
ucomisd %xmm5, %xmm11
ja 0x4062cf
andq $0x0, 0x168(%rsp)
movapd %xmm7, %xmm11
andpd %xmm0, %xmm11
ucomisd %xmm5, %xmm11
ja 0x4062ed
andq $0x0, 0x170(%rsp)
xorpd %xmm7, %xmm7
movapd %xmm9, %xmm11
andpd %xmm0, %xmm11
ucomisd %xmm5, %xmm11
ja 0x406307
andq $0x0, 0x178(%rsp)
unpckhpd %xmm9, %xmm9            # xmm9 = xmm9[1,1]
andpd %xmm0, %xmm9
ucomisd %xmm5, %xmm9
ja 0x406321
andq $0x0, 0x180(%rsp)
movapd %xmm10, %xmm9
andpd %xmm0, %xmm9
ucomisd %xmm5, %xmm9
ja 0x406340
andq $0x0, 0x188(%rsp)
xorpd %xmm10, %xmm10
andpd %xmm6, %xmm8
andpd %xmm6, %xmm7
ucomisd %xmm7, %xmm8
andpd %xmm6, %xmm10
jae 0x406367
xorl %eax, %eax
ucomisd %xmm10, %xmm7
setb %al
leal (%rax,%rax,2), %eax
addl $0x3, %eax
jmp 0x406372
xorl %eax, %eax
ucomisd %xmm10, %xmm8
jae 0x406372
movl %edi, %eax
leal (,%rax,4), %r8d
xorpd %xmm7, %xmm7
movq %rcx, %r9
xorl %r10d, %r10d
cmpq $0x3, %r10
je 0x4063b4
leaq (%r8,%r10,4), %r11
movslq (%rsi,%r11), %r11
movsd 0x160(%rsp,%r11,8), %xmm8
movsd %xmm8, (%r9)
mulsd %xmm8, %xmm8
addsd %xmm8, %xmm7
incq %r10
addq $0x18, %r9
jmp 0x406384
sqrtsd %xmm7, %xmm8
movapd %xmm1, %xmm9
divsd %xmm8, %xmm9
movapd %xmm5, %xmm8
cmpltsd %xmm7, %xmm8
andpd %xmm9, %xmm8
xorl %r8d, %r8d
cmpq $0x48, %r8
je 0x4063f3
movsd (%rcx,%r8), %xmm7
mulsd %xmm8, %xmm7
movsd %xmm7, (%rcx,%r8)
addq $0x18, %r8
jmp 0x4063d6
addq $0x2, %rdx
addq $0x10, %rcx
jmp 0x4061db
movsd 0x10(%rsp), %xmm0
movsd (%rsp), %xmm1
xorpd 0x17ccfd(%rip), %xmm1   # 0x583110
movhpd 0x8(%rsp), %xmm1        # xmm1 = xmm1[0],mem[0]
addq $0x10, %rbp
xorl %eax, %eax
cmpq $0x3, %rax
je 0x4069f1
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 0x20(%rsp,%rax,8), %xmm2
movsd %xmm2, (%r15,%rax,8)
incq %rax
addq $0x18, %rbp
jmp 0x40641f
pushq $0x3
popq %rax
jmp 0x406676
movsd 0x50(%rsp), %xmm3
mulsd 0x40(%rsp), %xmm3
movsd 0x68(%rsp), %xmm4
mulsd 0x58(%rsp), %xmm4
addsd %xmm3, %xmm4
movsd 0x80(%rsp), %xmm3
mulsd 0x70(%rsp), %xmm3
addsd %xmm4, %xmm3
movapd %xmm15, %xmm4
unpckhpd %xmm15, %xmm4           # xmm4 = xmm4[1],xmm15[1]
subsd %xmm4, %xmm15
addsd %xmm2, %xmm2
xorl %edi, %edi
xorl %esi, %esi
ucomisd %xmm2, %xmm15
setbe %dil
seta %sil
leal (%rsi,%rsi), %ecx
leal (%rdi,%rdi), %edx
shll $0x4, %esi
addq %rsp, %rsi
addq $0x40, %rsi
shll $0x4, %edi
addq %rsp, %rdi
addq $0x40, %rdi
xorpd %xmm2, %xmm2
xorl %r8d, %r8d
cmpq $0x48, %r8
je 0x40650a
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
jmp 0x4064dc
ucomisd 0x17cb0e(%rip), %xmm2   # 0x583020
jbe 0x40654c
sqrtsd %xmm2, %xmm1
movsd 0x17cae8(%rip), %xmm0   # 0x583008
divsd %xmm1, %xmm0
leaq (%rsp,%rcx,8), %rcx
addq $0x40, %rcx
xorl %edx, %edx
cmpq $0x48, %rdx
je 0x406611
movsd (%rcx,%rdx), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%rcx,%rdx)
addq $0x18, %rdx
jmp 0x40652e
leaq (%rsp,%rdx,8), %rsi
addq $0x40, %rsi
xorl %edi, %edi
cmpq $0x3, %rdi
je 0x406578
movsd (%rsi), %xmm2
andpd %xmm0, %xmm2
ucomisd %xmm2, %xmm1
minsd %xmm2, %xmm1
cmovael %edi, %eax
incq %rdi
addq $0x18, %rsi
jmp 0x406556
movslq %eax, %r8
leaq 0x17cbde(%rip), %rsi    # 0x583160
movslq (%rsi,%r8,4), %rdi
movslq 0x4(%rsi,%r8,4), %r9
imulq $0x18, %rdi, %rsi
addq %rsp, %rsi
addq $0x40, %rsi
shll $0x3, %edx
movsd (%rdx,%rsi), %xmm0
mulsd %xmm0, %xmm0
imulq $0x18, %r9, %rdi
addq %rsp, %rdi
addq $0x40, %rdi
movsd (%rdx,%rdi), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
sqrtsd %xmm1, %xmm0
ucomisd 0x17ca5a(%rip), %xmm0   # 0x583020
jbe 0x4069f1
leaq (%rsi,%rdx), %r9
imulq $0x18, %r8, %r8
addq %rsp, %r8
addq $0x40, %r8
shll $0x3, %ecx
andq $0x0, (%rcx,%r8)
addq %rdi, %rdx
movsd (%rdx), %xmm1
xorpd 0x17cb1e(%rip), %xmm1   # 0x583110
movsd 0x17ca0e(%rip), %xmm2   # 0x583008
divsd %xmm0, %xmm2
mulsd %xmm2, %xmm1
movsd %xmm1, (%rcx,%rsi)
mulsd (%r9), %xmm2
movsd %xmm2, (%rcx,%rdi)
movsd 0x68(%rsp), %xmm0
movsd 0x70(%rsp), %xmm1
movapd %xmm1, %xmm2
mulsd %xmm0, %xmm2
movsd 0x58(%rsp), %xmm3
movsd 0x80(%rsp), %xmm4
movapd %xmm4, %xmm5
mulsd %xmm3, %xmm5
subsd %xmm5, %xmm2
movsd %xmm2, 0x48(%rsp)
movsd 0x40(%rsp), %xmm2
movsd 0x50(%rsp), %xmm5
mulsd %xmm2, %xmm4
mulsd %xmm5, %xmm1
subsd %xmm1, %xmm4
movsd %xmm4, 0x60(%rsp)
mulsd %xmm3, %xmm5
mulsd %xmm0, %xmm2
subsd %xmm2, %xmm5
movsd %xmm5, 0x78(%rsp)
testl %r13d, %r13d
je 0x4069f1
leaq 0xb0(%rsp), %rcx
xorl %edx, %edx
movsd 0x17c997(%rip), %xmm0   # 0x583028
cmpq $0x2, %rdx
je 0x406734
movsd 0x40(%rsp,%rdx,8), %xmm2
movsd 0x58(%rsp,%rdx,8), %xmm3
movhpd 0x70(%rsp,%rdx,8), %xmm3 # xmm3 = xmm3[0],mem[0]
xorpd %xmm1, %xmm1
xorl %esi, %esi
cmpq $0x48, %rsi
je 0x4066f2
movsd 0x100(%rsp,%rsi), %xmm4
mulsd %xmm2, %xmm4
movupd 0x108(%rsp,%rsi), %xmm5
mulpd %xmm3, %xmm5
addsd %xmm5, %xmm4
unpckhpd %xmm5, %xmm5            # xmm5 = xmm5[1,1]
addsd %xmm4, %xmm5
movsd %xmm5, (%rcx,%rsi)
mulsd %xmm5, %xmm5
addsd %xmm5, %xmm1
addq $0x18, %rsi
jmp 0x4066b3
sqrtsd %xmm1, %xmm2
movapd %xmm14, %xmm3
divsd %xmm2, %xmm3
movapd %xmm0, %xmm2
cmpltsd %xmm1, %xmm2
andpd %xmm3, %xmm2
xorl %esi, %esi
cmpq $0x48, %rsi
je 0x406728
movsd (%rcx,%rsi), %xmm1
mulsd %xmm2, %xmm1
movsd %xmm1, (%rcx,%rsi)
addq $0x18, %rsi
jmp 0x40670e
incq %rdx
addq $0x8, %rcx
jmp 0x406691
movsd 0xb0(%rsp), %xmm1
movsd 0xc8(%rsp), %xmm0
movsd 0xb8(%rsp), %xmm2
mulsd %xmm1, %xmm2
movsd 0xd0(%rsp), %xmm3
mulsd %xmm0, %xmm3
addsd %xmm2, %xmm3
movsd 0xe0(%rsp), %xmm2
movsd 0xe8(%rsp), %xmm4
mulsd %xmm2, %xmm4
addsd %xmm3, %xmm4
xorpd %xmm3, %xmm3
pushq $0x8
popq %rcx
cmpq $0x50, %rcx
je 0x4067bc
movsd 0xb0(%rsp,%rcx), %xmm5
movsd 0xa8(%rsp,%rcx), %xmm6
mulsd %xmm4, %xmm6
subsd %xmm6, %xmm5
movsd %xmm5, 0xb0(%rsp,%rcx)
mulsd %xmm5, %xmm5
addsd %xmm5, %xmm3
addq $0x18, %rcx
jmp 0x406785
ucomisd 0x17c85c(%rip), %xmm3   # 0x583020
jbe 0x4067ff
sqrtsd %xmm3, %xmm4
movsd 0x17c836(%rip), %xmm3   # 0x583008
divsd %xmm4, %xmm3
pushq $0x8
popq %rax
cmpq $0x50, %rax
je 0x4068ce
movsd 0xb0(%rsp,%rax), %xmm4
mulsd %xmm3, %xmm4
movsd %xmm4, 0xb0(%rsp,%rax)
addq $0x18, %rax
jmp 0x4067d9
leaq 0xb0(%rsp), %rcx
xorl %edx, %edx
movapd 0x17c92f(%rip), %xmm3   # 0x583140
cmpq $0x3, %rdx
je 0x406835
movsd (%rcx), %xmm4
andpd %xmm3, %xmm4
ucomisd %xmm4, %xmm14
minsd %xmm4, %xmm14
cmovael %edx, %eax
incq %rdx
addq $0x18, %rcx
jmp 0x406811
cltq
leaq 0x17c922(%rip), %rcx    # 0x583160
movslq (%rcx,%rax,4), %rdx
movslq 0x4(%rcx,%rax,4), %rsi
imulq $0x18, %rdx, %rcx
movsd 0xb0(%rsp,%rcx), %xmm3
movapd %xmm3, %xmm5
mulsd %xmm3, %xmm5
imulq $0x18, %rsi, %rdx
movsd 0xb0(%rsp,%rdx), %xmm4
movapd %xmm4, %xmm6
mulsd %xmm4, %xmm6
addsd %xmm5, %xmm6
sqrtsd %xmm6, %xmm5
ucomisd 0x17c79f(%rip), %xmm5   # 0x583020
jbe 0x406995
addq %rsp, %rcx
addq $0xb0, %rcx
addq %rsp, %rdx
addq $0xb0, %rdx
imulq $0x18, %rax, %rax
andq $0x0, 0xb8(%rsp,%rax)
xorpd 0x17c860(%rip), %xmm4   # 0x583110
movsd 0x17c750(%rip), %xmm6   # 0x583008
divsd %xmm5, %xmm6
mulsd %xmm6, %xmm4
movsd %xmm4, 0x8(%rcx)
mulsd %xmm6, %xmm3
movsd %xmm3, 0x8(%rdx)
movsd 0xe8(%rsp), %xmm3
movapd %xmm3, %xmm4
mulsd %xmm0, %xmm4
movsd 0xb8(%rsp), %xmm5
movsd 0xd0(%rsp), %xmm6
movapd %xmm6, %xmm7
mulsd %xmm2, %xmm7
subsd %xmm7, %xmm4
movsd %xmm4, 0xc0(%rsp)
mulsd %xmm5, %xmm2
mulsd %xmm1, %xmm3
subsd %xmm3, %xmm2
movsd %xmm2, 0xd8(%rsp)
mulsd %xmm1, %xmm6
mulsd %xmm0, %xmm5
subsd %xmm5, %xmm6
movsd %xmm6, 0xf0(%rsp)
leaq 0x48(%rsp), %rax
xorl %ecx, %ecx
movq %rbp, %rdx
cmpq $0x3, %rcx
je 0x406995
imulq $0x18, %rcx, %rsi
movsd 0xb0(%rsp,%rsi), %xmm0
movupd 0xb8(%rsp,%rsi), %xmm1
movq %rax, %rsi
xorl %edi, %edi
cmpq $0x3, %rdi
je 0x40698c
movsd -0x8(%rsi), %xmm2
mulsd %xmm0, %xmm2
movupd (%rsi), %xmm3
mulpd %xmm1, %xmm3
addsd %xmm3, %xmm2
unpckhpd %xmm3, %xmm3            # xmm3 = xmm3[1,1]
addsd %xmm2, %xmm3
movsd %xmm3, (%rdx,%rdi,8)
incq %rdi
addq $0x18, %rsi
jmp 0x40695b
incq %rcx
addq $0x18, %rdx
jmp 0x40693a
movsd 0x10(%rsp), %xmm0
movsd (%rsp), %xmm1
xorpd 0x17c768(%rip), %xmm1   # 0x583110
movhpd 0x8(%rsp), %xmm1        # xmm1 = xmm1[0],mem[0]
addq $0x10, %rbp
xorl %eax, %eax
cmpq $0x3, %rax
je 0x4069f1
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 0x20(%rsp,%rax,8), %xmm2
movsd %xmm2, (%r15,%rax,8)
incq %rax
addq $0x18, %rbp
jmp 0x4069b4
xorl %eax, %eax
xorpd %xmm0, %xmm0
cmpq $0x3, %rax
je 0x406a1c
movsd 0x90(%rsp,%rax,8), %xmm1
maxsd %xmm0, %xmm1
sqrtsd %xmm1, %xmm1
movsd %xmm1, 0x90(%rsp,%rax,8)
incq %rax
jmp 0x4069f7
movsd 0xa0(%rsp), %xmm0
movapd 0x17c6e3(%rip), %xmm1   # 0x583110
xorpd %xmm0, %xmm1
xorpd %xmm2, %xmm2
cmpltsd %xmm2, %xmm13
andpd %xmm13, %xmm1
andnpd %xmm0, %xmm13
orpd %xmm1, %xmm13
addsd 0x98(%rsp), %xmm13
addsd 0x90(%rsp), %xmm13
addsd %xmm13, %xmm13
subsd %xmm13, %xmm12
maxsd %xmm2, %xmm12
movsd %xmm12, (%r14)
testl %ebx, %ebx
setg %al
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq