// File: /workspace/github_c_makefile_star2_O3/ugobas[P]tnm/output_tnm.c
// Function: Print_modes
void Print_modes(int N_print, char *nameout,
		 char *label, int *select,
		 int N, float **Mode, float *collectivity,
		 float *sigma2, double sum_sigma2,
		 struct axe *axe, int naxe,
		 atom *atoms, int natoms,
		 struct residue *seq, int nres,
		 int *atom_num, int N_ref)
{
  int PRINT_ALL=0;
  FILE *file_out; int ia, i=0, cart=0, k=0, j=0, ik=0, ires;
  char outfile[200], xyz[4];

  strcpy(xyz, "xyz");
  sprintf(outfile, "%s.Modes_%s.dat", nameout, label);
  file_out=fopen(outfile, "w");
  printf("Writing normal modes to file %s\n", outfile);

  fprintf(file_out, "# %d degrees of freedom: %s\n", N, label);
  fprintf(file_out, "# Contribution to fluctuation: ");
  for(ia=0; ia<N_print; ia++)
    if((select[ia])||PRINT_ALL)
      fprintf(file_out, "\t%.3g", sigma2[ia]/sum_sigma2);
  fprintf(file_out, "\n");
  fprintf(file_out, "# e_values:                    ");
  for(ia=0; ia<N_print; ia++)
    if((select[ia])||PRINT_ALL)
      fprintf(file_out, "\t%.3g", 1./sigma2[ia]);
  fprintf(file_out, "\n");
  fprintf(file_out, "# collectivity:                ");
  for(ia=0; ia<N_print; ia++)
    if((select[ia])||PRINT_ALL)
      fprintf(file_out, "\t%.3g", collectivity[ia]);
  fprintf(file_out, "\n");

  if(strncmp(label, "Cart", 4)==0)cart=1;
  for(i=0; i<N; i++){
    fprintf(file_out, "%4d", i);
    for(ia=0; ia<N_print; ia++)
      if((select[ia])||PRINT_ALL)
	fprintf(file_out, "\t%11.5g", Mode[ia][i]);
    if(cart==0){
      if(axe[i].type=='f'){fprintf(file_out, "\tphi");}
      else if(axe[i].type=='p'){fprintf(file_out, "\tpsi");}
      else if(axe[i].type=='l'){fprintf(file_out, "\tlen");}
      else if(axe[i].type=='a'){fprintf(file_out, "\tban");}
      else if(axe[i].type=='t'){fprintf(file_out, "\ttan");}
      else{ fprintf(file_out, "\t%c", axe[i].type);}
      sscanf(seq[axe[i].bond->atom->res].pdbres, "%d", &ires);
      fprintf(file_out, "%d\n", ires);
    }else{
      k=i/3; j=i-3*k; ik=atom_num[k];
      sscanf(seq[atoms[ik].res].pdbres, "%d", &ires);
      fprintf(file_out, "\t%s%d%c\n", atoms[ik].name, ires, xyz[j]);
    }
  }

  fclose(file_out);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movsd %xmm0, 0x18(%rsp)
movq %r9, 0x28(%rsp)
movl %r8d, %ebx
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, %rdx
movl %edi, %r12d
movl $0x7a7978, 0x24(%rsp)   # imm = 0x7A7978
leaq 0x1ba32(%rip), %rsi     # 0x5cd38
leaq 0x30(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x2270
leaq 0x15ee1(%rip), %rsi     # 0x57200
movq %rbp, %rdi
callq 0x2220
movq %rax, %r15
leaq 0x17fc3(%rip), %rdi     # 0x592f4
movq %rbp, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x17fd3(%rip), %rsi     # 0x59315
movq %r15, %rdi
movl %ebx, 0x10(%rsp)
movl %ebx, %edx
movq %r13, 0x8(%rsp)
movq %r13, %rcx
xorl %eax, %eax
callq 0x21a0
leaq 0x1b9e7(%rip), %rdi     # 0x5cd48
movl $0x1f, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2290
movl %r12d, %ebx
movl %r12d, (%rsp)
testl %r12d, %r12d
jle 0x4142d
movq 0x138(%rsp), %r12
xorl %r13d, %r13d
leaq 0x164ef(%rip), %rbp     # 0x57884
cmpl $0x0, (%r14,%r13,4)
je 0x413b8
xorps %xmm0, %xmm0
cvtss2sd (%r12,%r13,4), %xmm0
divsd 0x18(%rsp), %xmm0
movq %r15, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x21a0
incq %r13
cmpq %r13, %rbx
jne 0x41395
movl $0xa, %edi
movq %r15, %rsi
callq 0x2140
leaq 0x17f7d(%rip), %rdi     # 0x59351
movl $0x1f, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2290
cmpl $0x0, (%rsp)
jle 0x414b8
xorl %r13d, %r13d
leaq 0x1648a(%rip), %rbp     # 0x57884
cmpl $0x0, (%r14,%r13,4)
je 0x41423
xorps %xmm1, %xmm1
cvtss2sd (%r12,%r13,4), %xmm1
movsd 0xfd36(%rip), %xmm0     # 0x51148
divsd %xmm1, %xmm0
movq %r15, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x21a0
incq %r13
cmpq %r13, %rbx
jne 0x413fa
jmp 0x41453
movl $0xa, %edi
movq %r15, %rsi
callq 0x2140
leaq 0x17f10(%rip), %rdi     # 0x59351
movl $0x1f, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2290
movl $0xa, %edi
movq %r15, %rsi
callq 0x2140
leaq 0x1b901(%rip), %rdi     # 0x5cd68
movl $0x1f, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2290
cmpl $0x0, (%rsp)
jle 0x414de
movq 0x130(%rsp), %r12
xorl %r13d, %r13d
leaq 0x163f3(%rip), %rbp     # 0x57884
cmpl $0x0, (%r14,%r13,4)
je 0x414ae
xorps %xmm0, %xmm0
cvtss2sd (%r12,%r13,4), %xmm0
movq %r15, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x21a0
incq %r13
cmpq %r13, %rbx
jne 0x41491
jmp 0x414de
movl $0xa, %edi
movq %r15, %rsi
callq 0x2140
leaq 0x1b89c(%rip), %rdi     # 0x5cd68
movl $0x1f, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2290
movl $0xa, %edi
movq %r15, %rsi
callq 0x2140
leaq 0x140ce(%rip), %rsi     # 0x555c0
movl $0x4, %edx
movq 0x8(%rsp), %rdi
callq 0x2070
movl %eax, 0x18(%rsp)
movl 0x10(%rsp), %eax
testl %eax, %eax
jle 0x41723
movl %eax, %eax
movq %rax, 0x10(%rsp)
leaq 0x1b869(%rip), %r12     # 0x5cd88
xorl %ebp, %ebp
movq %r15, %rdi
leaq 0x17e46(%rip), %rsi     # 0x59371
movl %ebp, %edx
xorl %eax, %eax
callq 0x21a0
cmpl $0x0, (%rsp)
jle 0x4156a
xorl %r13d, %r13d
cmpl $0x0, (%r14,%r13,4)
je 0x41562
movq 0x28(%rsp), %rax
movq (%rax,%r13,8), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax,%rbp,4), %xmm0
movq %r15, %rdi
movq %r12, %rsi
movb $0x1, %al
callq 0x21a0
incq %r13
cmpq %r13, %rbx
jne 0x4153d
cmpl $0x0, 0x18(%rsp)
je 0x415bf
imulq $0x158, %rbp, %r13      # imm = 0x158
movq 0x140(%rsp), %rax
movzbl (%rax,%r13), %eax
cmpl $0x6b, %eax
jle 0x4164e
cmpl $0x6c, %eax
je 0x4166f
cmpl $0x70, %eax
je 0x41682
cmpl $0x74, %eax
jne 0x4170d
movl $0x4, %esi
movl $0x1, %edx
leaq 0x1b7ea(%rip), %rdi     # 0x5cda4
jmp 0x416a6
movl %ebp, %eax
movl $0xaaaaaaab, %ecx       # imm = 0xAAAAAAAB
imulq %rcx, %rax
shrq $0x21, %rax
leal (%rax,%rax,2), %ecx
movl %ebp, %r13d
subl %ecx, %r13d
movq 0x170(%rsp), %rcx
movslq (%rcx,%rax,4), %rax
imulq $0x70, %rax, %rax
movq 0x150(%rsp), %rcx
addq %rcx, %rax
addq $0x18, %rax
movq %rax, 0x8(%rsp)
movslq 0x4c(%rax), %rax
shlq $0x5, %rax
movq 0x160(%rsp), %rcx
leaq (%rcx,%rax), %rdi
addq $0xd, %rdi
leaq 0x1bca1(%rip), %rsi     # 0x5d2bb
leaq 0x4(%rsp), %rdx
xorl %eax, %eax
callq 0x2200
movl 0x4(%rsp), %ecx
movslq %r13d, %rax
movsbl 0x24(%rsp,%rax), %r8d
movq %r15, %rdi
leaq 0x1b76c(%rip), %rsi     # 0x5cda9
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x21a0
jmp 0x416fd
cmpl $0x61, %eax
je 0x41695
cmpl $0x66, %eax
jne 0x4170d
movl $0x4, %esi
movl $0x1, %edx
leaq 0x1b723(%rip), %rdi     # 0x5cd90
jmp 0x416a6
movl $0x4, %esi
movl $0x1, %edx
leaq 0x1b71a(%rip), %rdi     # 0x5cd9a
jmp 0x416a6
movl $0x4, %esi
movl $0x1, %edx
leaq 0x1b702(%rip), %rdi     # 0x5cd95
jmp 0x416a6
movl $0x4, %esi
movl $0x1, %edx
leaq 0x1b6f9(%rip), %rdi     # 0x5cd9f
movq %r15, %rcx
callq 0x2290
addq 0x140(%rsp), %r13
movq 0x8(%r13), %rax
movq (%rax), %rax
movslq 0x64(%rax), %rax
shlq $0x5, %rax
movq 0x160(%rsp), %rcx
leaq (%rcx,%rax), %rdi
addq $0xd, %rdi
leaq 0x1bbdf(%rip), %rsi     # 0x5d2bb
leaq 0x4(%rsp), %rdx
xorl %eax, %eax
callq 0x2200
movl 0x4(%rsp), %edx
movq %r15, %rdi
leaq 0x19b0d(%rip), %rsi     # 0x5b203
xorl %eax, %eax
callq 0x21a0
incq %rbp
cmpq 0x10(%rsp), %rbp
jne 0x41521
jmp 0x41723
movsbl %al, %edx
movq %r15, %rdi
leaq 0x1c111(%rip), %rsi     # 0x5d82b
xorl %eax, %eax
callq 0x21a0
jmp 0x416ae
movq %r15, %rdi
callq 0x20c0
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq