// File: /workspace/github_c_makefile_star2_O1/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 0x2fe49(%rip), %rsi     # 0x591d4
leaq 0x50(%rsp), %rbp
movq %rbp, %rdi
movq %r9, %rdx
xorl %eax, %eax
callq 0x2260
leaq 0x2de9c(%rip), %rsi     # 0x57240
movq %rbp, %rdi
callq 0x2210
movq %rax, %r13
leaq 0x2fe28(%rip), %rdi     # 0x591de
movq %rbp, %rsi
xorl %eax, %eax
callq 0x20f0
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rsp), %xmm0
mulsd 0x2db4f(%rip), %xmm0    # 0x56f20
leaq 0x2fe30(%rip), %rsi     # 0x59208
movq %r13, %rdi
movl %r12d, %edx
movb $0x1, %al
callq 0x2190
xorps %xmm0, %xmm0
cvtss2sd 0x8(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x293fe
sqrtsd %xmm0, %xmm0
jmp 0x29403
callq 0x2290
movsd 0x27c35(%rip), %xmm1    # 0x51040
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0xc(%rsp)
cvtss2sd %xmm0, %xmm0
leaq 0x2fe14(%rip), %rsi     # 0x5923b
movq %r13, %rdi
movb $0x1, %al
callq 0x2190
movss 0xc(%rsp), %xmm0
mulss 0x2f8a5(%rip), %xmm0    # 0x58ce4
divss 0x2deb1(%rip), %xmm0    # 0x572f8
movss %xmm0, 0xc(%rsp)
movl 0x14(%rsp), %ebp
xorps %xmm0, %xmm0
leaq 0x2f9d4(%rip), %rbx     # 0x58e2f
xorl %edx, %edx
movss %xmm0, 0x8(%rsp)
testl %edx, %edx
movl %edx, 0x10(%rsp)
je 0x2947e
movq %r13, %rdi
leaq 0x2fdf1(%rip), %rsi     # 0x59266
xorl %eax, %eax
callq 0x2190
jmp 0x29497
movl $0x14, %esi
movl $0x1, %edx
leaq 0x2fdc2(%rip), %rdi     # 0x59251
movq %r13, %rcx
callq 0x2280
cmpl $0x0, 0x14(%rsp)
jle 0x2958d
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 0x294c7
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 0x4fe9c(%rip), %r9d     # 0x793e8
xorps %xmm4, %xmm4
cvtss2sd 0x1c(%rcx), %xmm4
addq $0x18, %rcx
movq %rax, (%rsp)
movq %r13, %rdi
leaq 0x2fd0a(%rip), %rsi     # 0x59270
movl %r12d, %edx
leaq 0x18(%rsp), %r8
movsd 0x27aca(%rip), %xmm3    # 0x51040
movb $0x5, %al
callq 0x2190
incq %r14
addq $0xc, %r15
cmpq %rbp, %r14
jne 0x294ad
movl $0x7, %esi
movl $0x1, %edx
leaq 0x2fd07(%rip), %rdi     # 0x592a5
movq %r13, %rcx
callq 0x2280
movss 0x8(%rsp), %xmm0
addss 0xc(%rsp), %xmm0
movl 0x10(%rsp), %edx
incl %edx
cmpl $0xa, %edx
jne 0x2945d
movq %r13, %rdi
callq 0x20c0
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq