// File: /workspace/github_c_makefile_star2_O0/asford[P]tmalign/./TMalign.h
// Function: get_initial_local(double**, double**, int, int, int*)
bool get_initial_local(  double **x, 
						 double **y, 
						 int x_len,
						 int y_len, 
						 int *y2x
						 )
{
    double GL, rmsd;    
    double t[3];
    double u[3][3];

	double d01=d0+1.5;
	if(d01 < D0_MIN) d01=D0_MIN;
	double d02=d01*d01;
	
	double GLmax=0;
	int n_frag=20; //length of fragment for superposition
	int ns=20; //tail length to discard
	int *invmap=new int[y_len+1];
      
	int aL=getmin(x_len, y_len);
	if(aL>250)
	{
		n_frag=50;
	}
	else if(aL>200)
	{
		n_frag=40;
	}
	else if(aL>150)
	{
		n_frag=30;
	}
	else
	{
		n_frag=20;
	}
	
	int smallest=aL/3; // I change here from aL/2 to aL/3

	if(n_frag>smallest) n_frag=smallest; 
	if(ns>smallest) ns=smallest;
    
	int m1=x_len-n_frag-ns;
	int m2=y_len-n_frag-ns;

	bool flag=false;

	for(int ii=0; ii<y_len; ii++) 
	{                
		y2x[ii]=-1;
	}

	int count=0;
	for(int i=ns-1; i<m1; i=i+n_frag) //index starts from 0, different from FORTRAN
	{
		for(int j=ns-1; j<m2; j=j+n_frag)
		{
			for(int k=0; k<n_frag; k++) //fragment in y
			{ 
				r1[k][0]=x[k+i][0];  
				r1[k][1]=x[k+i][1]; 
				r1[k][2]=x[k+i][2]; 													
                        
                r2[k][0]=y[k+j][0];  
                r2[k][1]=y[k+j][1]; 
                r2[k][2]=y[k+j][2];
			}


			Kabsch(r1, r2, n_frag, 1, &rmsd, t, u);			
			count++;

			double gap_open=0.0;			
			NWDP_TM(x, y, x_len, y_len, t, u, d02, gap_open, invmap);
			GL=get_score_fast(x, y, x_len, y_len, invmap);
			if(GL>GLmax)
			{
				GLmax=GL;
				for(int ii=0; ii<y_len; ii++) 
				{                
					y2x[ii]=invmap[ii];
				}
				flag=true;
			}
		}
	}	


	delete [] invmap;
	return flag;

}

// Assembly:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0x100(%rsp)
movq %rsi, 0xf8(%rsp)
movl %edx, 0xf4(%rsp)
movl %ecx, 0xf0(%rsp)
movq %r8, 0xe8(%rsp)
movsd 0x180b1b(%rip), %xmm0   # 0x58c090
addsd 0x1ff003(%rip), %xmm0   # 0x60a580
movsd %xmm0, 0x68(%rsp)
movsd 0x68(%rsp), %xmm1
movsd 0x1fefd7(%rip), %xmm0   # 0x60a568
ucomisd %xmm1, %xmm0
jbe 0x40b5a5
movsd 0x1fefc9(%rip), %xmm0   # 0x60a568
movsd %xmm0, 0x68(%rsp)
movsd 0x68(%rsp), %xmm0
mulsd 0x68(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x58(%rsp)
movl $0x14, 0x54(%rsp)
movl $0x14, 0x50(%rsp)
movl 0xf0(%rsp), %eax
addl $0x1, %eax
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x411b60
movq %rax, 0x48(%rsp)
movl 0xf4(%rsp), %eax
cmpl 0xf0(%rsp), %eax
jle 0x40b61f
movl 0xf0(%rsp), %eax
movl %eax, 0x10(%rsp)
jmp 0x40b62a
movl 0xf4(%rsp), %eax
movl %eax, 0x10(%rsp)
movl 0x10(%rsp), %eax
movl %eax, 0x44(%rsp)
cmpl $0xfa, 0x44(%rsp)
jle 0x40b646
movl $0x32, 0x54(%rsp)
jmp 0x40b67a
cmpl $0xc8, 0x44(%rsp)
jle 0x40b65a
movl $0x28, 0x54(%rsp)
jmp 0x40b678
cmpl $0x96, 0x44(%rsp)
jle 0x40b66e
movl $0x1e, 0x54(%rsp)
jmp 0x40b676
movl $0x14, 0x54(%rsp)
jmp 0x40b678
jmp 0x40b67a
movl 0x44(%rsp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
movl %eax, 0x40(%rsp)
movl 0x54(%rsp), %eax
cmpl 0x40(%rsp), %eax
jle 0x40b69c
movl 0x40(%rsp), %eax
movl %eax, 0x54(%rsp)
movl 0x50(%rsp), %eax
cmpl 0x40(%rsp), %eax
jle 0x40b6ae
movl 0x40(%rsp), %eax
movl %eax, 0x50(%rsp)
movl 0xf4(%rsp), %eax
subl 0x54(%rsp), %eax
subl 0x50(%rsp), %eax
movl %eax, 0x3c(%rsp)
movl 0xf0(%rsp), %eax
subl 0x54(%rsp), %eax
subl 0x50(%rsp), %eax
movl %eax, 0x38(%rsp)
movb $0x0, 0x37(%rsp)
movl $0x0, 0x30(%rsp)
movl 0x30(%rsp), %eax
cmpl 0xf0(%rsp), %eax
jge 0x40b70f
movq 0xe8(%rsp), %rax
movslq 0x30(%rsp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x40b6e1
movl $0x0, 0x2c(%rsp)
movl 0x50(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x28(%rsp)
movl 0x28(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jge 0x40b9da
movl 0x50(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x24(%rsp)
movl 0x24(%rsp), %eax
cmpl 0x38(%rsp), %eax
jge 0x40b9c7
movl $0x0, 0x20(%rsp)
movl 0x20(%rsp), %eax
cmpl 0x54(%rsp), %eax
jge 0x40b891
movq 0x100(%rsp), %rax
movl 0x20(%rsp), %ecx
addl 0x28(%rsp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd (%rax), %xmm0
movq 0x1fee97(%rip), %rax    # 0x60a618
movslq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, (%rax)
movq 0x100(%rsp), %rax
movl 0x20(%rsp), %ecx
addl 0x28(%rsp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd 0x8(%rax), %xmm0
movq 0x1fee67(%rip), %rax    # 0x60a618
movslq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, 0x8(%rax)
movq 0x100(%rsp), %rax
movl 0x20(%rsp), %ecx
addl 0x28(%rsp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd 0x10(%rax), %xmm0
movq 0x1fee36(%rip), %rax    # 0x60a618
movslq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, 0x10(%rax)
movq 0xf8(%rsp), %rax
movl 0x20(%rsp), %ecx
addl 0x24(%rsp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd (%rax), %xmm0
movq 0x1fee0e(%rip), %rax    # 0x60a620
movslq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, (%rax)
movq 0xf8(%rsp), %rax
movl 0x20(%rsp), %ecx
addl 0x24(%rsp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd 0x8(%rax), %xmm0
movq 0x1fedde(%rip), %rax    # 0x60a620
movslq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, 0x8(%rax)
movq 0xf8(%rsp), %rax
movl 0x20(%rsp), %ecx
addl 0x24(%rsp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd 0x10(%rax), %xmm0
movq 0x1fedad(%rip), %rax    # 0x60a620
movslq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, 0x10(%rax)
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0x40b751
movq 0x1fed80(%rip), %rdi    # 0x60a618
movq 0x1fed81(%rip), %rsi    # 0x60a620
movl 0x54(%rsp), %edx
leaq 0xc0(%rsp), %r9
leaq 0x70(%rsp), %rax
movl $0x1, %ecx
leaq 0xd8(%rsp), %r8
movq %rax, (%rsp)
callq 0x4070f0
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x100(%rsp), %rdi
movq 0xf8(%rsp), %rsi
movl 0xf4(%rsp), %edx
movl 0xf0(%rsp), %ecx
leaq 0xc0(%rsp), %r8
leaq 0x70(%rsp), %r9
movsd 0x60(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movq 0x48(%rsp), %rax
movq %rax, (%rsp)
callq 0x4067b0
movq 0x100(%rsp), %rdi
movq 0xf8(%rsp), %rsi
movl 0xf4(%rsp), %edx
movl 0xf0(%rsp), %ecx
movq 0x48(%rsp), %r8
callq 0x40a1f0
movsd %xmm0, 0xe0(%rsp)
movsd 0xe0(%rsp), %xmm0
ucomisd 0x58(%rsp), %xmm0
jbe 0x40b9b4
movsd 0xe0(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movl $0x0, 0x14(%rsp)
movl 0x14(%rsp), %eax
cmpl 0xf0(%rsp), %eax
jge 0x40b9af
movq 0x48(%rsp), %rax
movslq 0x14(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0xe8(%rsp), %rax
movslq 0x14(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x40b978
movb $0x1, 0x37(%rsp)
jmp 0x40b9b6
movl 0x24(%rsp), %eax
addl 0x54(%rsp), %eax
movl %eax, 0x24(%rsp)
jmp 0x40b73b
jmp 0x40b9c9
movl 0x28(%rsp), %eax
addl 0x54(%rsp), %eax
movl %eax, 0x28(%rsp)
jmp 0x40b722
movq 0x48(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x40b9f4
movq 0x8(%rsp), %rdi
callq 0x410cc0
movb 0x37(%rsp), %al
andb $0x1, %al
addq $0x108, %rsp            # imm = 0x108
retq
nopw %cs:(%rax,%rax)