// File: /workspace/github_c_makefile_star2_O2/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, 0x10(%rsp)
movq %r9, 0x28(%rsp)
movq %r8, 0x8(%rsp)
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %rdx
movl %edi, %r12d
movl $0x7a7978, 0x1c(%rsp)   # imm = 0x7A7978
leaq 0x1ad14(%rip), %rsi     # 0x56ca8
xorl %r14d, %r14d
leaq 0x30(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2260
leaq 0x151a0(%rip), %rsi     # 0x51150
movq %rbp, %rdi
callq 0x2210
movq %rax, %r13
leaq 0x17292(%rip), %rdi     # 0x53254
movq %rbp, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x172a2(%rip), %rsi     # 0x53275
movq %r13, %rdi
movq 0x8(%rsp), %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2190
leaq 0x1accc(%rip), %rdi     # 0x56cb8
pushq $0x1f
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x2280
testl %r12d, %r12d
cmovlel %r14d, %r12d
leaq 0x157dc(%rip), %rbp     # 0x517e4
cmpq %r14, %r12
je 0x3c03a
cmpl $0x0, (%r15,%r14,4)
je 0x3c035
movq 0x138(%rsp), %rax
cvtss2sd (%rax,%r14,4), %xmm0
divsd 0x10(%rsp), %xmm0
movq %r13, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x2190
incq %r14
jmp 0x3c008
pushq $0xa
popq %rdi
movq %r13, %rsi
callq 0x2140
leaq 0x17265(%rip), %rdi     # 0x532b1
pushq $0x1f
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x2280
xorl %r14d, %r14d
leaq 0x15780(%rip), %rbp     # 0x517e4
cmpq %r14, %r12
je 0x3c09c
cmpl $0x0, (%r15,%r14,4)
je 0x3c097
movq 0x138(%rsp), %rax
cvtss2sd (%rax,%r14,4), %xmm1
movsd 0xefc2(%rip), %xmm0     # 0x4b048
divsd %xmm1, %xmm0
movq %r13, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x2190
incq %r14
jmp 0x3c064
pushq $0xa
popq %rdi
movq %r13, %rsi
callq 0x2140
leaq 0x1ac2a(%rip), %rdi     # 0x56cd8
pushq $0x1f
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x2280
xorl %r14d, %r14d
leaq 0x1571e(%rip), %rbp     # 0x517e4
cmpq %r14, %r12
je 0x3c0f2
cmpl $0x0, (%r15,%r14,4)
je 0x3c0ed
movq 0x130(%rsp), %rax
cvtss2sd (%rax,%r14,4), %xmm0
movq %r13, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x2190
incq %r14
jmp 0x3c0c6
pushq $0xa
popq %rdi
movq %r13, %rsi
callq 0x2140
leaq 0x13414(%rip), %rsi     # 0x4f518
pushq $0x4
popq %rdx
movq %rbx, %rdi
callq 0x2070
xorl %ecx, %ecx
movq 0x8(%rsp), %rdx
testl %edx, %edx
cmovlel %ecx, %edx
movq %rdx, 0x8(%rsp)
movl %eax, 0x10(%rsp)
leaq 0x1abcd(%rip), %r14     # 0x56cf8
xorl %ebp, %ebp
cmpq 0x8(%rsp), %rbp
je 0x3c2ee
movq %r13, %rdi
leaq 0x1718f(%rip), %rsi     # 0x532d1
movl %ebp, %edx
xorl %eax, %eax
callq 0x2190
xorl %ebx, %ebx
cmpq %rbx, %r12
je 0x3c179
cmpl $0x0, (%r15,%rbx,4)
je 0x3c174
movq 0x28(%rsp), %rax
movq (%rax,%rbx,8), %rax
cvtss2sd (%rax,%rbp,4), %xmm0
movq %r13, %rdi
movq %r14, %rsi
movb $0x1, %al
callq 0x2190
incq %rbx
jmp 0x3c14d
cmpl $0x0, 0x10(%rsp)
je 0x3c1cc
imulq $0x158, %rbp, %rbx      # imm = 0x158
movq 0x140(%rsp), %rax
movzbl (%rax,%rbx), %eax
cmpl $0x61, %eax
je 0x3c282
cmpl $0x74, %eax
je 0x3c251
cmpl $0x6c, %eax
je 0x3c263
cmpl $0x70, %eax
je 0x3c25a
cmpl $0x66, %eax
jne 0x3c26c
leaq 0x1ab39(%rip), %rdi     # 0x56d00
jmp 0x3c289
movl %ebp, %eax
xorl %edx, %edx
pushq $0x3
popq %rcx
divl %ecx
imull $-0x3, %eax, %ebx
addl %ebp, %ebx
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, 0x20(%rsp)
movslq 0x4c(%rax), %rax
shlq $0x5, %rax
movq 0x160(%rsp), %rcx
leaq (%rcx,%rax), %rdi
addq $0xd, %rdi
leaq 0x1b00e(%rip), %rsi     # 0x5722b
leaq 0x4(%rsp), %rdx
xorl %eax, %eax
callq 0x21f0
movl 0x4(%rsp), %ecx
movslq %ebx, %rax
movsbl 0x1c(%rsp,%rax), %r8d
movq %r13, %rdi
leaq 0x1aad9(%rip), %rsi     # 0x56d19
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x2190
jmp 0x3c2e6
leaq 0x1aabc(%rip), %rdi     # 0x56d14
jmp 0x3c289
leaq 0x1aaa4(%rip), %rdi     # 0x56d05
jmp 0x3c289
leaq 0x1aaa0(%rip), %rdi     # 0x56d0a
jmp 0x3c289
movsbl %al, %edx
movq %r13, %rdi
leaq 0x1b522(%rip), %rsi     # 0x5779b
xorl %eax, %eax
callq 0x2190
jmp 0x3c297
leaq 0x1aa86(%rip), %rdi     # 0x56d0f
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x2280
addq 0x140(%rsp), %rbx
movq 0x8(%rbx), %rax
movq (%rax), %rax
movslq 0x64(%rax), %rax
shlq $0x5, %rax
movq 0x160(%rsp), %rcx
leaq (%rcx,%rax), %rdi
addq $0xd, %rdi
leaq 0x1af66(%rip), %rsi     # 0x5722b
leaq 0x4(%rsp), %rdx
xorl %eax, %eax
callq 0x21f0
movl 0x4(%rsp), %edx
movq %r13, %rdi
leaq 0x18e84(%rip), %rsi     # 0x55163
xorl %eax, %eax
callq 0x2190
incq %rbp
jmp 0x3c12d
movq %r13, %rdi
callq 0x20c0
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq