// File: /workspace/github_c_makefile_star2_O2/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)
leaq 0x100(%rsp), %rax
xorl %ecx, %ecx
cmpq $0x3, %rcx
je 0x20de3
andq $0x0, 0x70(%rsp,%rcx,8)
andq $0x0, 0x50(%rsp,%rcx,8)
incq %rcx
jmp 0x20dcc
movl (%rax), %ebx
movq 0x28(%rax), %r14
movq 0x10(%rax), %r13
xorl %ebp, %ebp
testl %ebx, %ebx
cmovlel %ebp, %ebx
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
xorl %r15d, %r15d
cmpq %rbx, %rbp
je 0x20ebc
cvtss2sd (%r13,%rbp,4), %xmm1
movslq (%r14,%rbp,4), %rax
movslq %r15d, %r15
movq 0x40(%rsp), %rcx
leaq (%rcx,%r15,4), %rcx
xorl %r12d, %r12d
cmpq $0x3, %r12
je 0x20e51
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
jmp 0x20e24
imulq $0x70, %rax, %rsi
addq 0x48(%rsp), %rsi
leaq 0xb0(%rsp), %rdi
leaq 0x90(%rsp), %rdx
movsd %xmm1, 0x10(%rsp)
callq 0xf8f7
movsd 0x10(%rsp), %xmm1
addq %r12, %r15
xorl %eax, %eax
cmpq $0x3, %rax
je 0x20ea4
movsd 0xb0(%rsp,%rax,8), %xmm0
mulsd %xmm1, %xmm0
addsd 0x50(%rsp,%rax,8), %xmm0
movsd %xmm0, 0x50(%rsp,%rax,8)
incq %rax
jmp 0x20e80
movapd 0x20(%rsp), %xmm0
addsd %xmm1, %xmm0
movapd %xmm0, 0x20(%rsp)
incq %rbp
jmp 0x20e01
xorpd %xmm1, %xmm1
xorl %eax, %eax
cmpq $0x3, %rax
je 0x20ee1
movsd 0x70(%rsp,%rax,8), %xmm0
movhpd 0x50(%rsp,%rax,8), %xmm0 # xmm0 = xmm0[0],mem[0]
mulpd %xmm0, %xmm0
addpd %xmm0, %xmm1
incq %rax
jmp 0x20ec2
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jb 0x20ef1
sqrtsd %xmm1, %xmm0
jmp 0x20f0a
movapd %xmm1, %xmm0
movapd %xmm1, 0x10(%rsp)
callq 0x2290
xorpd %xmm2, %xmm2
movapd 0x10(%rsp), %xmm1
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
ucomisd %xmm2, %xmm1
jb 0x20f1a
sqrtsd %xmm1, %xmm1
jmp 0x20f33
movapd %xmm0, 0x10(%rsp)
movapd %xmm1, %xmm0
callq 0x2290
movapd %xmm0, %xmm1
movapd 0x10(%rsp), %xmm0
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movapd 0x20(%rsp), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm1
movapd 0x315d3(%rip), %xmm0    # 0x52520
cmpltpd %xmm1, %xmm0
movmskpd %xmm0, %ecx
xorl %eax, %eax
testl %ecx, %ecx
je 0x20f81
movq 0x38(%rsp), %rax
movsbl (%rax), %edx
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
leaq 0x318b5(%rip), %rdi     # 0x52828
movl 0xc(%rsp), %esi
movb $0x2, %al
callq 0x20f0
pushq $0x1
popq %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq