// File: /workspace/github_c_makefile_star2_O1/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, 0x20(%rsp)
movq %r9, %rbx
movl %r8d, %r13d
movq %rcx, %r14
movq %rdx, %rbp
movq %rsi, %rdx
movl %edi, %r12d
movl $0x7a7978, 0x2c(%rsp)   # imm = 0x7A7978
leaq 0x1ba30(%rip), %rsi     # 0x5cd78
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rcx
xorl %eax, %eax
callq 0x2260
leaq 0x15edf(%rip), %rsi     # 0x57240
movq %r15, %rdi
callq 0x2210
movq %rax, %r15
leaq 0x17fd4(%rip), %rdi     # 0x59347
leaq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x17fe2(%rip), %rsi     # 0x59368
movq %r15, %rdi
movl %r13d, 0x18(%rsp)
movl %r13d, %edx
movq %rbp, 0x10(%rsp)
movq %rbp, %rcx
xorl %eax, %eax
callq 0x2190
leaq 0x1b9e1(%rip), %rdi     # 0x5cd88
movl $0x1f, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2280
movl %r12d, %r13d
movl %r12d, 0x8(%rsp)
testl %r12d, %r12d
jle 0x41403
xorl %r12d, %r12d
leaq 0x164f4(%rip), %rbp     # 0x578c4
cmpl $0x0, (%r14,%r12,4)
je 0x413fb
movq 0x138(%rsp), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax,%r12,4), %xmm0
divsd 0x20(%rsp), %xmm0
movq %r15, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x2190
incq %r12
cmpq %r12, %r13
jne 0x413d0
movl $0xa, %edi
movq %r15, %rsi
callq 0x2140
leaq 0x17f8d(%rip), %rdi     # 0x593a4
movl $0x1f, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2280
cmpl $0x0, 0x8(%rsp)
jle 0x41473
xorl %r12d, %r12d
leaq 0x1648a(%rip), %rbp     # 0x578c4
cmpl $0x0, (%r14,%r12,4)
je 0x4146b
movq 0x138(%rsp), %rax
xorps %xmm1, %xmm1
cvtss2sd (%rax,%r12,4), %xmm1
movsd 0xfbe6(%rip), %xmm0     # 0x51040
divsd %xmm1, %xmm0
movq %r15, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x2190
incq %r12
cmpq %r12, %r13
jne 0x4143a
movl $0xa, %edi
movq %r15, %rsi
callq 0x2140
leaq 0x1b921(%rip), %rdi     # 0x5cda8
movl $0x1f, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2280
cmpl $0x0, 0x8(%rsp)
jle 0x414d7
xorl %r12d, %r12d
leaq 0x1641a(%rip), %rbp     # 0x578c4
cmpl $0x0, (%r14,%r12,4)
je 0x414cf
movq 0x130(%rsp), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax,%r12,4), %xmm0
movq %r15, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x2190
incq %r12
cmpq %r12, %r13
jne 0x414aa
movl $0xa, %edi
movq %r15, %rsi
callq 0x2140
leaq 0x140a9(%rip), %rsi     # 0x55594
movl $0x4, %edx
movq 0x10(%rsp), %rdi
callq 0x2070
movl %eax, 0x20(%rsp)
movl 0x18(%rsp), %eax
testl %eax, %eax
jle 0x41716
movl %eax, %eax
movq %rax, 0x18(%rsp)
xorl %ebp, %ebp
movq %r15, %rdi
leaq 0x17eab(%rip), %rsi     # 0x593c8
movl %ebp, %edx
xorl %eax, %eax
callq 0x2190
cmpl $0x0, 0x8(%rsp)
jle 0x4155c
xorl %r12d, %r12d
cmpl $0x0, (%r14,%r12,4)
je 0x41554
movq (%rbx,%r12,8), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax,%rbp,4), %xmm0
movq %r15, %rdi
leaq 0x1b87b(%rip), %rsi     # 0x5cdc8
movb $0x1, %al
callq 0x2190
incq %r12
cmpq %r12, %r13
jne 0x41530
cmpl $0x0, 0x20(%rsp)
je 0x415b1
imulq $0x158, %rbp, %r12      # imm = 0x158
movq 0x140(%rsp), %rax
movzbl (%rax,%r12), %eax
cmpl $0x6b, %eax
jle 0x41640
cmpl $0x6c, %eax
je 0x41661
cmpl $0x70, %eax
je 0x41674
cmpl $0x74, %eax
jne 0x41700
movl $0x4, %esi
movl $0x1, %edx
leaq 0x1b838(%rip), %rdi     # 0x5cde4
jmp 0x41698
movl %ebp, %eax
movl $0xaaaaaaab, %ecx       # imm = 0xAAAAAAAB
imulq %rcx, %rax
shrq $0x21, %rax
leal (%rax,%rax,2), %ecx
movl %ebp, %r12d
subl %ecx, %r12d
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, 0x10(%rsp)
movslq 0x4c(%rax), %rax
shlq $0x5, %rax
movq 0x160(%rsp), %rcx
leaq (%rcx,%rax), %rdi
addq $0xd, %rdi
leaq 0x1bcdf(%rip), %rsi     # 0x5d2eb
leaq 0xc(%rsp), %rdx
xorl %eax, %eax
callq 0x21f0
movl 0xc(%rsp), %ecx
movslq %r12d, %rax
movsbl 0x2c(%rsp,%rax), %r8d
movq %r15, %rdi
leaq 0x1b7ba(%rip), %rsi     # 0x5cde9
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x2190
jmp 0x416f0
cmpl $0x61, %eax
je 0x41687
cmpl $0x66, %eax
jne 0x41700
movl $0x4, %esi
movl $0x1, %edx
leaq 0x1b771(%rip), %rdi     # 0x5cdd0
jmp 0x41698
movl $0x4, %esi
movl $0x1, %edx
leaq 0x1b768(%rip), %rdi     # 0x5cdda
jmp 0x41698
movl $0x4, %esi
movl $0x1, %edx
leaq 0x1b750(%rip), %rdi     # 0x5cdd5
jmp 0x41698
movl $0x4, %esi
movl $0x1, %edx
leaq 0x1b747(%rip), %rdi     # 0x5cddf
movq %r15, %rcx
callq 0x2280
addq 0x140(%rsp), %r12
movq 0x8(%r12), %rax
movq (%rax), %rax
movslq 0x64(%rax), %rax
shlq $0x5, %rax
movq 0x160(%rsp), %rcx
leaq (%rcx,%rax), %rdi
addq $0xd, %rdi
leaq 0x1bc1c(%rip), %rsi     # 0x5d2eb
leaq 0xc(%rsp), %rdx
xorl %eax, %eax
callq 0x21f0
movl 0xc(%rsp), %edx
movq %r15, %rdi
leaq 0x19b62(%rip), %rsi     # 0x5b24b
xorl %eax, %eax
callq 0x2190
incq %rbp
cmpq 0x18(%rsp), %rbp
jne 0x41513
jmp 0x41716
movsbl %al, %edx
movq %r15, %rdi
leaq 0x1c14e(%rip), %rsi     # 0x5d85b
xorl %eax, %eax
callq 0x2190
jmp 0x416a0
movq %r15, %rdi
callq 0x20c0
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq