// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/force2confchange.c
// Function: Force2Confchange
int Force2Confchange(float *atom_move, char *FILE_FORCE,
		     int naxe1, int N_ref, atom *atoms1, int natoms1,
		     int *atom_num1, float **Jacobian_ar, float *eigen_value,
		     float **Tors_mode, int *select, struct axe *axe1,
		     char *chain1, int nres1, struct residue *seq1,
		     struct bond *bonds)
{
  int N_cart=3*N_ref, i, ia, j, k;
  double Delta_theta[naxe1];
  float Force_input_cart[N_cart];
  float Force_input_tors[naxe1];
  float Force_input_coef[naxe1];
  double sum;

  //i=Read_force(Force_input_cart, atoms1, atom_num1, N_ref, FILE_FORCE);

  // Read force
  int nres, nmr, ANISOU;
  //~ int natoms;
  atom atom_read[natoms1], *atom;
  struct residue seq[nres1];
  printf("Reading force in file %s\n", FILE_FORCE);
  nres=Read_coord(FILE_FORCE, &nmr, seq, atom_read, chain1, &ANISOU, NULL);
  if(nres<0)return(-1); // file not found
  if(nres!=nres1){
    printf("ERROR, wrong number of residues in force file:");
    printf(" %d instead of %d\n", nres, nres1); return(-1);
  }
  for(i=0; i<nres; i++){
    if(seq[i].amm!=seq1[i].amm){
      printf("ERROR, wrong amino acid in force file\n");
      printf("Position %d, %c instead of %c\n", i, seq[i].amm, seq1[i].amm);
      return(-1);
    }
  }
  for(i=0; i<3*N_ref; i++)Force_input_cart[i]=0;
  for(i=0; i<N_ref; i++){
    atom=Find_atom_seq(seq, nres, atoms1[atom_num1[i]]);
    if(atom==NULL)continue;
    k=3*i; for(j=0; j<3; j++){Force_input_cart[k]=atom->r[j]; k++;}
  }
  // End read force

  for(i=0; i<naxe1; i++){  // Torsional force F^tors_a = sum_i F_i*J_ia
    sum=0; for(j=0; j<N_cart; j++)sum+=Jacobian_ar[i][j]*Force_input_cart[j];
    Force_input_tors[i]=sum;
  }
  for(ia=0; ia<naxe1; ia++){  // c^alpha =(F^tors,u^alpha)
    if(select[ia]==0)continue;
    float *ua=Tors_mode[ia];
    sum=0; for(i=0; i<naxe1; i++)sum+=ua[i]*Force_input_tors[i];
    Force_input_coef[ia]=sum;
  }
  for(i=0; i<naxe1; i++)Delta_theta[i]=0;
  for(ia=0; ia<naxe1; ia++){  // Delta_theta= H^{-1} F^tors
    if(select[ia]==0)continue;
    float *ua=Tors_mode[ia];
    float w=Force_input_coef[ia]/eigen_value[ia];
    for(i=0; i<naxe1; i++)Delta_theta[i]+=w*ua[i];
  }

  // Initialize build up
  Set_bonds_measure(bonds, natoms1, atoms1);
  // Build up Cartesian coordinates from Delta_theta
  Build_up(bonds, natoms1, Delta_theta, naxe1);
  k=3;
  for(i=1;i<N_ref;i++){
    struct bond *bond=bonds+atom_num1[i];
    for(j=0; j<3; j++){
      atom_move[k]=bond->r[j]; k++;
    }
  }
  return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movl 0x48(%rbp), %eax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movl -0x20(%rbp), %ecx
movl %ecx, %eax
leal (%rax,%rax,2), %eax
movl %eax, -0x30(%rbp)
movl -0x1c(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x48(%rbp)
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xf0(%rbp)
movq %rcx, %rsp
movq %rax, -0x50(%rbp)
movl -0x30(%rbp), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xe8(%rbp)
movq %rcx, %rsp
movq %rax, -0x58(%rbp)
movl -0x1c(%rbp), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xe0(%rbp)
movq %rcx, %rsp
movq %rax, -0x60(%rbp)
movl -0x1c(%rbp), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xd8(%rbp)
movq %rcx, %rsp
movq %rax, -0x68(%rbp)
movl -0x2c(%rbp), %eax
imulq $0x70, %rax, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xc8(%rbp)
movq %rcx, %rsp
movq %rax, -0x88(%rbp)
movl 0x48(%rbp), %eax
movq %rax, %rdx
shlq $0x5, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xd0(%rbp)
movq %rcx, %rsp
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rsi
leaq 0x2d110(%rip), %rdi     # 0x811e0
movb $0x0, %al
callq 0x10d0
movq -0xd0(%rbp), %rdx
movq -0xc8(%rbp), %rcx
movq -0x18(%rbp), %rdi
movq 0x40(%rbp), %r8
leaq -0x78(%rbp), %rsi
leaq -0x7c(%rbp), %r9
xorl %eax, %eax
subq $0x10, %rsp
movq $0x0, (%rsp)
callq 0xfe90
addq $0x10, %rsp
movl %eax, -0x74(%rbp)
cmpl $0x0, -0x74(%rbp)
jge 0x5412b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x9c(%rbp)
jmp 0x54615
movl -0x74(%rbp), %eax
cmpl 0x48(%rbp), %eax
je 0x5416b
leaq 0x2d0c0(%rip), %rdi     # 0x811fa
movb $0x0, %al
callq 0x10d0
movl -0x74(%rbp), %esi
movl 0x48(%rbp), %edx
leaq 0x2d0db(%rip), %rdi     # 0x81229
movb $0x0, %al
callq 0x10d0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x9c(%rbp)
jmp 0x54615
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x74(%rbp), %eax
jge 0x54219
movq -0xd0(%rbp), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsbl 0x13(%rax), %eax
movq 0x50(%rbp), %rcx
movslq -0x34(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movsbl 0x13(%rcx), %ecx
cmpl %ecx, %eax
je 0x54209
leaq 0x2d08a(%rip), %rdi     # 0x8123c
movb $0x0, %al
callq 0x10d0
movq -0xd0(%rbp), %rax
movl -0x34(%rbp), %esi
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsbl 0x13(%rax), %edx
movq 0x50(%rbp), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsbl 0x13(%rax), %ecx
leaq 0x2d077(%rip), %rdi     # 0x81263
movb $0x0, %al
callq 0x10d0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x9c(%rbp)
jmp 0x54615
jmp 0x5420b
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x54172
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
imull $0x3, -0x20(%rbp), %ecx
cmpl %ecx, %eax
jge 0x54249
movq -0xe8(%rbp), %rax
movslq -0x34(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x54220
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x54339
movq -0xd0(%rbp), %rdi
movl -0x74(%rbp), %esi
movq -0x28(%rbp), %rcx
movq 0x10(%rbp), %rax
movslq -0x34(%rbp), %rdx
movslq (%rax,%rdx,4), %rax
imulq $0x70, %rax, %rax
addq %rax, %rcx
movq %rcx, -0xf8(%rbp)
subq $0x70, %rsp
movups 0x60(%rcx), %xmm0
movq %rsp, %rax
movups %xmm0, 0x60(%rax)
movups 0x50(%rcx), %xmm0
movups %xmm0, 0x50(%rax)
movups 0x40(%rcx), %xmm0
movups %xmm0, 0x40(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups 0x30(%rcx), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x54630
addq $0x70, %rsp
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
jne 0x542dd
jmp 0x5432b
imull $0x3, -0x34(%rbp), %eax
movl %eax, -0x40(%rbp)
movl $0x0, -0x3c(%rbp)
cmpl $0x3, -0x3c(%rbp)
jge 0x54329
movq -0xe8(%rbp), %rax
movq -0x90(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
cvtsd2ss %xmm0, %xmm0
movslq -0x40(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x542eb
jmp 0x5432b
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x54250
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x543c4
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x5439d
movq -0xe8(%rbp), %rax
movq 0x18(%rbp), %rcx
movslq -0x34(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x3c(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm0
movslq -0x3c(%rbp), %rcx
mulss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x54357
movq -0xe0(%rbp), %rax
movsd -0x70(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movslq -0x34(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x54340
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x54471
movq 0x30(%rbp), %rax
movslq -0x38(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x543e7
jmp 0x54463
movq 0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xa8(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x5444a
movq -0xe0(%rbp), %rax
movq -0xa8(%rbp), %rcx
movslq -0x34(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm0
movslq -0x34(%rbp), %rcx
mulss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x54409
movq -0xd8(%rbp), %rax
movsd -0x70(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movslq -0x38(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x543cb
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x5449e
movq -0xf0(%rbp), %rax
movslq -0x34(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x54478
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x54557
movq 0x30(%rbp), %rax
movslq -0x38(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x544c4
jmp 0x54549
movq -0xd8(%rbp), %rax
movq 0x28(%rbp), %rcx
movslq -0x38(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq %rcx, -0xb0(%rbp)
movslq -0x38(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movq 0x20(%rbp), %rax
movslq -0x38(%rbp), %rcx
divss (%rax,%rcx,4), %xmm0
movss %xmm0, -0xb4(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x54547
movq -0xf0(%rbp), %rax
movss -0xb4(%rbp), %xmm0
movq -0xb0(%rbp), %rcx
movslq -0x34(%rbp), %rdx
mulss (%rcx,%rdx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movslq -0x34(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x54503
jmp 0x54549
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x544a5
movq 0x58(%rbp), %rdi
movl -0x2c(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x1bf00
movq -0xf0(%rbp), %rdx
movq 0x58(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0x1c(%rbp), %ecx
callq 0x1c4f0
movl $0x3, -0x40(%rbp)
movl $0x1, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x54604
movq 0x58(%rbp), %rax
movq 0x10(%rbp), %rcx
movslq -0x34(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0xc0, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
movl $0x0, -0x3c(%rbp)
cmpl $0x3, -0x3c(%rbp)
jge 0x545f7
movq -0xc0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd 0x8(%rax,%rcx,8), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x10(%rbp), %rax
movslq -0x40(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x545bb
jmp 0x545f9
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5458b
movl $0x0, -0x4(%rbp)
movl $0x1, -0x9c(%rbp)
movq -0x48(%rbp), %rax
movq %rax, %rsp
movl -0x4(%rbp), %eax
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)