// File: /workspace/github_c_makefile_star2_O3/ugobas[P]tnm/kinetic_tnm.c
// Function: Test_Eckart
int Test_Eckart(float *Cart_dev, atom *atoms, int N_atoms,
		 struct Reference Ref, int mode, struct axe *axe)
{
  // r_sum = sum_i m_i Delta_r_i
  // r_rot = sum_i r_i X Delta_r_i
  double r_sum[3], r_rot_sum[3], norm=0;
  double r_rot[3], r1=0, r2=0, x[3];
  int iref, j, jj=0;
  for(j=0; j<3; j++){r_sum[j]=0; r_rot_sum[j]=0;}
  for(iref=0; iref< Ref.N_ref; iref++){
    atom *atom1=atoms+Ref.atom_num[iref];
    double m = Ref.mass_atom[iref];
    for(j=0; j<3; j++){x[j]=Cart_dev[jj]; r_sum[j]+=m*x[j]; jj++;}
    Vector_product_d(r_rot, atom1->r, x);
    for(j=0; j<3; j++)r_rot_sum[j]+=m*r_rot[j];
    norm+=m;
  }
  for(j=0; j<3; j++){
    r1+= r_sum[j]*r_sum[j];
    r2+= r_rot_sum[j]*r_rot_sum[j];
  }
  r1=sqrt(r1)/norm; r2=sqrt(r2)/norm;
  if((r1>0.001)||(r2>0.001)){
    printf("%3d %c <d>= %.8f <r_X_d>= %.8f\n", mode, axe->type, r1, r2);
    return(1);
  }
  return(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %r8, 0x38(%rsp)
movl %ecx, 0xc(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdi, 0x40(%rsp)
xorpd %xmm2, %xmm2
movapd %xmm2, 0x70(%rsp)
xorl %eax, %eax
movq %rax, 0x80(%rsp)
movapd %xmm2, 0x50(%rsp)
movq %rax, 0x60(%rsp)
movslq 0x100(%rsp), %rbx
testq %rbx, %rbx
jle 0x23006
leaq 0x100(%rsp), %rax
movq 0x10(%rax), %r14
movq 0x28(%rax), %r13
xorpd %xmm1, %xmm1
xorl %ebp, %ebp
xorl %r15d, %r15d
movapd %xmm1, 0x20(%rsp)
xorps %xmm1, %xmm1
cvtss2sd (%r14,%rbp,4), %xmm1
movslq (%r13,%rbp,4), %rax
movslq %r15d, %r15
movq 0x40(%rsp), %rcx
leaq (%rcx,%r15,4), %rcx
xorl %r12d, %r12d
xorps %xmm0, %xmm0
cvtss2sd (%rcx,%r12,4), %xmm0
movsd %xmm0, 0x90(%rsp,%r12,8)
mulsd %xmm1, %xmm0
addsd 0x70(%rsp,%r12,8), %xmm0
movsd %xmm0, 0x70(%rsp,%r12,8)
incq %r12
cmpq $0x3, %r12
jne 0x22f6b
imulq $0x70, %rax, %rsi
addq 0x48(%rsp), %rsi
leaq 0xb0(%rsp), %rdi
leaq 0x90(%rsp), %rdx
movsd %xmm1, 0x10(%rsp)
callq 0x103bb
movsd 0x10(%rsp), %xmm2
addq %r12, %r15
xorl %eax, %eax
movsd 0xb0(%rsp,%rax,8), %xmm0
mulsd %xmm2, %xmm0
addsd 0x50(%rsp,%rax,8), %xmm0
movsd %xmm0, 0x50(%rsp,%rax,8)
incq %rax
cmpq $0x3, %rax
jne 0x22fc8
movapd 0x20(%rsp), %xmm1
addsd %xmm2, %xmm1
incq %rbp
cmpq %rbx, %rbp
xorpd %xmm2, %xmm2
jne 0x22f48
jmp 0x2300a
xorpd %xmm1, %xmm1
xorl %eax, %eax
movsd 0x50(%rsp,%rax,8), %xmm0
movhpd 0x70(%rsp,%rax,8), %xmm0 # xmm0 = xmm0[0],mem[0]
mulpd %xmm0, %xmm0
addpd %xmm0, %xmm2
incq %rax
cmpq $0x3, %rax
jne 0x2300c
movapd %xmm2, %xmm0
unpckhpd %xmm2, %xmm0            # xmm0 = xmm0[1],xmm2[1]
xorpd %xmm4, %xmm4
ucomisd %xmm4, %xmm0
movapd %xmm1, 0x20(%rsp)
jb 0x23047
sqrtsd %xmm0, %xmm3
jmp 0x23060
movapd %xmm2, 0x10(%rsp)
callq 0x22a0
xorpd %xmm4, %xmm4
movapd 0x10(%rsp), %xmm2
movapd %xmm0, %xmm3
ucomisd %xmm4, %xmm2
jb 0x2306f
xorps %xmm1, %xmm1
sqrtsd %xmm2, %xmm1
jmp 0x23088
movapd %xmm2, %xmm0
movapd %xmm3, 0x10(%rsp)
callq 0x22a0
movapd 0x10(%rsp), %xmm3
movapd %xmm0, %xmm1
movapd 0x20(%rsp), %xmm0
unpcklpd %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0]
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm1
movapd 0x3551e(%rip), %xmm0    # 0x585c0
cmpltpd %xmm1, %xmm0
movmskpd %xmm0, %ecx
xorl %eax, %eax
testl %ecx, %ecx
je 0x230d8
movq 0x38(%rsp), %rax
movsbl (%rax), %edx
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
leaq 0x35800(%rip), %rdi     # 0x588c8
movl 0xc(%rsp), %esi
movb $0x2, %al
callq 0x20f0
movl $0x1, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq