// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/nma.c
// Function: Convert_torsion2cart_old
void Convert_torsion2cart_old(float *Cart_mode, atom *atoms, float *u_a,
			  struct axe *axes, int N_axes, int *atom_ref,
			  int N_ref, struct Jacobian *J)
{
  // Computing derivative:
  // dr_ia ~ (sum_k u_a,k*rot_ik) X r_i + (sum_k u_a,k*shift_ik)

  int  i, j, k, jj;

  double dr_daxe_rot[J->N_Cart], dr_daxe_shift[J->N_Cart];
  for(j=0; j<J->N_Cart; j++){
    dr_daxe_rot[j]=0; dr_daxe_shift[j]=0;
  }
  float *u_ak=u_a;
  struct axe *axe=axes;
  for(k=0; k<N_axes; k++){
    jj=0;
    for(i=0; i<N_ref; i++){
      if((i>=axe->first_kin)&&(i<=axe->last_kin)){
	for(j=0; j<3; j++){
	  dr_daxe_rot[jj]  +=(*u_ak)*axe->local_rot[j];
	  dr_daxe_shift[jj]+=(*u_ak)*axe->local_shift[j];
	  jj++;
	}
      }else{
	for(j=0; j<3; j++){
	  dr_daxe_rot[jj]  +=(*u_ak)*axe->global_rot[j];
	  dr_daxe_shift[jj]+=(*u_ak)*axe->global_shift[j];
	  jj++;
	}
      }
    }
    u_ak++; axe++;
  }
  
  double r[3], dd[3]; jj=0;
  for(i=0; i<N_ref; i++){
    atom *atom=atoms+atom_ref[i];
    for(j=0; j<3; j++)r[j]= atom->r[j];
    Vector_product_d(dd, dr_daxe_rot+jj, r);
    for(j=0; j<3; j++){
      Cart_mode[jj]=dr_daxe_shift[jj]+dd[j]; jj++;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq 0x18(%rbp), %rax
movl 0x4(%rax), %eax
movq %rsp, %rcx
movq %rcx, -0x48(%rbp)
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xb8(%rbp)
movq %rcx, %rsp
movq %rax, -0x50(%rbp)
movq 0x18(%rbp), %rax
movl 0x4(%rax), %eax
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xb0(%rbp)
movq %rcx, %rsp
movq %rax, -0x58(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq 0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x35a43
movq -0xb0(%rbp), %rax
movq -0xb8(%rbp), %rcx
movslq -0x38(%rbp), %rdx
xorps %xmm0, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
movslq -0x38(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x35a06
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x35c17
movl $0x0, -0x40(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl 0x10(%rbp), %eax
jge 0x35bef
movl -0x34(%rbp), %eax
movq -0x68(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jl 0x35b41
movl -0x34(%rbp), %eax
movq -0x68(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jg 0x35b41
movl $0x0, -0x38(%rbp)
cmpl $0x3, -0x38(%rbp)
jge 0x35b3c
movq -0xb0(%rbp), %rax
movq -0xb8(%rbp), %rcx
movq -0x60(%rbp), %rdx
movss (%rdx), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x68(%rbp), %rdx
movslq -0x38(%rbp), %rsi
movsd 0xd8(%rdx,%rsi,8), %xmm2
movslq -0x40(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
movq -0x60(%rbp), %rcx
movss (%rcx), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x68(%rbp), %rcx
movslq -0x38(%rbp), %rdx
movsd 0xc0(%rcx,%rdx,8), %xmm2
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x35aa7
jmp 0x35bdf
movl $0x0, -0x38(%rbp)
cmpl $0x3, -0x38(%rbp)
jge 0x35bdd
movq -0xb0(%rbp), %rax
movq -0xb8(%rbp), %rcx
movq -0x60(%rbp), %rdx
movss (%rdx), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x68(%rbp), %rdx
movslq -0x38(%rbp), %rsi
movsd 0xa8(%rdx,%rsi,8), %xmm2
movslq -0x40(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
movq -0x60(%rbp), %rcx
movss (%rcx), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x68(%rbp), %rcx
movslq -0x38(%rbp), %rdx
movsd 0x90(%rcx,%rdx,8), %xmm2
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x35b48
jmp 0x35bdf
jmp 0x35be1
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x35a74
movq -0x60(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %rax
addq $0x158, %rax            # imm = 0x158
movq %rax, -0x68(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x35a5a
movl $0x0, -0x40(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl 0x10(%rbp), %eax
jge 0x35d02
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movslq -0x34(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movl $0x0, -0x38(%rbp)
cmpl $0x3, -0x38(%rbp)
jge 0x35c81
movq -0xa8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movslq -0x38(%rbp), %rax
movsd %xmm0, -0x80(%rbp,%rax,8)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x35c56
movq -0xb8(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
movslq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
leaq -0x80(%rbp), %rdx
callq 0x14aa0
movl $0x0, -0x38(%rbp)
cmpl $0x3, -0x38(%rbp)
jge 0x35cf2
movq -0xb0(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movslq -0x38(%rbp), %rax
addsd -0xa0(%rbp,%rax,8), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x8(%rbp), %rax
movslq -0x40(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x35caa
jmp 0x35cf4
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x35c25
movq -0x48(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
nop