// File: /workspace/github_c_makefile_star2_O2/asford[P]tmalign/./TMalign.h
// Function: output_superpose(char*, char*, int, int, double*, double (*) [3], double, double, int*, int*, int, double, double, double, double)
void output_superpose(char *xname,
					  char *yname,
					  int x_len,
					  int y_len,
					  double t[3],
					  double u[3][3],
					  double rmsd,
					  double d0_out,
					  int m1[], 
					  int m2[],
					  int n_ali8,
					  double seq_id,
					  double TM_0,
					  double Lnorm_0,
					  double d0_0
					 )
{
	int i, j, j1;
	double dis2;

	int max=2000;


	//aligned region
	FILE *fp=fopen(out_reg, "w");
	fprintf(fp, "load inline\n");
	fprintf(fp, "select atomno<%d\n", max);
	fprintf(fp, "wireframe .45\n");
	fprintf(fp, "select none\n");
	fprintf(fp, "select atomno>%d\n", max);
	fprintf(fp, "wireframe .20\n");
	fprintf(fp, "color white\n");


	do_rotation(xa, xt, x_len, t, u);
	for(i=0; i<n_ali8; i++)
	{
		j=m1[i];
		j1=m2[i];
		dis2=sqrt(dist(&xt[j][0], &ya[j1][0])) ;
		if(dis2<=d0_out)
		{
			fprintf(fp, "select atomno=%d\n", j+1);
			fprintf(fp, "color red\n");

			fprintf(fp, "select atomno=%d\n", max+j1+1);
			fprintf(fp, "color red\n");
		}
	}

	fprintf(fp, "select all\n");
	fprintf(fp, "exit\n");
	fprintf(fp, "REMARK TM-align Version %s\n", version);
	fprintf(fp, "REMARK Structure A:%s   Size=%d\n", yname, y_len);
	fprintf(fp, "REMARK Structure B:%s   Size=%d\n", xname, x_len);
	fprintf(fp, "REMARK TM-score is normalized by %.2f, d0=%.2f\n",  Lnorm_0, d0_0);
	fprintf(fp, "REMARK Aligned length=%d, RMSD=%.2f, TM-score=%.5f, ID=%.3f\n", n_ali8, rmsd, TM_0, seq_id);


	char AA[3];
	//superposed structure B
	for(i=0; i<n_ali8; i++)
	{
		j=m1[i];
		AAmap3(seqx[j], AA);
		fprintf(fp, "ATOM  %5d  CA  %3s %5d    %8.3f%8.3f%8.3f\n", j+1, AA, xresno[j], xt[j][0], xt[j][1], xt[j][2]);
	}
	fprintf(fp, "TER\n");

	for(i=1; i<n_ali8; i++)
	{
		j=m1[i-1]+1;
		j1=m1[i]+1;
		fprintf(fp, "CONECT%5d%5d\n", j, j1);
	}
	//structure A
	for(i=0; i<n_ali8; i++)
	{
		j=m2[i];
		AAmap3(seqy[j], AA);
		fprintf(fp, "ATOM  %5d  CA  %3s %5d    %8.3f%8.3f%8.3f\n", j+max+1, AA, yresno[j], ya[j][0], ya[j][1], ya[j][2]);
	}
	fprintf(fp, "TER\n");
	for(i=1; i<n_ali8; i++)
	{
		j=max+m2[i-1]+1;
		j1=max+m2[i]+1;
		fprintf(fp, "CONECT%5d%5d\n", j, j1);
	}

	fclose(fp);








	//all regions
	char str[3000];
	sprintf(str, "%s_all", out_reg);
	fp=fopen(str, "w");
	fprintf(fp, "load inline\n");
	fprintf(fp, "select atomno<%d\n", max);
	fprintf(fp, "wireframe .45\n");
	fprintf(fp, "select none\n");
	fprintf(fp, "select atomno>%d\n", max);
	fprintf(fp, "wireframe .20\n");
	fprintf(fp, "color white\n");

	for(i=0; i<n_ali8; i++)
	{
		j=m1[i];
		j1=m2[i];
		dis2=sqrt(dist(&xt[j][0], &ya[j1][0])) ;
		if(dis2<=d0_out)
		{
			fprintf(fp, "select atomno=%d\n", j+1);
			fprintf(fp, "color red\n");

			fprintf(fp, "select atomno=%d\n", max+j1+1);
			fprintf(fp, "color red\n");
		}
	}


	fprintf(fp, "select all\n");
	fprintf(fp, "exit\n");
	fprintf(fp, "REMARK TM-align Version %s\n", version);
	fprintf(fp, "REMARK Structure A:%s   Size=%d\n", yname, y_len);
	fprintf(fp, "REMARK Structure B:%s   Size=%d\n", xname, x_len);
	fprintf(fp, "REMARK TM-score is normalized by %.2f, d0=%.2f\n",  Lnorm_0, d0_0);
	fprintf(fp, "REMARK Aligned length=%d, RMSD=%.2f, TM-score=%.5f, ID=%.3f\n", n_ali8, rmsd, TM_0, seq_id);



	//superposed structure B
	for(i=0; i<x_len; i++)
	{
		j=i;
		AAmap3(seqx[j], AA);
		fprintf(fp, "ATOM  %5d  CA  %3s %5d    %8.3f%8.3f%8.3f\n", j+1, AA, xresno[j], xt[j][0], xt[j][1], xt[j][2]);
	}
	fprintf(fp, "TER\n");

	for(i=1; i<x_len; i++)
	{
		fprintf(fp, "CONECT%5d%5d\n", i, i+1);
	}
	//structure A
	for(i=0; i<y_len; i++)
	{
		j=i;
		AAmap3(seqy[j], AA);
		fprintf(fp, "ATOM  %5d  CA  %3s %5d    %8.3f%8.3f%8.3f\n", j+max+1, AA, yresno[j], ya[j][0], ya[j][1], ya[j][2]);
	}
	fprintf(fp, "TER\n");
	for(i=1; i<y_len; i++)
	{
		fprintf(fp, "CONECT%5d%5d\n", max+i, max+i+1);
	}

	fclose(fp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc18, %rsp            # imm = 0xC18
movsd %xmm5, 0x38(%rsp)
movsd %xmm4, 0x30(%rsp)
movsd %xmm3, 0x48(%rsp)
movsd %xmm2, 0x50(%rsp)
movsd %xmm1, 0x58(%rsp)
movsd %xmm0, 0x40(%rsp)
movq %r9, 0x18(%rsp)
movq %r8, %r12
movl %ecx, 0x14(%rsp)
movl %edx, %ebp
movq %rsi, 0x20(%rsp)
movq %rdi, 0x28(%rsp)
leaq 0x1f99d7(%rip), %rdi    # 0x6026a0
leaq 0x17f059(%rip), %rsi    # 0x587d29
callq 0x4e7380
movq %rax, %r13
leaq 0x17a561(%rip), %rdi    # 0x583240
pushq $0xc
popq %rbx
pushq $0x1
popq %r15
movq %rbx, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x4e76b0
leaq 0x17a552(%rip), %rsi    # 0x58324d
movq %r13, %rdi
movl $0x7d0, %edx            # imm = 0x7D0
xorl %eax, %eax
callq 0x4d8660
leaq 0x17a54e(%rip), %rdi    # 0x58325f
pushq $0xe
popq %r14
movq %r14, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x4e76b0
leaq 0x17a544(%rip), %rdi    # 0x58326e
movq %rbx, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x4e76b0
leaq 0x17a53c(%rip), %rsi    # 0x58327b
movq %r13, %rdi
movl $0x7d0, %edx            # imm = 0x7D0
xorl %eax, %eax
callq 0x4d8660
leaq 0x17a538(%rip), %rdi    # 0x58328d
movq %r14, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x4e76b0
leaq 0x17a532(%rip), %rdi    # 0x58329c
movq %rbx, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x4e76b0
movq 0x1f9841(%rip), %rdi    # 0x6025c0
movq 0x1f986a(%rip), %rsi    # 0x6025f0
movl %ebp, 0x10(%rsp)
movl %ebp, %edx
movq %r12, %rcx
movq 0x18(%rsp), %r8
callq 0x405577
movl 0xc60(%rsp), %eax
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movq %rcx, 0x18(%rsp)
xorl %r15d, %r15d
pushq $0xa
popq %rbx
cmpq %r15, 0x18(%rsp)
je 0x408e64
movq 0xc50(%rsp), %rax
movslq (%rax,%r15,4), %r14
movq 0xc58(%rsp), %rax
movslq (%rax,%r15,4), %rbp
movq 0x1f9811(%rip), %rax    # 0x6025f0
movq (%rax,%r14,8), %rdi
movq 0x1f97de(%rip), %rax    # 0x6025c8
movq (%rax,%rbp,8), %rsi
callq 0x4054a5
sqrtsd %xmm0, %xmm0
ucomisd 0x58(%rsp), %xmm0
ja 0x408e5c
incl %r14d
movq %r13, %rdi
leaq 0x17a49d(%rip), %rsi    # 0x5832a9
movl %r14d, %edx
xorl %eax, %eax
callq 0x4d8660
leaq 0x17a49e(%rip), %r12    # 0x5832bb
movq %r12, %rdi
movq %rbx, %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
movq %r13, %rcx
callq 0x4e76b0
addl $0x7d1, %ebp            # imm = 0x7D1
movq %r13, %rdi
leaq 0x17a467(%rip), %rsi    # 0x5832a9
movl %ebp, %edx
xorl %eax, %eax
callq 0x4d8660
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r13, %rcx
callq 0x4e76b0
incq %r15
jmp 0x408db5
leaq 0x17a45b(%rip), %rdi    # 0x5832c6
pushq $0xb
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
movq %r13, %rcx
callq 0x4e76b0
leaq 0x17a44e(%rip), %rdi    # 0x5832d2
pushq $0x5
popq %rsi
movq %r14, %rdx
movq %r13, %rcx
callq 0x4e76b0
leaq 0x17a43f(%rip), %rsi    # 0x5832d8
leaq 0x1f96b0(%rip), %rdx    # 0x602550
xorl %ebp, %ebp
movq %r13, %rdi
xorl %eax, %eax
callq 0x4d8660
leaq 0x17a441(%rip), %rsi    # 0x5832f4
movq %r13, %rdi
movq 0x20(%rsp), %rdx
movl 0x14(%rsp), %ecx
xorl %eax, %eax
callq 0x4d8660
leaq 0x17a448(%rip), %rsi    # 0x583315
movq %r13, %rdi
movq 0x28(%rsp), %rdx
movl 0x10(%rsp), %ecx
xorl %eax, %eax
callq 0x4d8660
leaq 0x17a44f(%rip), %rsi    # 0x583336
movq %r13, %rdi
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movb $0x2, %al
callq 0x4d8660
leaq 0x17a462(%rip), %rsi    # 0x583366
movq %r13, %rdi
movl 0xc60(%rsp), %edx
movsd 0x40(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movsd 0x50(%rsp), %xmm2
movb $0x3, %al
callq 0x4d8660
leaq 0xd(%rsp), %rbx
leaq 0x17a470(%rip), %r12    # 0x5833a3
cmpq %rbp, 0x18(%rsp)
je 0x408f97
movq 0xc50(%rsp), %rax
movslq (%rax,%rbp,4), %r15
movq 0x1f96ab(%rip), %rax    # 0x6025f8
movsbl (%rax,%r15), %edi
movq %rbx, %rsi
callq 0x404974
leal 0x1(%r15), %edx
movq 0x1f966b(%rip), %rax    # 0x6025d0
movl (%rax,%r15,4), %r8d
movq 0x1f9680(%rip), %rax    # 0x6025f0
movq (%rax,%r15,8), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rcx
movb $0x3, %al
callq 0x4d8660
incq %rbp
jmp 0x408f33
leaq 0x17a430(%rip), %rdi    # 0x5833ce
pushq $0x4
popq %rsi
movq %r14, %rdx
movq %r13, %rcx
callq 0x4e76b0
movslq 0xc60(%rsp), %r15
leaq 0x17a418(%rip), %rbx    # 0x5833d3
cmpq %r15, %r14
jge 0x408fe7
movq 0xc50(%rsp), %rax
movl -0x4(%rax,%r14,4), %edx
movl (%rax,%r14,4), %ecx
incl %edx
incl %ecx
movq %r13, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4d8660
incq %r14
jmp 0x408fbb
xorl %ebp, %ebp
leaq 0xd(%rsp), %rbx
leaq 0x17a3ae(%rip), %r12    # 0x5833a3
cmpq %rbp, 0x18(%rsp)
je 0x40905c
movq 0xc58(%rsp), %rax
movslq (%rax,%rbp,4), %r14
movq 0x1f95f1(%rip), %rax    # 0x602600
movsbl (%rax,%r14), %edi
movq %rbx, %rsi
callq 0x404974
leal 0x7d1(%r14), %edx
movq 0x1f95ae(%rip), %rax    # 0x6025d8
movl (%rax,%r14,4), %r8d
movq 0x1f9593(%rip), %rax    # 0x6025c8
movq (%rax,%r14,8), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rcx
movb $0x3, %al
callq 0x4d8660
incq %rbp
jmp 0x408ff5
leaq 0x17a36b(%rip), %rdi    # 0x5833ce
pushq $0x4
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
movq %r13, %rcx
callq 0x4e76b0
movl $0x7d1, %ebp            # imm = 0x7D1
leaq 0x17a353(%rip), %r14    # 0x5833d3
cmpq %r15, %rbx
jge 0x4090aa
movq 0xc58(%rsp), %rax
movl -0x4(%rax,%rbx,4), %edx
addl %ebp, %edx
movl (%rax,%rbx,4), %ecx
addl %ebp, %ecx
movq %r13, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x4d8660
incq %rbx
jmp 0x409080
movq %r13, %rdi
callq 0x4e6c50
leaq 0x17a328(%rip), %rsi    # 0x5833e1
leaq 0x1f95e0(%rip), %rdx    # 0x6026a0
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4d87f0
leaq 0x17ec53(%rip), %rsi    # 0x587d29
movq %rbx, %rdi
callq 0x4e7380
movq %rax, %r13
leaq 0x17a158(%rip), %rdi    # 0x583240
pushq $0xc
popq %rbx
pushq $0x1
popq %r15
movq %rbx, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x4e76b0
leaq 0x17a149(%rip), %rsi    # 0x58324d
movq %r13, %rdi
movl $0x7d0, %edx            # imm = 0x7D0
xorl %eax, %eax
callq 0x4d8660
leaq 0x17a145(%rip), %rdi    # 0x58325f
pushq $0xe
popq %r14
movq %r14, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x4e76b0
leaq 0x17a13b(%rip), %rdi    # 0x58326e
movq %rbx, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x4e76b0
leaq 0x17a133(%rip), %rsi    # 0x58327b
movq %r13, %rdi
movl $0x7d0, %edx            # imm = 0x7D0
xorl %eax, %eax
callq 0x4d8660
leaq 0x17a12f(%rip), %rdi    # 0x58328d
movq %r14, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x4e76b0
leaq 0x17a129(%rip), %rdi    # 0x58329c
movq %rbx, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x4e76b0
xorl %r15d, %r15d
cmpq %r15, 0x18(%rsp)
je 0x40923d
movq 0xc50(%rsp), %rax
movslq (%rax,%r15,4), %r14
movq 0xc58(%rsp), %rax
movslq (%rax,%r15,4), %rbp
movq 0x1f9442(%rip), %rax    # 0x6025f0
movq (%rax,%r14,8), %rdi
movq 0x1f940f(%rip), %rax    # 0x6025c8
movq (%rax,%rbp,8), %rsi
callq 0x4054a5
sqrtsd %xmm0, %xmm0
ucomisd 0x58(%rsp), %xmm0
ja 0x409235
incl %r14d
movq %r13, %rdi
leaq 0x17a0ce(%rip), %rsi    # 0x5832a9
movl %r14d, %edx
xorl %eax, %eax
callq 0x4d8660
leaq 0x17a0cf(%rip), %r12    # 0x5832bb
movq %r12, %rdi
movq %r13, %rbx
pushq $0xa
popq %r13
movq %r13, %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
movq %rbx, %rcx
callq 0x4e76b0
addl $0x7d1, %ebp            # imm = 0x7D1
movq %rbx, %rdi
leaq 0x17a091(%rip), %rsi    # 0x5832a9
movl %ebp, %edx
xorl %eax, %eax
callq 0x4d8660
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %r13
movq %r14, %rdx
movq %rbx, %rcx
callq 0x4e76b0
incq %r15
jmp 0x409184
leaq 0x17a082(%rip), %rdi    # 0x5832c6
pushq $0xb
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
movq %r13, %rcx
callq 0x4e76b0
leaq 0x17a076(%rip), %rdi    # 0x5832d2
pushq $0x5
popq %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x4e76b0
leaq 0x17a067(%rip), %rsi    # 0x5832d8
leaq 0x1f92d8(%rip), %rdx    # 0x602550
xorl %r12d, %r12d
movq %r13, %rdi
xorl %eax, %eax
callq 0x4d8660
leaq 0x17a068(%rip), %rsi    # 0x5832f4
movq %r13, %rdi
movq 0x20(%rsp), %rdx
movl 0x14(%rsp), %ecx
xorl %eax, %eax
callq 0x4d8660
leaq 0x17a06f(%rip), %rsi    # 0x583315
movq %r13, %rdi
movq 0x28(%rsp), %rdx
movl 0x10(%rsp), %ebx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x4d8660
leaq 0x17a074(%rip), %rsi    # 0x583336
movq %r13, %rdi
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movb $0x2, %al
callq 0x4d8660
leaq 0x17a087(%rip), %rsi    # 0x583366
movq %r13, %rdi
movl 0xc60(%rsp), %edx
movsd 0x40(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movsd 0x50(%rsp), %xmm2
movb $0x3, %al
callq 0x4d8660
testl %ebx, %ebx
movl $0x0, %ebp
cmovgl %ebx, %ebp
leaq 0xd(%rsp), %rbx
leaq 0x17a08b(%rip), %r14    # 0x5833a3
cmpq %r12, %rbp
je 0x409372
movq 0x1f92d4(%rip), %rax    # 0x6025f8
movsbl (%rax,%r12), %edi
movq %rbx, %rsi
callq 0x404974
leaq 0x1(%r12), %r15
movq 0x1f9293(%rip), %rax    # 0x6025d0
movl (%rax,%r12,4), %r8d
movq 0x1f92a8(%rip), %rax    # 0x6025f0
movq (%rax,%r12,8), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
movq %r13, %rdi
movq %r14, %rsi
movl %r15d, %edx
movq %rbx, %rcx
movb $0x3, %al
callq 0x4d8660
movq %r15, %r12
jmp 0x409318
leaq 0x17a055(%rip), %rdi    # 0x5833ce
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x4e76b0
pushq $0x2
popq %rbx
leaq 0x17a042(%rip), %r14    # 0x5833d3
movl 0x14(%rsp), %ebp
movl 0x10(%rsp), %r15d
leal -0x1(%rbx), %edx
cmpl %r15d, %edx
jge 0x4093b5
movq %r13, %rdi
movq %r14, %rsi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x4d8660
incl %ebx
jmp 0x40939a
xorl %r15d, %r15d
testl %ebp, %ebp
movl $0x0, %r12d
cmovgl %ebp, %r12d
leaq 0xd(%rsp), %rbx
leaq 0x179fd3(%rip), %r14    # 0x5833a3
cmpq %r15, %r12
je 0x409429
movq 0x1f9224(%rip), %rax    # 0x602600
movsbl (%rax,%r15), %edi
movq %rbx, %rsi
callq 0x404974
movq 0x1f91e8(%rip), %rax    # 0x6025d8
movl (%rax,%r15,4), %r8d
movq 0x1f91cd(%rip), %rax    # 0x6025c8
movq (%rax,%r15,8), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
leal 0x7d1(%r15), %edx
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rcx
movb $0x3, %al
callq 0x4d8660
incq %r15
jmp 0x4093d0
leaq 0x179f9e(%rip), %rdi    # 0x5833ce
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x4e76b0
pushq $0x1
popq %r14
leaq 0x179f8a(%rip), %rbx    # 0x5833d3
cmpl %ebp, %r14d
jge 0x40946e
leal 0x7d0(%r14), %edx
leal 0x7d1(%r14), %ecx
movq %r13, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4d8660
incl %r14d
jmp 0x409449
movq %r13, %rdi
callq 0x4e6c50
addq $0xc18, %rsp            # imm = 0xC18
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq