// File: /workspace/github_c_makefile_star2_O3/ugobas[P]tnm/nma.c
// Function: Print_PDB_3
void Print_PDB_3(float *Cart_mode, float eigen_value, float eigen_B,
		 atom *atoms, int N_atom_ref, int *atom_ref,
		 struct residue *seq, char *file_name, int ia)
{
  // Print PDB file
  FILE *file_out;  char outfile[200];
  int i, j, k; atom *atom1=atoms;
  char aaname3[10];
  // Amplitude factors
  float DTHETA=0;
  float AMPL_FACTOR=16; // Amplification with respect to thermal fluctuations
  //~ float AMAX=120;      // New amplitude factor
  float step, dtheta, r[3];
  int N_STEP=10; // Number of conformations per normal mode
  int i_step;

  for(i=0; i<10; i++)aaname3[i]='\0';

  // Opening file
  sprintf(outfile, "%s_%d.pdb", file_name, ia+1);
  file_out=fopen(outfile, "w");
  printf("Writing normal modes in PDB format in %s\n", outfile);
  fprintf(file_out, "REMARK  Normal mode %3d  Percent fluctuation= %.2f",
	  ia, eigen_B*100.0);

  // Compute amplitude
  DTHETA=1./sqrt(eigen_value);
  fprintf(file_out, " sqrt<theta^2>= %.4f\n", DTHETA);
  DTHETA*=AMPL_FACTOR;
  step=DTHETA/N_STEP; dtheta=0;

  for(i_step=0; i_step<N_STEP; i_step++){
    if(i_step==0){
      fprintf(file_out, "MODEL: ground state\n");
    }else{
      fprintf(file_out, "MODEL %d\n", i_step);
    }

    // Compute and print
    int jatom=0;
    for(i=0; i<N_atom_ref; i++){
      int m=3*i;
      atom1=atoms+atom_ref[i];
      for(j=0; j<3; j++)r[j]=atom1->r[j]+Cart_mode[m+j]*dtheta;
      k=atom1->res; Name3(aaname3, seq[k].i_aa);
      if(jatom <99999)jatom++;
      fprintf(file_out,
	      "ATOM  %5d%4s  %3s %c%4s   %8.3f%8.3f%8.3f%6.2f%6.2f\n",
	      jatom, atom1->name, aaname3, chain,
	      seq[k].pdbres,  r[0], r[1], r[2], 1.0, atom1->B_factor);
      atom1=atoms+atom1->i_next;
    }
    fprintf(file_out, "ENDMDL\n");
    dtheta+=step;
  }
  fclose(file_out);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %r8, 0x48(%rsp)
movq %rcx, 0x40(%rsp)
movl %edx, 0x14(%rsp)
movq %rsi, 0x38(%rsp)
movss %xmm1, 0x10(%rsp)
movss %xmm0, 0x8(%rsp)
movq %rdi, 0x30(%rsp)
movl 0x150(%rsp), %r12d
movq $0x0, 0x18(%rsp)
movw $0x0, 0x20(%rsp)
leal 0x1(%r12), %ecx
leaq 0x30147(%rip), %rsi     # 0x59181
leaq 0x50(%rsp), %rbp
movq %rbp, %rdi
movq %r9, %rdx
xorl %eax, %eax
callq 0x2270
leaq 0x2e1ad(%rip), %rsi     # 0x57200
movq %rbp, %rdi
callq 0x2220
movq %rax, %r13
leaq 0x30126(%rip), %rdi     # 0x5918b
movq %rbp, %rsi
xorl %eax, %eax
callq 0x20f0
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rsp), %xmm0
mulsd 0x2de60(%rip), %xmm0    # 0x56ee0
leaq 0x3012e(%rip), %rsi     # 0x591b5
movq %r13, %rdi
movl %r12d, %edx
movb $0x1, %al
callq 0x21a0
xorps %xmm0, %xmm0
cvtss2sd 0x8(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x290ad
sqrtsd %xmm0, %xmm0
jmp 0x290b2
callq 0x22a0
movsd 0x2808e(%rip), %xmm1    # 0x51148
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0xc(%rsp)
cvtss2sd %xmm0, %xmm0
leaq 0x30112(%rip), %rsi     # 0x591e8
movq %r13, %rdi
movb $0x1, %al
callq 0x21a0
movss 0xc(%rsp), %xmm0
mulss 0x2fbb2(%rip), %xmm0    # 0x58ca0
divss 0x2e1c2(%rip), %xmm0    # 0x572b8
movss %xmm0, 0xc(%rsp)
movl 0x14(%rsp), %ebp
xorps %xmm0, %xmm0
leaq 0x2fcd9(%rip), %rbx     # 0x58de3
xorl %edx, %edx
movss %xmm0, 0x8(%rsp)
testl %edx, %edx
movl %edx, 0x10(%rsp)
je 0x2912d
movq %r13, %rdi
leaq 0x300ef(%rip), %rsi     # 0x59213
xorl %eax, %eax
callq 0x21a0
jmp 0x29146
movl $0x14, %esi
movl $0x1, %edx
leaq 0x300c0(%rip), %rdi     # 0x591fe
movq %r13, %rcx
callq 0x2290
cmpl $0x0, 0x14(%rsp)
jle 0x2923c
xorl %r14d, %r14d
movq 0x30(%rsp), %r15
xorl %r12d, %r12d
movq 0x40(%rsp), %rax
movslq (%rax,%r14,4), %rax
imulq $0x70, %rax, %rcx
addq 0x38(%rsp), %rcx
xorl %eax, %eax
movss 0x8(%rsp), %xmm1
movss (%r15,%rax,4), %xmm0
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
addsd (%rcx,%rax,8), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x24(%rsp,%rax,4)
incq %rax
cmpq $0x3, %rax
jne 0x29176
movslq 0x64(%rcx), %rax
shlq $0x5, %rax
movq 0x48(%rsp), %rdx
addq %rdx, %rax
addq $0xd, %rax
movswq 0x7(%rax), %rdx
movb 0x2(%rbx,%rdx,4), %sil
movb %sil, 0x1a(%rsp)
movzwl (%rbx,%rdx,4), %edx
movw %dx, 0x18(%rsp)
movb $0x0, 0x1b(%rsp)
cmpl $0x1869f, %r12d         # imm = 0x1869F
adcl $0x0, %r12d
xorps %xmm0, %xmm0
cvtss2sd 0x24(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x28(%rsp), %xmm1
xorps %xmm2, %xmm2
cvtss2sd 0x2c(%rsp), %xmm2
movsbl 0x501ed(%rip), %r9d     # 0x793e8
xorps %xmm4, %xmm4
cvtss2sd 0x1c(%rcx), %xmm4
addq $0x18, %rcx
movq %rax, (%rsp)
movq %r13, %rdi
leaq 0x30008(%rip), %rsi     # 0x5921d
movl %r12d, %edx
leaq 0x18(%rsp), %r8
movsd 0x27f23(%rip), %xmm3    # 0x51148
movb $0x5, %al
callq 0x21a0
incq %r14
addq $0xc, %r15
cmpq %rbp, %r14
jne 0x2915c
movl $0x7, %esi
movl $0x1, %edx
leaq 0x30005(%rip), %rdi     # 0x59252
movq %r13, %rcx
callq 0x2290
movss 0x8(%rsp), %xmm0
addss 0xc(%rsp), %xmm0
movl 0x10(%rsp), %edx
incl %edx
cmpl $0xa, %edx
jne 0x2910c
movq %r13, %rdi
callq 0x20c0
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq