// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/allostery.c
// Function: Test_pairs
int Test_pairs(struct site_results *res, int *atom_site,
	       float *profile, float **coupling, int Na,
	       int *coupled_site, int **coupled_site_ran, int numran,
	       int ni, int nij, int *atomres)
{

  int n_not=0;

  // Observed site
  double c_ave, c_dev;
  int n_notfound=0;
  c_ave=Pair_site(&c_dev, &n_notfound,
		  coupled_site, ni, nij, atomres, atom_site, coupling, Na);
  if(n_notfound){
    printf("WARNING in Test_pairs, %d reference atoms not found\n",
	   n_notfound);
  }
      
  // Sum over num random sites 
  double ran_pair1=0, ran_pair2=0;
  int num_c_gt=0;
  for(int kran=0; kran<numran; kran++){
    double ave_pair, sigpair;
    ave_pair=Pair_site(&sigpair, &n_notfound,
		       coupled_site_ran[kran], ni, nij,
		       atomres, NULL, coupling, Na);
    if(ave_pair > c_ave)num_c_gt++;
    ran_pair1+=ave_pair;
    ran_pair2+=ave_pair*ave_pair;
    n_not+=n_notfound;
  }
  if(n_not)
    printf("WARNING, %d atoms not found in %d random sites\n",
	   n_not, numran);
  
  Ave_St_dev(&ran_pair1, &ran_pair2, numran);
  float Z_c=(c_ave-ran_pair1);
  if(ran_pair2)Z_c/=ran_pair2;
  res->coup=c_ave; res->Z_c=Z_c; res->P_c= (float)num_c_gt/numran;
  return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq 0x30(%rbp), %rax
movl 0x28(%rbp), %eax
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x4c(%rbp)
movq -0x30(%rbp), %rdx
movl 0x20(%rbp), %ecx
movl 0x28(%rbp), %r8d
movq 0x30(%rbp), %r9
movq -0x10(%rbp), %r11
movq -0x20(%rbp), %r10
movl -0x24(%rbp), %eax
leaq -0x48(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x66bd0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x66a56
movl -0x4c(%rbp), %esi
leaq 0x1bdc9(%rip), %rdi     # 0x82818
movb $0x0, %al
callq 0x10d0
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl 0x18(%rbp), %eax
jge 0x66b1f
movq 0x10(%rbp), %rax
movslq -0x68(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movl 0x20(%rbp), %ecx
movl 0x28(%rbp), %r8d
movq 0x30(%rbp), %r9
movq -0x20(%rbp), %r10
movl -0x24(%rbp), %eax
leaq -0x78(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
xorl %r11d, %r11d
movq $0x0, (%rsp)
movq %r10, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x66bd0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x70(%rbp), %xmm0
ucomisd -0x40(%rbp), %xmm0
jbe 0x66add
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
movsd -0x70(%rbp), %xmm0
addsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x70(%rbp), %xmm0
movsd -0x70(%rbp), %xmm2
movsd -0x60(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movl -0x4c(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x66a74
cmpl $0x0, -0x34(%rbp)
je 0x66b39
movl -0x34(%rbp), %esi
movl 0x18(%rbp), %edx
leaq 0x1bcb6(%rip), %rdi     # 0x827e8
movb $0x0, %al
callq 0x10d0
movl 0x18(%rbp), %edx
leaq -0x58(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x66900
movsd -0x40(%rbp), %xmm0
subsd -0x58(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x7c(%rbp)
movsd -0x60(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x66b6e
jp 0x66b6e
jmp 0x66b89
movsd -0x60(%rbp), %xmm1
movss -0x7c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x7c(%rbp)
movsd -0x40(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0xc(%rax)
movss -0x7c(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x14(%rax)
cvtsi2ssl -0x64(%rbp), %xmm0
cvtsi2ssl 0x18(%rbp), %xmm1
divss %xmm1, %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x10(%rax)
xorl %eax, %eax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax,%rax)