// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movss %xmm0, -0xc(%rbp)
movss %xmm1, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x128(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x138(%rbp)
movss 0x437c7(%rip), %xmm0    # 0x7dd44
movss %xmm0, -0x13c(%rbp)
movl $0xa, -0x154(%rbp)
movl $0x0, -0x114(%rbp)
cmpl $0xa, -0x114(%rbp)
jge 0x3a5c2
movslq -0x114(%rbp), %rax
movb $0x0, -0x132(%rbp,%rax)
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0x3a599
leaq -0x110(%rbp), %rdi
movq -0x38(%rbp), %rdx
movl 0x10(%rbp), %ecx
addl $0x1, %ecx
leaq 0x43db9(%rip), %rsi     # 0x7e393
movb $0x0, %al
callq 0x1200
leaq -0x110(%rbp), %rdi
leaq 0x41d83(%rip), %rsi     # 0x7c372
callq 0x11b0
movq %rax, -0x40(%rbp)
leaq -0x110(%rbp), %rsi
leaq 0x43d97(%rip), %rdi     # 0x7e39d
movb $0x0, %al
callq 0x10d0
movq -0x40(%rbp), %rdi
movl 0x10(%rbp), %edx
movss -0x10(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x419fb(%rip), %xmm1    # 0x7c020
mulsd %xmm1, %xmm0
leaq 0x43d97(%rip), %rsi     # 0x7e3c7
movb $0x1, %al
callq 0x1150
movss -0xc(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x1220
movaps %xmm0, %xmm1
movsd 0x3b9f8(%rip), %xmm0    # 0x76048
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x138(%rbp)
movq -0x40(%rbp), %rdi
movss -0x138(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x43d83(%rip), %rsi     # 0x7e3fa
movb $0x1, %al
callq 0x1150
movss -0x13c(%rbp), %xmm0
mulss -0x138(%rbp), %xmm0
movss %xmm0, -0x138(%rbp)
movss -0x138(%rbp), %xmm0
cvtsi2ssl -0x154(%rbp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x140(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x144(%rbp)
movl $0x0, -0x158(%rbp)
movl -0x158(%rbp), %eax
cmpl -0x154(%rbp), %eax
jge 0x3a916
cmpl $0x0, -0x158(%rbp)
jne 0x3a6f6
movq -0x40(%rbp), %rdi
leaq 0x43d23(%rip), %rsi     # 0x7e410
movb $0x0, %al
callq 0x1150
jmp 0x3a70e
movq -0x40(%rbp), %rdi
movl -0x158(%rbp), %edx
leaq 0x43d1e(%rip), %rsi     # 0x7e425
movb $0x0, %al
callq 0x1150
movl $0x0, -0x15c(%rbp)
movl $0x0, -0x114(%rbp)
movl -0x114(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x3a8d8
imull $0x3, -0x114(%rbp), %eax
movl %eax, -0x160(%rbp)
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rcx
movslq -0x114(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x128(%rbp)
movl $0x0, -0x118(%rbp)
cmpl $0x3, -0x118(%rbp)
jge 0x3a7d2
movq -0x128(%rbp), %rax
movslq -0x118(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movl -0x160(%rbp), %ecx
addl -0x118(%rbp), %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm1
mulss -0x144(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movslq -0x118(%rbp), %rax
movss %xmm0, -0x150(%rbp,%rax,4)
movl -0x118(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x118(%rbp)
jmp 0x3a769
movq -0x128(%rbp), %rax
movl 0x64(%rax), %eax
movl %eax, -0x11c(%rbp)
leaq -0x132(%rbp), %rdi
movq -0x30(%rbp), %rax
movslq -0x11c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movswl 0x14(%rax), %esi
callq 0x37330
cmpl $0x1869f, -0x15c(%rbp)  # imm = 0x1869F
jge 0x3a81f
movl -0x15c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x15c(%rbp)
movq -0x40(%rbp), %rdi
movl -0x15c(%rbp), %edx
movq -0x128(%rbp), %rcx
addq $0x18, %rcx
leaq -0x132(%rbp), %r8
movsbl 0x61b65(%rip), %r9d     # 0x9c3a8
movq -0x30(%rbp), %rax
movslq -0x11c(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rax
addq $0xd, %rax
movss -0x150(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x14c(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
movss -0x148(%rbp), %xmm2
cvtss2sd %xmm2, %xmm2
movq -0x128(%rbp), %rsi
movss 0x1c(%rsi), %xmm3
cvtss2sd %xmm3, %xmm4
leaq 0x43b9b(%rip), %rsi     # 0x7e42f
movsd 0x3b7ac(%rip), %xmm3    # 0x76048
movq %rax, (%rsp)
movb $0x5, %al
callq 0x1150
movq -0x18(%rbp), %rax
movq -0x128(%rbp), %rcx
movslq 0x4c(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x128(%rbp)
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0x3a722
movq -0x40(%rbp), %rdi
leaq 0x43b81(%rip), %rsi     # 0x7e464
movb $0x0, %al
callq 0x1150
movss -0x140(%rbp), %xmm0
addss -0x144(%rbp), %xmm0
movss %xmm0, -0x144(%rbp)
movl -0x158(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x158(%rbp)
jmp 0x3a6c7
movq -0x40(%rbp), %rdi
callq 0x10a0
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopl (%rax,%rax)