// File: /workspace/github_c_makefile_star2_O2/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 $0x138, %rsp            # imm = 0x138
movq %r8, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
movl %edx, %r12d
movq %rsi, 0x40(%rsp)
movss %xmm1, 0x18(%rsp)
movss %xmm0, 0x14(%rsp)
movq %rdi, 0x38(%rsp)
movl 0x170(%rsp), %ebx
xorl %eax, %eax
cmpq $0xa, %rax
je 0x2655e
movb $0x0, 0x66(%rsp,%rax)
incq %rax
jmp 0x2654e
leal 0x1(%rbx), %ecx
leaq 0x2cb79(%rip), %rsi     # 0x530e1
xorl %r15d, %r15d
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %r9, %rdx
xorl %eax, %eax
callq 0x2260
leaq 0x2abcc(%rip), %rsi     # 0x51150
movq %r14, %rdi
callq 0x2210
movq %rax, %r13
leaq 0x2cb55(%rip), %rdi     # 0x530eb
movq %r14, %rsi
xorl %eax, %eax
callq 0x20f0
cvtss2sd 0x18(%rsp), %xmm0
mulsd 0x2a882(%rip), %xmm0    # 0x50e30
leaq 0x2cb60(%rip), %rsi     # 0x53115
movq %r13, 0x18(%rsp)
movq %r13, %rdi
movl %ebx, %edx
movb $0x1, %al
callq 0x2190
cvtss2sd 0x14(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x265dc
sqrtsd %xmm0, %xmm0
jmp 0x265e1
callq 0x2290
movsd 0x24a5f(%rip), %xmm1    # 0x4b048
divsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x24(%rsp)
cvtss2sd %xmm0, %xmm0
leaq 0x2cb46(%rip), %rsi     # 0x53148
movq 0x18(%rsp), %rdi
movb $0x1, %al
callq 0x2190
movss 0x24(%rsp), %xmm0
mulss 0x2c5e4(%rip), %xmm0    # 0x52c00
divss 0x2abe4(%rip), %xmm0    # 0x51208
movss %xmm0, 0x24(%rsp)
testl %r12d, %r12d
cmovlel %r15d, %r12d
movq %r12, 0x58(%rsp)
xorps %xmm0, %xmm0
leaq 0x66(%rsp), %r13
xorl %edx, %edx
testl %edx, %edx
movss %xmm0, 0x14(%rsp)
movl %edx, 0x28(%rsp)
je 0x2666c
cmpl $0xa, %edx
je 0x2678a
movq 0x18(%rsp), %rdi
leaq 0x2cb10(%rip), %rsi     # 0x53173
xorl %eax, %eax
callq 0x2190
jmp 0x26683
leaq 0x2caeb(%rip), %rdi     # 0x5315e
pushq $0x14
popq %rsi
pushq $0x1
popq %rdx
movq 0x18(%rsp), %rcx
callq 0x2280
xorl %r12d, %r12d
movq 0x38(%rsp), %r15
xorl %ebx, %ebx
cmpq 0x58(%rsp), %r12
je 0x2675c
movq 0x48(%rsp), %rax
movslq (%rax,%r12,4), %rax
imulq $0x70, %rax, %r14
addq 0x40(%rsp), %r14
xorl %eax, %eax
movss 0x14(%rsp), %xmm1
cmpq $0x3, %rax
je 0x266db
movss (%r15,%rax,4), %xmm0
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
addsd (%r14,%rax,8), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x2c(%rsp,%rax,4)
incq %rax
jmp 0x266b2
movslq 0x64(%r14), %rax
shlq $0x5, %rax
movq 0x50(%rsp), %rcx
leaq (%rcx,%rax), %rbp
addq $0xd, %rbp
movswl 0x7(%rbp), %esi
movq %r13, %rdi
callq 0x24647
cmpl $0x1869f, %ebx          # imm = 0x1869F
adcl $0x0, %ebx
cvtss2sd 0x2c(%rsp), %xmm0
cvtss2sd 0x30(%rsp), %xmm1
cvtss2sd 0x34(%rsp), %xmm2
movsbl 0x4dcc9(%rip), %r9d     # 0x743e8
cvtss2sd 0x1c(%r14), %xmm4
addq $0x18, %r14
movq %rbp, (%rsp)
movq 0x18(%rsp), %rdi
leaq 0x2ca44(%rip), %rsi     # 0x5317d
movl %ebx, %edx
movq %r14, %rcx
movq %r13, %r8
movsd 0x248ff(%rip), %xmm3    # 0x4b048
movb $0x5, %al
callq 0x2190
incq %r12
addq $0xc, %r15
jmp 0x2668d
leaq 0x2ca4f(%rip), %rdi     # 0x531b2
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
movq 0x18(%rsp), %rcx
callq 0x2280
movss 0x14(%rsp), %xmm0
addss 0x24(%rsp), %xmm0
movl 0x28(%rsp), %edx
incl %edx
jmp 0x26640
movq 0x18(%rsp), %rdi
callq 0x20c0
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq