// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/simulation.c
// Function: Simulate_confchange
void Simulate_confchange(int N_frames, float *tors_dir, float *d_Cart,
			 int PRINT_SIMUL_PDB, float RMSD_NM,
			 float *coord_1, float *coord_2, float rmsd,
			 struct Para_simul Para_simul,
			 atom *atoms, int natoms,
			 struct axe *axe, int naxes,
			 struct bond *bonds,
			 struct residue *seq, int nres,
			 int N_diso, struct Normal_Mode NM,
			 struct Jacobian J, struct Reference Ref,
			 struct interaction *Int_list, int N_int,
			 char *INT_TYPE, float s0, char *nameout,
			 double tors2, int anhar)
{
  int i, Ini_ch=1, n3=3*natoms;
  float coord_all[n3], coord_opt[n3];
  float coord_ref[Ref.N_Cart], coord_ref2[Ref.N_Cart];
  for(i=0; i<Ref.N_Cart; i++)coord_ref2[i]=coord_1[i];

  // Compute factor for simulations
  double factor=1.00;
  if(rmsd >0 ){
    factor=sqrt(rmsd/RMSD_NM);
    printf("RMSD= %.2f (observed) factor=%.2f\n", rmsd, factor);
  }


  // Open files
  FILE *file_pdb=NULL, *file_out; char name_pdb[100], name_out[200];
  if(tors_dir==NULL){
      if(PRINT_SIMUL_PDB)sprintf(name_pdb, "%s_simul.pdb", nameout);
      sprintf(name_out, "%s_simul.dat", nameout);
  }else{
    if(PRINT_SIMUL_PDB)sprintf(name_pdb, "%s_pred_mut.pdb", nameout);
    sprintf(name_out, "%s_pred_mut.dat", nameout);
  }
  if(PRINT_SIMUL_PDB)file_pdb=fopen(name_pdb, "w");
  file_out=fopen(name_out, "w");
  fprintf(file_out, "#step rmsd_previous rmsd_ini rmsd_end E_clash\n");

  // Simulations
  float rmsd0=-1;
  if(coord_2){
    rmsd0=rmsd_mclachlan_f(coord_1, coord_2, Ref.mass_atom, Ref.N_ref);
  }

  char type='R'; // Random ensemble
  float coeff=3*factor/N_frames;
  double d_phi[naxes];
  if(tors_dir){   // Move along a predefined torsional direction   
    for(i=0; i<naxes; i++)d_phi[i]=tors_dir[i]*coeff;
    type='T'; // torsional displacement
  }
  Make_conformations(type, N_frames, d_phi, NULL, factor, coeff, rmsd0,
		     coord_all, coord_opt, coord_ref, coord_ref2, 
		     PRINT_SIMUL_PDB, file_out, file_pdb,
		     coord_1, coord_2, Para_simul,
		     atoms, natoms, axe, naxes, bonds, seq, nres, N_diso,
		     NM, J, Ref, Int_list, N_int, INT_TYPE, s0, nameout,
		     anhar);
  if(d_Cart){
    Make_conformations('C', N_frames, NULL, d_Cart, factor, coeff, rmsd0,
		       coord_all, coord_opt, coord_ref, coord_ref2, 
		       PRINT_SIMUL_PDB, file_out, file_pdb,
		       coord_1, coord_2, Para_simul,
		       atoms, natoms, axe, naxes, bonds, seq, nres, N_diso,
		       NM, J, Ref, Int_list, N_int, INT_TYPE, s0, nameout,
		       anhar);
  }
  printf("Distances printed in %s\n", name_out); fclose(file_out);
  if(PRINT_SIMUL_PDB){
    printf("Simulated structures printed in %s\n", name_pdb);
    fclose(file_pdb);
  }
  if(Ini_ch==0){Empty_tors(Diff_s); free(ali_sim.alignres); Ini_ch=1;}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2c8, %rsp            # imm = 0x2C8
movl 0x1f8(%rbp), %eax
movq 0x1f0(%rbp), %rax
movq 0x1e8(%rbp), %rax
movl 0x1e0(%rbp), %eax
movq 0x1d8(%rbp), %rax
leaq 0x1a8(%rbp), %rax
movq %rax, -0x248(%rbp)
leaq 0x160(%rbp), %r10
movq %r10, -0x240(%rbp)
leaq 0x90(%rbp), %r10
movq %r10, -0x238(%rbp)
movl 0x88(%rbp), %r10d
movl 0x80(%rbp), %r10d
movq 0x78(%rbp), %r10
movq 0x70(%rbp), %r10
movl 0x68(%rbp), %r10d
movq 0x60(%rbp), %r10
movl 0x58(%rbp), %r10d
movq 0x50(%rbp), %r10
leaq 0x10(%rbp), %r10
movq %r10, -0x230(%rbp)
movl %edi, -0x2c(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdx, -0x40(%rbp)
movl %ecx, -0x44(%rbp)
movss %xmm0, -0x48(%rbp)
movq %r8, -0x50(%rbp)
movq %r9, -0x58(%rbp)
movss %xmm1, -0x5c(%rbp)
movss %xmm2, -0x60(%rbp)
movsd %xmm3, -0x68(%rbp)
movl $0x1, -0x70(%rbp)
movl 0x58(%rbp), %edx
movl %edx, %ecx
leal (%rcx,%rcx,2), %ecx
movl %ecx, -0x74(%rbp)
movl -0x74(%rbp), %ecx
movq %rsp, %rdx
movq %rdx, -0x80(%rbp)
leaq 0xf(,%rcx,4), %rsi
andq $-0x10, %rsi
movq %rsp, %rdx
subq %rsi, %rdx
movq %rdx, -0x228(%rbp)
movq %rdx, %rsp
movq %rcx, -0x88(%rbp)
movl -0x74(%rbp), %ecx
leaq 0xf(,%rcx,4), %rsi
andq $-0x10, %rsi
movq %rsp, %rdx
subq %rsi, %rdx
movq %rdx, -0x220(%rbp)
movq %rdx, %rsp
movq %rcx, -0x90(%rbp)
movl 0x4(%rax), %ecx
leaq 0xf(,%rcx,4), %rsi
andq $-0x10, %rsi
movq %rsp, %rdx
subq %rsi, %rdx
movq %rdx, -0x218(%rbp)
movq %rdx, %rsp
movq %rcx, -0x98(%rbp)
movl 0x4(%rax), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x210(%rbp)
movq %rcx, %rsp
movq %rax, -0xa0(%rbp)
movl $0x0, -0x6c(%rbp)
movq -0x248(%rbp), %rcx
movl -0x6c(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x4f529
movq -0x210(%rbp), %rax
movq -0x50(%rbp), %rcx
movslq -0x6c(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm0
movslq -0x6c(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x4f4f2
movsd 0x26b17(%rip), %xmm0    # 0x76048
movsd %xmm0, -0xa8(%rbp)
movss -0x5c(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x4f580
movss -0x5c(%rbp), %xmm0
divss -0x48(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x1220
movsd %xmm0, -0xa8(%rbp)
movss -0x5c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd -0xa8(%rbp), %xmm1
leaq 0x313ae(%rip), %rdi     # 0x80927
movb $0x2, %al
callq 0x10d0
movq $0x0, -0xb0(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x4f5d2
cmpl $0x0, -0x44(%rbp)
je 0x4f5b4
leaq -0x120(%rbp), %rdi
movq 0x1f0(%rbp), %rdx
leaq 0x3139d(%rip), %rsi     # 0x8094a
movb $0x0, %al
callq 0x1200
leaq -0x1f0(%rbp), %rdi
movq 0x1f0(%rbp), %rdx
leaq 0x313e5(%rip), %rsi     # 0x809ae
movb $0x0, %al
callq 0x1200
jmp 0x4f610
cmpl $0x0, -0x44(%rbp)
je 0x4f5f4
leaq -0x120(%rbp), %rdi
movq 0x1f0(%rbp), %rdx
leaq 0x3136a(%rip), %rsi     # 0x80957
movb $0x0, %al
callq 0x1200
leaq -0x1f0(%rbp), %rdi
movq 0x1f0(%rbp), %rdx
leaq 0x3135e(%rip), %rsi     # 0x80967
movb $0x0, %al
callq 0x1200
cmpl $0x0, -0x44(%rbp)
je 0x4f630
leaq -0x120(%rbp), %rdi
leaq 0x2cd4e(%rip), %rsi     # 0x7c372
callq 0x11b0
movq %rax, -0xb0(%rbp)
leaq -0x1f0(%rbp), %rdi
leaq 0x2cd34(%rip), %rsi     # 0x7c372
callq 0x11b0
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rdi
leaq 0x3131f(%rip), %rsi     # 0x80977
movb $0x0, %al
callq 0x1150
movss 0x26a09(%rip), %xmm0    # 0x76070
movss %xmm0, -0x1f4(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x4f69c
movq -0x248(%rbp), %rax
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq 0x10(%rax), %rdx
movl (%rax), %ecx
callq 0x70af0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x1f4(%rbp)
movb $0x52, -0x1f5(%rbp)
movsd -0xa8(%rbp), %xmm0
movsd 0x2cd85(%rip), %xmm1    # 0x7c438
mulsd %xmm1, %xmm0
cvtsi2sdl -0x2c(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x1fc(%rbp)
movl 0x68(%rbp), %eax
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x250(%rbp)
movq %rcx, %rsp
movq %rax, -0x208(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x4f743
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl 0x68(%rbp), %eax
jge 0x4f73c
movq -0x250(%rbp), %rax
movq -0x38(%rbp), %rcx
movslq -0x6c(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm0
mulss -0x1fc(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movslq -0x6c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x4f700
movb $0x54, -0x1f5(%rbp)
movq -0x248(%rbp), %rax
movq -0x238(%rbp), %rsi
movb -0x1f5(%rbp), %cl
movb %cl, -0x251(%rbp)
movl -0x2c(%rbp), %ecx
movl %ecx, -0x29c(%rbp)
movsd -0xa8(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss -0x1fc(%rbp), %xmm1
movss -0x1f4(%rbp), %xmm2
movl -0x44(%rbp), %r11d
movq -0xb8(%rbp), %rbx
movq -0xb0(%rbp), %r14
movq -0x50(%rbp), %r15
movq -0x58(%rbp), %r12
movq 0x50(%rbp), %r13
movl 0x58(%rbp), %edx
movq 0x60(%rbp), %rcx
movq %rcx, -0x298(%rbp)
movl 0x68(%rbp), %r8d
movq 0x70(%rbp), %r9
movq 0x78(%rbp), %r10
movl 0x80(%rbp), %ecx
movl %ecx, -0x258(%rbp)
movl 0x88(%rbp), %ecx
movl %ecx, -0x25c(%rbp)
movq 0x1d8(%rbp), %rcx
movq %rcx, -0x268(%rbp)
movl 0x1e0(%rbp), %ecx
movl %ecx, -0x26c(%rbp)
movq 0x1e8(%rbp), %rcx
movq %rcx, -0x278(%rbp)
movss -0x60(%rbp), %xmm3
movq 0x1f0(%rbp), %rcx
movq %rcx, -0x280(%rbp)
movl 0x1f8(%rbp), %ecx
movl %ecx, -0x28c(%rbp)
xorl %ecx, %ecx
subq $0x230, %rsp            # imm = 0x230
movq %rsp, %rdi
movq %rdi, -0x288(%rbp)
addq $0xb8, %rdi
movl $0x1a, %ecx
rep  movsq (%rsi), %es:(%rdi)
movl -0x29c(%rbp), %esi
movq -0x298(%rbp), %rdi
movq -0x288(%rbp), %rcx
movups (%rax), %xmm4
movups 0x10(%rax), %xmm5
movups 0x20(%rax), %xmm6
movq -0x240(%rbp), %rax
movups %xmm6, 0x1f0(%rcx)
movups %xmm5, 0x1e0(%rcx)
movups %xmm4, 0x1d0(%rcx)
movq 0x40(%rax), %rax
movq %rax, 0x1c8(%rcx)
movl -0x28c(%rbp), %eax
movq -0x240(%rbp), %rcx
movups (%rcx), %xmm4
movups 0x10(%rcx), %xmm5
movups 0x20(%rcx), %xmm6
movups 0x30(%rcx), %xmm7
movq -0x288(%rbp), %rcx
movups %xmm7, 0x1b8(%rcx)
movups %xmm6, 0x1a8(%rcx)
movups %xmm5, 0x198(%rcx)
movups %xmm4, 0x188(%rcx)
movq -0x230(%rbp), %rcx
movups (%rcx), %xmm4
movups 0x10(%rcx), %xmm5
movups 0x20(%rcx), %xmm6
movups 0x2c(%rcx), %xmm7
movq -0x288(%rbp), %rcx
movups %xmm7, 0x64(%rcx)
movups %xmm6, 0x58(%rcx)
movups %xmm5, 0x48(%rcx)
movups %xmm4, 0x38(%rcx)
movl %eax, 0x220(%rcx)
movq -0x280(%rbp), %rax
movq %rax, 0x218(%rcx)
movq -0x278(%rbp), %rax
movq %rax, 0x210(%rcx)
movl -0x26c(%rbp), %eax
movl %eax, 0x208(%rcx)
movq -0x268(%rbp), %rax
movq %rax, 0x200(%rcx)
movl -0x25c(%rbp), %eax
movl %eax, 0xb0(%rcx)
movl -0x258(%rbp), %eax
movl %eax, 0xa8(%rcx)
movb -0x251(%rbp), %al
movq %r10, 0xa0(%rcx)
movq -0x210(%rbp), %r10
movq %r9, 0x98(%rcx)
movq -0x220(%rbp), %r9
movl %r8d, 0x90(%rcx)
movq -0x228(%rbp), %r8
movq %rdi, 0x88(%rcx)
movq -0x218(%rbp), %rdi
movl %edx, 0x80(%rcx)
movq -0x250(%rbp), %rdx
movq %r13, 0x78(%rcx)
movq %r12, 0x30(%rcx)
movq %r15, 0x28(%rcx)
movq %r14, 0x20(%rcx)
movq %rbx, 0x18(%rcx)
movl %r11d, 0x10(%rcx)
movq %r10, 0x8(%rcx)
movq %rdi, (%rcx)
movsbl %al, %edi
xorl %eax, %eax
movl %eax, %ecx
callq 0x4fcf0
addq $0x230, %rsp            # imm = 0x230
cmpq $0x0, -0x40(%rbp)
je 0x4fc3d
movq -0x248(%rbp), %rax
movq -0x238(%rbp), %rsi
movl -0x2c(%rbp), %ecx
movl %ecx, -0x2e4(%rbp)
movq -0x40(%rbp), %rcx
movq %rcx, -0x2a8(%rbp)
movsd -0xa8(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss -0x1fc(%rbp), %xmm1
movss -0x1f4(%rbp), %xmm2
movl -0x44(%rbp), %r10d
movq -0xb8(%rbp), %r11
movq -0xb0(%rbp), %rbx
movq -0x50(%rbp), %r14
movq -0x58(%rbp), %r15
movq 0x50(%rbp), %r12
movl 0x58(%rbp), %r13d
movq 0x60(%rbp), %rdx
movl 0x68(%rbp), %ecx
movl %ecx, -0x2e0(%rbp)
movq 0x70(%rbp), %r8
movq 0x78(%rbp), %r9
movl 0x80(%rbp), %ecx
movl %ecx, -0x2ac(%rbp)
movl 0x88(%rbp), %ecx
movl %ecx, -0x2b0(%rbp)
movq 0x1d8(%rbp), %rcx
movq %rcx, -0x2b8(%rbp)
movl 0x1e0(%rbp), %ecx
movl %ecx, -0x2bc(%rbp)
movq 0x1e8(%rbp), %rcx
movq %rcx, -0x2c8(%rbp)
movss -0x60(%rbp), %xmm3
movq 0x1f0(%rbp), %rcx
movq %rcx, -0x2d0(%rbp)
movl 0x1f8(%rbp), %ecx
movl %ecx, -0x2dc(%rbp)
xorl %ecx, %ecx
subq $0x230, %rsp            # imm = 0x230
movq %rsp, %rdi
movq %rdi, -0x2d8(%rbp)
addq $0xb8, %rdi
movl $0x1a, %ecx
rep  movsq (%rsi), %es:(%rdi)
movl -0x2e4(%rbp), %esi
movl -0x2e0(%rbp), %edi
movq -0x240(%rbp), %rcx
movups (%rax), %xmm4
movups 0x10(%rax), %xmm5
movups 0x20(%rax), %xmm6
movq -0x2d8(%rbp), %rax
movups %xmm6, 0x1f0(%rax)
movups %xmm5, 0x1e0(%rax)
movups %xmm4, 0x1d0(%rax)
movq 0x40(%rcx), %rcx
movq %rcx, 0x1c8(%rax)
movl -0x2dc(%rbp), %ecx
movq -0x240(%rbp), %rax
movups (%rax), %xmm4
movups 0x10(%rax), %xmm5
movups 0x20(%rax), %xmm6
movups 0x30(%rax), %xmm7
movq -0x2d8(%rbp), %rax
movups %xmm7, 0x1b8(%rax)
movups %xmm6, 0x1a8(%rax)
movups %xmm5, 0x198(%rax)
movups %xmm4, 0x188(%rax)
movq -0x230(%rbp), %rax
movups (%rax), %xmm4
movups 0x10(%rax), %xmm5
movups 0x20(%rax), %xmm6
movups 0x2c(%rax), %xmm7
movq -0x2d8(%rbp), %rax
movups %xmm7, 0x64(%rax)
movups %xmm6, 0x58(%rax)
movups %xmm5, 0x48(%rax)
movups %xmm4, 0x38(%rax)
movl %ecx, 0x220(%rax)
movq -0x2d0(%rbp), %rcx
movq %rcx, 0x218(%rax)
movq -0x2c8(%rbp), %rcx
movq %rcx, 0x210(%rax)
movl -0x2bc(%rbp), %ecx
movl %ecx, 0x208(%rax)
movq -0x2b8(%rbp), %rcx
movq %rcx, 0x200(%rax)
movl -0x2b0(%rbp), %ecx
movl %ecx, 0xb0(%rax)
movl -0x2ac(%rbp), %ecx
movl %ecx, 0xa8(%rax)
movq -0x2a8(%rbp), %rcx
movq %r9, 0xa0(%rax)
movq -0x220(%rbp), %r9
movq %r8, 0x98(%rax)
movq -0x228(%rbp), %r8
movl %edi, 0x90(%rax)
movq -0x210(%rbp), %rdi
movq %rdx, 0x88(%rax)
movq -0x218(%rbp), %rdx
movl %r13d, 0x80(%rax)
movq %r12, 0x78(%rax)
movq %r15, 0x30(%rax)
movq %r14, 0x28(%rax)
movq %rbx, 0x20(%rax)
movq %r11, 0x18(%rax)
movl %r10d, 0x10(%rax)
movq %rdi, 0x8(%rax)
movq %rdx, (%rax)
xorl %eax, %eax
movl %eax, %edx
movl $0x43, %edi
callq 0x4fcf0
addq $0x230, %rsp            # imm = 0x230
leaq -0x1f0(%rbp), %rsi
leaq 0x30650(%rip), %rdi     # 0x8029b
movb $0x0, %al
callq 0x10d0
movq -0xb8(%rbp), %rdi
callq 0x10a0
cmpl $0x0, -0x44(%rbp)
je 0x4fc85
leaq -0x120(%rbp), %rsi
leaq 0x3075c(%rip), %rdi     # 0x803ce
movb $0x0, %al
callq 0x10d0
movq -0xb0(%rbp), %rdi
callq 0x10a0
cmpl $0x0, -0x70(%rbp)
jne 0x4fcd9
subq $0x40, %rsp
movups 0x4c872(%rip), %xmm0    # 0x9c508
movq %rsp, %rax
movups %xmm0, 0x30(%rax)
movups 0x4c854(%rip), %xmm0    # 0x9c4f8
movups %xmm0, 0x20(%rax)
movups 0x4c839(%rip), %xmm0    # 0x9c4e8
movups %xmm0, 0x10(%rax)
movups 0x4c81e(%rip), %xmm0    # 0x9c4d8
movups %xmm0, (%rax)
callq 0x16450
addq $0x40, %rsp
movq 0x4c863(%rip), %rdi     # 0x9c530
callq 0x1040
movl $0x1, -0x70(%rbp)
movq -0x80(%rbp), %rax
movq %rax, %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop