// File: /workspace/github_c_makefile_star2_O0/asford[P]tmalign/./TMalign.h
// Function: find_max_frag(double**, int*, int, int*, int*)
void find_max_frag(double **x, int *resno, int len, int *start_max, int *end_max)
{
	int r_min, fra_min=4;           //minimum fragment for search
	double d;
	int start;
	int Lfr_max=0, flag;

	r_min= (int) (len*1.0/3.0); //minimum fragment, in case too small protein
	if(r_min > fra_min) r_min=fra_min;
	
	int inc=0;
	double dcu0_cut=dcu0*dcu0;;
	double dcu_cut=dcu0_cut;

	while(Lfr_max < r_min)
	{		
		Lfr_max=0;			
		int j=1;    //number of residues at nf-fragment
		start=0;
		for(int i=1; i<len; i++)
		{			
			d = dist(x[i-1], x[i]);
			flag=0;
			if(dcu_cut>dcu0_cut)
			{
				if(d<dcu_cut)
				{
					flag=1;
				}
			}
			else if(resno[i] == (resno[i-1]+1)) //necessary??
			{
				if(d<dcu_cut)
				{
					flag=1;
				}
			}

			if(flag==1)
			{
				j++;

				if(i==(len-1))
				{
					if(j > Lfr_max) 
					{
						Lfr_max=j;
						*start_max=start;
						*end_max=i;						
					}
					j=1;
				}
			}
			else
			{
				if(j>Lfr_max) 
				{
					Lfr_max=j;
					*start_max=start;
					*end_max=i-1;										
				}

				j=1;
				start=i;
			}
		}// for i;
		
		if(Lfr_max < r_min)
		{
			inc++;
			double dinc=pow(1.1, (double) inc) * dcu0;
			dcu_cut= dinc*dinc;
		}
	}//while <;	
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movl %edx, 0x54(%rsp)
movq %rcx, 0x48(%rsp)
movq %r8, 0x40(%rsp)
movl $0x4, 0x38(%rsp)
movl $0x0, 0x28(%rsp)
cvtsi2sdl 0x54(%rsp), %xmm0
movsd 0x17feee(%rip), %xmm1   # 0x58c008
mulsd %xmm1, %xmm0
movsd 0x17ff02(%rip), %xmm1   # 0x58c028
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
cmpl 0x38(%rsp), %eax
jle 0x40c144
movl 0x38(%rsp), %eax
movl %eax, 0x3c(%rsp)
movl $0x0, 0x20(%rsp)
movsd 0x1fe43c(%rip), %xmm0   # 0x60a590
mulsd 0x1fe434(%rip), %xmm0   # 0x60a590
movsd %xmm0, 0x18(%rsp)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x28(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jge 0x40c336
movl $0x0, 0x28(%rsp)
movl $0x1, 0xc(%rsp)
movl $0x0, 0x2c(%rsp)
movl $0x1, 0x8(%rsp)
movl 0x8(%rsp), %eax
cmpl 0x54(%rsp), %eax
jge 0x40c2ec
movq 0x60(%rsp), %rax
movl 0x8(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
movq 0x60(%rsp), %rax
movslq 0x8(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x406000
movsd %xmm0, 0x30(%rsp)
movl $0x0, 0x24(%rsp)
movsd 0x10(%rsp), %xmm0
ucomisd 0x18(%rsp), %xmm0
jbe 0x40c208
movsd 0x30(%rsp), %xmm1
movsd 0x10(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x40c206
movl $0x1, 0x24(%rsp)
jmp 0x40c24c
movq 0x58(%rsp), %rax
movslq 0x8(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movq 0x58(%rsp), %rcx
movl 0x8(%rsp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x40c24a
movsd 0x30(%rsp), %xmm1
movsd 0x10(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x40c248
movl $0x1, 0x24(%rsp)
jmp 0x40c24a
jmp 0x40c24c
cmpl $0x1, 0x24(%rsp)
jne 0x40c29f
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
movl 0x8(%rsp), %eax
movl 0x54(%rsp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x40c29d
movl 0xc(%rsp), %eax
cmpl 0x28(%rsp), %eax
jle 0x40c295
movl 0xc(%rsp), %eax
movl %eax, 0x28(%rsp)
movl 0x2c(%rsp), %ecx
movq 0x48(%rsp), %rax
movl %ecx, (%rax)
movl 0x8(%rsp), %ecx
movq 0x40(%rsp), %rax
movl %ecx, (%rax)
movl $0x1, 0xc(%rsp)
jmp 0x40c2da
movl 0xc(%rsp), %eax
cmpl 0x28(%rsp), %eax
jle 0x40c2ca
movl 0xc(%rsp), %eax
movl %eax, 0x28(%rsp)
movl 0x2c(%rsp), %ecx
movq 0x48(%rsp), %rax
movl %ecx, (%rax)
movl 0x8(%rsp), %ecx
subl $0x1, %ecx
movq 0x40(%rsp), %rax
movl %ecx, (%rax)
movl $0x1, 0xc(%rsp)
movl 0x8(%rsp), %eax
movl %eax, 0x2c(%rsp)
jmp 0x40c2dc
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0x40c19c
movl 0x28(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jge 0x40c331
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
cvtsi2sdl 0x20(%rsp), %xmm1
movsd 0x17fd89(%rip), %xmm0   # 0x58c098
callq 0x4b0d10
mulsd 0x1fe274(%rip), %xmm0   # 0x60a590
movsd %xmm0, (%rsp)
movsd (%rsp), %xmm0
mulsd (%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
jmp 0x40c16e
addq $0x68, %rsp
retq
nopl (%rax,%rax)