// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/simulation.c
// Function: Standardize_bonds
void Standardize_bonds(struct bond *bonds, atom *atoms,
		       int natoms, char *nameout1,
		       struct axe *axes, int naxes,
		       struct residue *seq, int nres,
		       struct chain *chains, int Nchain, 
		       double Tors_fluct,
		       struct Para_simul Para_simul)
{
  printf("Standardizing bond lengths and bond angles\n");

  int PR_STD=1; char name[80]="tmp.dat"; FILE *file_out;
  if(PR_STD){
    file_out=fopen(name, "w");
    fprintf(file_out, "#atm delta_r delta_cos_theta\n");
  }

  // Change bond angles and bond lengths in bonds
  Set_bonds_measure(bonds, natoms, atoms);
  int nc=0, i;
  for(i=0; i<natoms; i++){
    struct bond *bond=bonds+i;
    if(bond->previous==NULL)continue;
    if((bond->len>=0)||(bond->angle>=0))continue;  // exclude pseudo-bonds
    int na=Atom_type(bond->atom->name);
    if((na<0)||(na>4))continue;
    if(PR_STD){
      fprintf(file_out, "%s %.3f %.3f\n",
	      bond->atom->name, bond->l-BB_length[na],
	      bond->r_cos_theta/bond->l-cos(BB_angle[na]));
    }
    if(bond->previous->previous){
      bond->r_cos_theta =  BB_length[na]*cos(BB_angle[na]);
    }else{
      bond->r_cos_theta =  BB_length[na];
    }
    bond->l=BB_length[na];
    nc+=2;
  }
  if(PR_STD){fclose(file_out);
  printf("%d internal coordinates changed\n", nc);
  printf("Coordinates written in %s\n", name);}

  // Compute coordinates and RMSD
  double d_phi[naxes]; for(i=0; i<naxes; i++)d_phi[i]=0;
  Build_up(bonds, natoms, d_phi, naxes);

  atom atoms2[natoms], *atom2=atoms2, *atom1=atoms;
  for(i=0; i<natoms; i++){
    *atom2=*atom1; atom2->ali=i; atom1++; atom2++;
  }
  Copy_atoms_bonds(atoms2, bonds, natoms);

  // Adjust torsion angles
  double diff_phi[naxes];
  struct Reference Ref1;
  Set_reference(&Ref1, 0, "EB", atoms, 0, natoms);
  struct ali_atoms ali_a; Copy_ali(&ali_a, Ref1);
  struct Jacobian J;
  Allocate_Jacobian(&J, naxes, Ref1.N_Cart);
  int first_kin[naxes], last_kin[naxes];
  Change_kin(first_kin, last_kin, axes, naxes, natoms, Ref1);
  Compute_kinetic(&J, axes, naxes, atoms, natoms, Ref1, 0);
  Change_kin_back(axes, naxes, first_kin, last_kin);
  Torsional_confchange_RRR(diff_phi, "standard", bonds, &J, Ref1, ali_a,
			   Tors_fluct, atoms2, natoms, nameout1, axes, naxes,
			   seq, nres, chains, Nchain,atoms,natoms,Para_simul,
			   NULL,0);
  Empty_Ref(&Ref1);
  Empty_Jacobian(J);

  // Check
  Test_standard(bonds, natoms);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
leaq 0x30(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movl 0x28(%rbp), %eax
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movl %edx, -0x3c(%rbp)
movq %rcx, -0x48(%rbp)
movq %r8, -0x50(%rbp)
movl %r9d, -0x54(%rbp)
movsd %xmm0, -0x60(%rbp)
leaq 0x2dfea(%rip), %rdi     # 0x80f3a
movb $0x0, %al
callq 0x10d0
movl $0x1, -0x64(%rbp)
leaq -0xc0(%rbp), %rdi
leaq 0x2e224(%rip), %rsi     # 0x81190
movl $0x50, %edx
callq 0x1160
cmpl $0x0, -0x64(%rbp)
je 0x52fab
leaq -0xc0(%rbp), %rdi
leaq 0x293e8(%rip), %rsi     # 0x7c372
callq 0x11b0
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rdi
leaq 0x2dfc2(%rip), %rsi     # 0x80f66
movb $0x0, %al
callq 0x1150
movq -0x30(%rbp), %rdi
movl -0x3c(%rbp), %esi
movq -0x38(%rbp), %rdx
callq 0x1bf00
movl $0x0, -0xcc(%rbp)
movl $0x0, -0xd0(%rbp)
movl -0xd0(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x531fa
movq -0x30(%rbp), %rax
movslq -0xd0(%rbp), %rcx
imulq $0xc0, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x5300d
jmp 0x531e6
movq -0xd8(%rbp), %rax
cmpl $0x0, 0x34(%rax)
jge 0x53027
movq -0xd8(%rbp), %rax
cmpl $0x0, 0x38(%rax)
jl 0x5302c
jmp 0x531e6
movq -0xd8(%rbp), %rax
movq (%rax), %rdi
addq $0x18, %rdi
callq 0x14250
movl %eax, -0xdc(%rbp)
cmpl $0x0, -0xdc(%rbp)
jl 0x53057
cmpl $0x4, -0xdc(%rbp)
jle 0x5305c
jmp 0x531e6
cmpl $0x0, -0x64(%rbp)
je 0x53127
movq -0xc8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
movq -0xd8(%rbp), %rax
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0x1d0(%rbp)
movq -0xd8(%rbp), %rax
movsd 0x58(%rax), %xmm0
movslq -0xdc(%rbp), %rcx
leaq 0x39d6d(%rip), %rax     # 0x8ce10
movss (%rax,%rcx,4), %xmm1
cvtss2sd %xmm1, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x1c8(%rbp)
movq -0xd8(%rbp), %rax
movsd 0x60(%rax), %xmm0
movq -0xd8(%rbp), %rax
divsd 0x58(%rax), %xmm0
movsd %xmm0, -0x1e0(%rbp)
movslq -0xdc(%rbp), %rcx
leaq 0x39d4a(%rip), %rax     # 0x8ce30
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x1100
movsd -0x1e0(%rbp), %xmm1
movq -0x1d8(%rbp), %rdi
movq -0x1d0(%rbp), %rdx
movaps %xmm0, %xmm2
movsd -0x1c8(%rbp), %xmm0
subsd %xmm2, %xmm1
leaq 0x2dead(%rip), %rsi     # 0x80fcd
movb $0x2, %al
callq 0x1150
movq -0xd8(%rbp), %rax
movq 0x28(%rax), %rax
cmpq $0x0, 0x28(%rax)
je 0x53191
movslq -0xdc(%rbp), %rcx
leaq 0x39cc9(%rip), %rax     # 0x8ce10
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x1e8(%rbp)
movslq -0xdc(%rbp), %rcx
leaq 0x39cca(%rip), %rax     # 0x8ce30
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x1100
movaps %xmm0, %xmm1
movsd -0x1e8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movq -0xd8(%rbp), %rax
movsd %xmm0, 0x60(%rax)
jmp 0x531b4
movslq -0xdc(%rbp), %rcx
leaq 0x39c71(%rip), %rax     # 0x8ce10
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0xd8(%rbp), %rax
movsd %xmm0, 0x60(%rax)
movslq -0xdc(%rbp), %rcx
leaq 0x39c4e(%rip), %rax     # 0x8ce10
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0xd8(%rbp), %rax
movsd %xmm0, 0x58(%rax)
movl -0xcc(%rbp), %eax
addl $0x2, %eax
movl %eax, -0xcc(%rbp)
movl -0xd0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd0(%rbp)
jmp 0x52fcf
cmpl $0x0, -0x64(%rbp)
je 0x53235
movq -0xc8(%rbp), %rdi
callq 0x10a0
movl -0xcc(%rbp), %esi
leaq 0x2dd6b(%rip), %rdi     # 0x80f84
movb $0x0, %al
callq 0x10d0
leaq -0xc0(%rbp), %rsi
leaq 0x2dd77(%rip), %rdi     # 0x80fa5
movb $0x0, %al
callq 0x10d0
movl -0x54(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0xe8(%rbp)
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x1f0(%rbp)
movq %rcx, %rsp
movq %rax, -0xf0(%rbp)
movl $0x0, -0xd0(%rbp)
movl -0xd0(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0x532a1
movq -0x1f0(%rbp), %rax
movslq -0xd0(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0xd0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd0(%rbp)
jmp 0x5326f
movq -0x1f0(%rbp), %rdx
movq -0x30(%rbp), %rdi
movl -0x3c(%rbp), %esi
movl -0x54(%rbp), %ecx
callq 0x1c4f0
movl -0x3c(%rbp), %eax
movl %eax, %ecx
imulq $0x70, %rcx, %rdx
movq %rsp, %rax
subq %rdx, %rax
movq %rax, -0x1f8(%rbp)
movq %rax, %rsp
movq %rcx, -0xf8(%rbp)
movq %rax, -0x100(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x108(%rbp)
movl $0x0, -0xd0(%rbp)
movl -0xd0(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x5335b
movq -0x100(%rbp), %rdi
movq -0x108(%rbp), %rsi
movl $0x70, %edx
callq 0x1160
movl -0xd0(%rbp), %ecx
movq -0x100(%rbp), %rax
movl %ecx, 0x54(%rax)
movq -0x108(%rbp), %rax
addq $0x70, %rax
movq %rax, -0x108(%rbp)
movq -0x100(%rbp), %rax
addq $0x70, %rax
movq %rax, -0x100(%rbp)
movl -0xd0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd0(%rbp)
jmp 0x532f3
movq -0x1f8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x3c(%rbp), %edx
callq 0x4e480
movl -0x54(%rbp), %eax
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x200(%rbp)
movq %rcx, %rsp
movq %rax, -0x110(%rbp)
movq -0x38(%rbp), %rcx
movl -0x3c(%rbp), %r9d
leaq 0x23049(%rip), %rdx     # 0x763ec
leaq -0x140(%rbp), %rdi
xorl %r8d, %r8d
movl %r8d, %esi
callq 0x34f10
subq $0x30, %rsp
movups -0x140(%rbp), %xmm0
movups -0x130(%rbp), %xmm1
movups -0x120(%rbp), %xmm2
movq %rsp, %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x160(%rbp), %rdi
callq 0x4b500
addq $0x30, %rsp
movl -0x54(%rbp), %esi
movl -0x13c(%rbp), %edx
leaq -0x1a8(%rbp), %rdi
callq 0x31560
movl -0x54(%rbp), %eax
leaq 0xf(,%rax,4), %rcx
andq $-0x10, %rcx
movq %rsp, %rdi
subq %rcx, %rdi
movq %rdi, -0x210(%rbp)
movq %rdi, %rsp
movq %rax, -0x1b0(%rbp)
movl -0x54(%rbp), %eax
leaq 0xf(,%rax,4), %rcx
andq $-0x10, %rcx
movq %rsp, %rsi
subq %rcx, %rsi
movq %rsi, -0x208(%rbp)
movq %rsi, %rsp
movq %rax, -0x1b8(%rbp)
movq -0x50(%rbp), %rdx
movl -0x54(%rbp), %ecx
movl -0x3c(%rbp), %r8d
subq $0x30, %rsp
movups -0x140(%rbp), %xmm0
movups -0x130(%rbp), %xmm1
movups -0x120(%rbp), %xmm2
movq %rsp, %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x50690
addq $0x30, %rsp
movq -0x50(%rbp), %rsi
movl -0x54(%rbp), %edx
movq -0x38(%rbp), %rcx
movl -0x3c(%rbp), %r8d
xorl %eax, %eax
subq $0x30, %rsp
movups -0x140(%rbp), %xmm0
movups -0x130(%rbp), %xmm1
movups -0x120(%rbp), %xmm2
movq %rsp, %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x1a8(%rbp), %rdi
xorl %r9d, %r9d
callq 0x2dc70
movq -0x210(%rbp), %rdx
movq -0x208(%rbp), %rcx
addq $0x30, %rsp
movq -0x50(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x50600
movq -0x200(%rbp), %rdi
movq -0x1f8(%rbp), %r8
movq -0x30(%rbp), %rdx
movsd -0x60(%rbp), %xmm0
movl -0x3c(%rbp), %r9d
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %rsi
movl -0x54(%rbp), %r10d
movq 0x10(%rbp), %r11
movl 0x18(%rbp), %ebx
movq 0x20(%rbp), %r14
movl 0x28(%rbp), %r15d
movq -0x38(%rbp), %r12
movl -0x3c(%rbp), %r13d
xorl %eax, %eax
xorl %eax, %eax
movq -0x1c0(%rbp), %rax
subq $0xf0, %rsp
movups (%rax), %xmm1
movups 0x10(%rax), %xmm2
movups 0x20(%rax), %xmm3
movups 0x2c(%rax), %xmm4
movq %rsp, %rax
movups %xmm4, 0xc4(%rax)
movups %xmm3, 0xb8(%rax)
movups %xmm2, 0xa8(%rax)
movups %xmm1, 0x98(%rax)
movups -0x160(%rbp), %xmm1
movups -0x150(%rbp), %xmm2
movups %xmm2, 0x40(%rax)
movups %xmm1, 0x30(%rax)
movups -0x140(%rbp), %xmm1
movups -0x130(%rbp), %xmm2
movups -0x120(%rbp), %xmm3
movups %xmm3, 0x20(%rax)
movups %xmm2, 0x10(%rax)
movups %xmm1, (%rax)
movl %r13d, 0x90(%rax)
movq %r12, 0x88(%rax)
movl %r15d, 0x80(%rax)
movq %r14, 0x78(%rax)
movl %ebx, 0x70(%rax)
movq %r11, 0x68(%rax)
movl %r10d, 0x60(%rax)
movq %rsi, 0x58(%rax)
movq %rcx, 0x50(%rax)
movl $0x0, 0xe0(%rax)
movq $0x0, 0xd8(%rax)
leaq 0x2cf3e(%rip), %rsi     # 0x80527
leaq -0x1a8(%rbp), %rcx
callq 0x4cf90
addq $0xf0, %rsp
leaq -0x140(%rbp), %rdi
callq 0x354f0
subq $0x50, %rsp
movq -0x168(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x40(%rax)
movups -0x1a8(%rbp), %xmm0
movups -0x198(%rbp), %xmm1
movups -0x188(%rbp), %xmm2
movups -0x178(%rbp), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x31600
addq $0x50, %rsp
movq -0x30(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x53680
movq -0xe8(%rbp), %rax
movq %rax, %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)