// File: /workspace/github_c_makefile_star2_O1/asford[P]tmalign/./TMalign.h
// Function: output_results(char*, char*, int, int, double*, double (*) [3], double, double, double, double, int*, int*, int, int, double, double, double)
void output_results(char *xname,
					 char *yname,
					 int x_len,
					 int y_len,
					 double t[3],
					 double u[3][3],
					 double TM1,
					 double TM2,
					 double rmsd,
					 double d0_out,
					 int m1[], 
					 int m2[],
					 int n_ali8,
					 int n_ali,
					 double TM_0,
					 double Lnorm_0,
					 double d0_0
					 )
{
    double seq_id;          
    int i, j, k;
    double d;
    int ali_len=x_len+y_len; //maximum length of alignment
	char *seqM, *seqxA, *seqyA;
	seqM=new char[ali_len];
	seqxA=new char[ali_len];
	seqyA=new char[ali_len];
	

	do_rotation(xa, xt, x_len, t, u);

	seq_id=0;
	int kk=0, i_old=0, j_old=0;
	for(k=0; k<n_ali8; k++)
	{
		for(i=i_old; i<m1[k]; i++)
		{
			//align x to gap
			seqxA[kk]=seqx[i];
			seqyA[kk]='-';
			seqM[kk]=' ';					
			kk++;
		}

		for(j=j_old; j<m2[k]; j++)
		{
			//align y to gap
			seqxA[kk]='-';
            seqyA[kk]=seqy[j];
            seqM[kk]=' ';
            kk++;
		}

		seqxA[kk]=seqx[m1[k]];
		seqyA[kk]=seqy[m2[k]];
		if(seqxA[kk]==seqyA[kk])
		{
			seq_id++;
		}
		d=sqrt(dist(&xt[m1[k]][0], &ya[m2[k]][0]));
		if(d<d0_out)
		{
			seqM[kk]=':';
		}
		else
		{
			seqM[kk]='.';
		} 
		kk++;  
		i_old=m1[k]+1;
		j_old=m2[k]+1;
	}

	//tail
	for(i=i_old; i<x_len; i++)
	{
		//align x to gap
		seqxA[kk]=seqx[i];
		seqyA[kk]='-';
		seqM[kk]=' ';					
		kk++;
	}    
	for(j=j_old; j<y_len; j++)
	{
		//align y to gap
		seqxA[kk]='-';
		seqyA[kk]=seqy[j];
		seqM[kk]=' ';
		kk++;
	}
 
    seqxA[kk]='\0';
    seqyA[kk]='\0';
    seqM[kk]='\0';
	

	seq_id=seq_id/( n_ali8+0.00000001); //what did by TMalign, but not reasonable, it should be n_ali8    




 



	
	cout <<endl;	
	cout << " *****************************************************************************" << endl
		 << " * TM-align (Version "<< version <<"): A protein structural alignment algorithm     *" << endl
		 << " * Reference: Y Zhang and J Skolnick, Nucl Acids Res 33, 2302-9 (2005)       *" << endl
		 << " * Please email your comments and suggestions to Yang Zhang (zhng@umich.edu) *" << endl
		 << " *****************************************************************************" << endl;	


	
	printf("\nName of structure A: %s\n", yname); 
	printf("Name of structure B: %s (to be superimposed onto structure A)\n", xname); 
	printf("Length of structure A: %d residues\n", y_len);
	printf("Length of structure B: %d residues\n\n", x_len);

	printf("Aligned length=%d, RMSD=%6.2f, Seq_ID=n_identical/n_aligned=%4.3f\n\n", n_ali8, rmsd, seq_id); 
	
	printf("TM-score=%6.5f (if normalized by length of structure B, i.e., LN=%d, d0=%.2f)\n", TM2, x_len, d0B);
	printf("TM-score=%6.5f (if normalized by length of structure A, i.e., LN=%d, d0=%.2f)\n", TM1, y_len, d0A);
	if(a_opt)
	{
		double L_ave=(x_len+y_len)*0.5;
		printf("TM-score=%6.5f (if normalized by average length of two structures, i.e., LN=%.2f, d0=%.2f)\n", TM3, L_ave, d0a);
	}
	if(u_opt)
	{		
		printf("TM-score=%6.5f (if normalized by user-specified LN=%.2f and d0=%.2f)\n", TM4, Lnorm_ass, d0u);
	}
	if(d_opt)
	{		
		printf("TM-score=%6.5f (if scaled by user-specified d0=%.2f, and LN=%.2f)\n", TM5, d0_scale, Lnorm_0);
	}
	printf("(You should use TM-score normalized by length of the reference protein)\n");

   

    printf("\n----- The rotation matrix to rotate Structure B to Structure A -----\n");
    
    printf("i\t%18s %15s %15s %15s\n", "t[i]", "u[i][0]", "u[i][1]", "u[i][2]");
    for(k=0; k<3; k++)
    {
        printf("%d\t%18.10f %15.10f %15.10f %15.10f\n",\
                k, t[k], u[k][0], u[k][1] ,u[k][2]);
    }
    printf("\nCode for rotating Structure B from (x,y,z) to (X,Y,Z):\n");
    printf("for(k=0; k<L; k++)\n");
    printf("{\n");
    printf("   X[k] = t[0] + u[0][0]*x[k] + u[0][1]*y[k] + u[0][2]*z[k]\n");
    printf("   Y[k] = t[1] + u[1][0]*x[k] + u[1][1]*y[k] + u[1][2]*z[k]\n");
    printf("   Z[k] = t[2] + u[2][0]*x[k] + u[2][1]*y[k] + u[2][2]*z[k]\n");    
    printf("}\n"); 
    
    
    //output structure alignment
    printf("\n(\":\" denotes residue pairs of d < %4.1f Angstrom, ", d0_out);
    printf("\".\" denotes other aligned residues)\n");
    printf("%s\n", seqxA);
    printf("%s\n", seqM);
    printf("%s\n", seqyA);

	cout << endl;




	if(o_opt)
	{
		output_superpose(xname, yname, x_len, y_len, t, u, rmsd, d0_out, m1, m2, n_ali8, seq_id, TM_0, Lnorm_0, d0_0);
	}


	delete [] seqM;
	delete [] seqxA;
	delete [] seqyA;
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movsd %xmm6, 0x90(%rsp)
movsd %xmm5, 0x50(%rsp)
movsd %xmm4, 0x88(%rsp)
movsd %xmm3, 0x30(%rsp)
movsd %xmm2, 0x70(%rsp)
movsd %xmm1, 0x98(%rsp)
movsd %xmm0, 0xa0(%rsp)
movq %r9, %r13
movq %r8, %rbp
movl %edx, %r14d
movq %rsi, 0x60(%rsp)
movq %rdi, 0x58(%rsp)
movl 0x100(%rsp), %eax
movq %rax, 0x38(%rsp)
movq 0xf8(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0xf0(%rsp), %rax
movq %rax, 0x80(%rsp)
movq %rcx, 0x28(%rsp)
leal (%rcx,%r14), %eax
movl %eax, 0x44(%rsp)
movslq %eax, %rbx
movq %rbx, %rdi
callq 0x40d060
movq %rax, 0x48(%rsp)
movq %rbx, %rdi
callq 0x40d060
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
callq 0x40d060
movq %rax, 0x8(%rsp)
movq %r14, 0x18(%rsp)
testl %r14d, %r14d
jle 0x40a2ac
movq 0x1f833e(%rip), %rbx    # 0x6025c0
movq 0x1f8367(%rip), %r14    # 0x6025f0
movl 0x18(%rsp), %r15d
xorl %r12d, %r12d
movq (%rbx,%r12,8), %rdx
movq (%r14,%r12,8), %rcx
movq %rbp, %rdi
movq %r13, %rsi
callq 0x4058ff
incq %r12
cmpq %r12, %r15
jne 0x40a291
movq %rbp, 0x68(%rsp)
movq 0x38(%rsp), %rax
testl %eax, %eax
jle 0x40a484
movq 0x1f8333(%rip), %rcx    # 0x6025f8
movq 0x1f8334(%rip), %rdx    # 0x602600
movq 0x1f831d(%rip), %rsi    # 0x6025f0
movq %rsi, 0x20(%rsp)
movq 0x1f82e9(%rip), %rsi    # 0x6025c8
movq %rsi, 0xb0(%rsp)
movl %eax, %eax
movq %rax, 0xa8(%rsp)
xorl %r9d, %r9d
xorpd %xmm1, %xmm1
movsd 0x179d08(%rip), %xmm0   # 0x584008
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %eax, %eax
movsd 0x30(%rsp), %xmm4
movq 0x48(%rsp), %rsi
movq %rsi, %rdi
movq %r13, %rbp
movq %rsi, %r13
movq %rbp, %r8
movq 0x80(%rsp), %rsi
movslq (%rsi,%r9,4), %r12
cmpl %r12d, %r14d
jge 0x40a37b
movslq %eax, %r15
movslq %r14d, %r10
leaq (%rcx,%r10), %r14
movq %r12, %r11
subq %r10, %r11
movq 0x10(%rsp), %rsi
leaq (%rsi,%r15), %rbp
movq 0x8(%rsp), %rsi
leaq (%rsi,%r15), %r10
addq %r13, %r15
xorl %r13d, %r13d
movb (%r14,%r13), %sil
movb %sil, (%rbp,%r13)
movb $0x2d, (%r10,%r13)
movb $0x20, (%r15,%r13)
incq %r13
cmpq %r13, %r11
jne 0x40a357
addl %r13d, %eax
movq %rdi, %r13
movq %r8, %rbp
movq 0x78(%rsp), %rsi
movslq (%rsi,%r9,4), %r15
cmpl %r15d, %ebx
jge 0x40a3d5
movslq %eax, %r14
movslq %ebx, %r10
leaq (%rdx,%r10), %rbx
movq %r15, %r11
subq %r10, %r11
movq 0x10(%rsp), %rsi
leaq (%rsi,%r14), %rbp
movq 0x8(%rsp), %rsi
leaq (%rsi,%r14), %r10
addq %r13, %r14
xorl %r13d, %r13d
movb $0x2d, (%rbp,%r13)
movb (%rbx,%r13), %sil
movb %sil, (%r10,%r13)
movb $0x20, (%r14,%r13)
incq %r13
cmpq %r13, %r11
jne 0x40a3b1
addl %r13d, %eax
movq %rdi, %r13
movq %r8, %rbp
movb (%rcx,%r12), %sil
cltq
movq 0x10(%rsp), %r10
movb %sil, (%r10,%rax)
movb (%rdx,%r15), %r10b
movq 0x8(%rsp), %r11
movb %r10b, (%r11,%rax)
movapd %xmm1, %xmm5
addsd %xmm0, %xmm5
cmpb %r10b, %sil
je 0x40a402
movapd %xmm1, %xmm5
movq 0x20(%rsp), %rsi
movq (%rsi,%r12,8), %rsi
movq 0xb0(%rsp), %r10
movq (%r10,%r15,8), %r10
movsd (%rsi), %xmm1
subsd (%r10), %xmm1
mulsd %xmm1, %xmm1
movupd 0x8(%rsi), %xmm2
movupd 0x8(%r10), %xmm3
subpd %xmm3, %xmm2
mulpd %xmm2, %xmm2
addsd %xmm2, %xmm1
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm1, %xmm2
xorps %xmm1, %xmm1
sqrtsd %xmm2, %xmm1
ucomisd %xmm4, %xmm1
movl $0x2e, %esi
movl $0x3a, %r10d
cmovbl %r10d, %esi
movb %sil, (%r13,%rax)
incl %eax
leal 0x1(%r12), %r14d
leal 0x1(%r15), %ebx
incq %r9
movapd %xmm5, %xmm1
cmpq 0xa8(%rsp), %r9
jne 0x40a31e
jmp 0x40a497
xorpd %xmm5, %xmm5
xorl %eax, %eax
xorl %r14d, %r14d
xorl %ebx, %ebx
movq %r13, %rbp
movq 0x48(%rsp), %r13
movq 0x18(%rsp), %rsi
cmpl %esi, %r14d
jge 0x40a4e8
movslq %eax, %rcx
movslq %r14d, %rdx
movslq %esi, %rsi
subq %rdx, %rsi
addq 0x1f8144(%rip), %rdx    # 0x6025f8
movq 0x10(%rsp), %rdi
addq %rcx, %rdi
movq 0x8(%rsp), %r8
leaq (%r8,%rcx), %r9
addq %r13, %rcx
xorl %r8d, %r8d
movb (%rdx,%r8), %r10b
movb %r10b, (%rdi,%r8)
movb $0x2d, (%r9,%r8)
movb $0x20, (%rcx,%r8)
incq %r8
cmpq %r8, %rsi
jne 0x40a4cb
addl %r8d, %eax
movq 0x28(%rsp), %r14
cmpl %r14d, %ebx
movq 0x38(%rsp), %r12
jge 0x40a540
movslq %ebx, %rcx
movslq %r14d, %rdx
subq %rcx, %rdx
addq 0x1f80f9(%rip), %rcx    # 0x602600
movslq %eax, %r8
movq 0x10(%rsp), %rsi
addq %r8, %rsi
movq 0x8(%rsp), %rdi
addq %r8, %rdi
movq %r13, %r9
addq %r8, %r9
xorl %r8d, %r8d
movb $0x2d, (%rsi,%r8)
movb (%rcx,%r8), %r10b
movb %r10b, (%rdi,%r8)
movb $0x20, (%r9,%r8)
incq %r8
cmpq %r8, %rdx
jne 0x40a523
addl %r8d, %eax
cltq
xorl %ecx, %ecx
movq 0x10(%rsp), %rdx
movb %cl, (%rdx,%rax)
movq 0x8(%rsp), %rdx
movb %cl, (%rdx,%rax)
cvtsi2sd %r12d, %xmm0
movb %cl, (%r13,%rax)
addsd 0x179aba(%rip), %xmm0   # 0x584020
divsd %xmm0, %xmm5
movsd %xmm5, 0x20(%rsp)
movq $0x605d20, %rbx         # imm = 0x605D20
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x456f30
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4758e0
movq %rax, %rdi
callq 0x474eb0
leaq 0x179e83(%rip), %rsi    # 0x584428
movl $0x4e, %edx
movq %rbx, %rdi
callq 0x475de0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x456f30
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4758e0
movq %rax, %rdi
callq 0x474eb0
movq %rax, %rbx
leaq 0x179e94(%rip), %rsi    # 0x584477
movl $0x15, %edx
movq %rax, %rdi
callq 0x475de0
leaq 0x1f7f59(%rip), %r15    # 0x602550
movq %r15, %rdi
callq 0x401120
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x475de0
leaq 0x179e79(%rip), %rsi    # 0x58448d
movl $0x31, %edx
movq %rbx, %rdi
callq 0x475de0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x456f30
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4758e0
movq %rax, %rdi
callq 0x474eb0
movq %rax, %rbx
leaq 0x179e6d(%rip), %rsi    # 0x5844bf
movl $0x4e, %edx
movq %rax, %rdi
callq 0x475de0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x456f30
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4758e0
movq %rax, %rdi
callq 0x474eb0
movq %rax, %rbx
leaq 0x179e7e(%rip), %rsi    # 0x58450e
movl $0x4e, %edx
movq %rax, %rdi
callq 0x475de0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x456f30
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4758e0
movq %rax, %rdi
callq 0x474eb0
movq %rax, %rbx
movl $0x4e, %edx
movq %rax, %rdi
leaq 0x179d52(%rip), %rsi    # 0x584428
callq 0x475de0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x456f30
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4758e0
movq %rax, %rdi
callq 0x474eb0
leaq 0x179e54(%rip), %rdi    # 0x58455d
movq 0x60(%rsp), %rsi
xorl %eax, %eax
callq 0x4d9810
leaq 0x179e5b(%rip), %rdi    # 0x584577
movq 0x58(%rsp), %rsi
xorl %eax, %eax
callq 0x4d9810
leaq 0x179e87(%rip), %rdi    # 0x5845b6
movl %r14d, %esi
xorl %eax, %eax
callq 0x4d9810
leaq 0x179e9a(%rip), %rdi    # 0x5845da
movq 0x18(%rsp), %rbx
movl %ebx, %esi
xorl %eax, %eax
callq 0x4d9810
leaq 0x179eaa(%rip), %rdi    # 0x5845ff
movl %r12d, %esi
movsd 0x70(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
movb $0x2, %al
callq 0x4d9810
movsd 0x1fa65d(%rip), %xmm1   # 0x604dd0
leaq 0x179ec9(%rip), %rdi    # 0x584643
movsd 0x98(%rsp), %xmm0
movl %ebx, %esi
movb $0x2, %al
callq 0x4d9810
movsd 0x1fa634(%rip), %xmm1   # 0x604dc8
leaq 0x179ef7(%rip), %rdi    # 0x584692
movsd 0xa0(%rsp), %xmm0
movl %r14d, %esi
movb $0x2, %al
callq 0x4d9810
cmpb $0x1, 0x1fa634(%rip)    # 0x604de9
jne 0x40a7e6
xorps %xmm1, %xmm1
cvtsi2sdl 0x44(%rsp), %xmm1
mulsd 0x179850(%rip), %xmm1   # 0x584018
movsd 0x1fa620(%rip), %xmm0   # 0x604df0
movsd 0x1fa608(%rip), %xmm2   # 0x604de0
leaq 0x179f02(%rip), %rdi    # 0x5846e1
movb $0x3, %al
callq 0x4d9810
cmpb $0x1, 0x1fa5fd(%rip)    # 0x604dea
jne 0x40a815
movsd 0x1fa601(%rip), %xmm0   # 0x604df8
movsd 0x1fa5b1(%rip), %xmm1   # 0x604db0
movsd 0x1fa5d1(%rip), %xmm2   # 0x604dd8
leaq 0x179f2f(%rip), %rdi    # 0x58473d
movb $0x3, %al
callq 0x4d9810
cmpb $0x1, 0x1fa5cf(%rip)    # 0x604deb
jne 0x40a842
movsd 0x1fa5da(%rip), %xmm0   # 0x604e00
movsd 0x1fa592(%rip), %xmm1   # 0x604dc0
leaq 0x179f4e(%rip), %rdi    # 0x584783
movsd 0x50(%rsp), %xmm2
movb $0x3, %al
callq 0x4d9810
leaq 0x17a625(%rip), %rdi    # 0x584e6e
callq 0x4e8d30
leaq 0x17a661(%rip), %rdi    # 0x584eb6
callq 0x4e8d30
leaq 0x179f65(%rip), %rdi    # 0x5847c6
leaq 0x179f75(%rip), %rsi    # 0x5847dd
leaq 0x179f73(%rip), %rdx    # 0x5847e2
leaq 0x179f74(%rip), %rcx    # 0x5847ea
leaq 0x179f75(%rip), %r8     # 0x5847f2
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4d9810
movq %rbp, %r12
leaq 0x10(%rbp), %r14
leaq 0x179f66(%rip), %r15    # 0x5847fa
movq 0x68(%rsp), %rbp
movsd (%rbp,%rbx,8), %xmm0
movsd -0x10(%r14), %xmm1
movsd -0x8(%r14), %xmm2
movsd (%r14), %xmm3
movq %r15, %rdi
movl %ebx, %esi
movb $0x4, %al
callq 0x4d9810
incq %rbx
addq $0x18, %r14
cmpq $0x3, %rbx
jne 0x40a899
leaq 0x17a62c(%rip), %rdi    # 0x584efc
callq 0x4e8d30
leaq 0x17a658(%rip), %rdi    # 0x584f34
callq 0x4e8d30
leaq 0x17a65f(%rip), %rdi    # 0x584f47
callq 0x4e8d30
leaq 0x17a655(%rip), %rdi    # 0x584f49
callq 0x4e8d30
leaq 0x17a685(%rip), %rdi    # 0x584f85
callq 0x4e8d30
leaq 0x17a6b5(%rip), %rdi    # 0x584fc1
callq 0x4e8d30
leaq 0x17a6e5(%rip), %rdi    # 0x584ffd
callq 0x4e8d30
leaq 0x179efa(%rip), %rdi    # 0x58481e
movsd 0x30(%rsp), %xmm0
movb $0x1, %al
callq 0x4d9810
leaq 0x17a6c7(%rip), %rdi    # 0x584fff
callq 0x4e8d30
movq 0x10(%rsp), %rdi
callq 0x4e8d30
movq %r13, %rdi
callq 0x4e8d30
movq 0x8(%rsp), %rdi
callq 0x4e8d30
movq $0x605d20, %rbx         # imm = 0x605D20
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x456f30
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4758e0
movq %rax, %rdi
callq 0x474eb0
cmpb $0x1, 0x1fa45a(%rip)    # 0x604de8
jne 0x40a9f5
subq $0x8, %rsp
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq 0x70(%rsp), %r8
movq %r12, %r9
movsd 0x78(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
movsd 0x90(%rsp), %xmm3
movsd 0x58(%rsp), %xmm4
movsd 0x98(%rsp), %xmm5
pushq 0x40(%rsp)
pushq 0x88(%rsp)
pushq 0x98(%rsp)
callq 0x4098f3
addq $0x20, %rsp
movq %r13, %rdi
callq 0x40c360
movq 0x10(%rsp), %rdi
callq 0x40c360
movq 0x8(%rsp), %rdi
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x40c360