// File: /workspace/github_c_makefile_star2_O3/ugobas[P]tnm/anharmonic_tnm.c
// Function: Interactions_CA
int Interactions_CA(struct interaction *Int_list, float thr,
		    atom *atoms, int natoms, int N_res, float *coord)
{
  int N_int=0, i1=0;
  float thr2=thr*thr, d, d2;

  for(int res1=0; res1<N_res; res1++){

    if(Find_CA(atoms, &i1, res1, natoms)< 0)continue;
    float *r1=coord+3*i1; atom *atom1=atoms+i1;
    int i2=i1+1;

    for(int res2=res1+1; res2<N_res; res2++){
      if(Find_CA(atoms, &i2, res2, natoms)< 0)continue;
      float *r2=coord+3*i2; atom *atom2=atoms+i2;

      int n=nat_res1_res2[atom1->res][atom2->res];

      // Interatomic distance
      d=r2[0]-r1[0]; d2 =d*d; if((d2>thr2)&&(n<0))continue;
      d=r2[1]-r1[1]; d2+=d*d; if((d2>thr2)&&(n<0))continue;
      d=r2[2]-r1[2]; d2+=d*d; if((d2>thr2)&&(n<0))continue;

      // store interaction
      Int_list[N_int].i1=i1; Int_list[N_int].i2=i2; N_int++;
      if(N_int >= INT_MAX){
	printf("ERROR, too many interactions %d\n", N_int);
	printf("%d residues, Threshold= %.2f\n", N_res, thr);
	exit(8);
      }
    }
  }
  return(N_int);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, 0x28(%rsp)
movl $0x0, 0x1c(%rsp)
testl %ecx, %ecx
jle 0x1b60f
movq %r8, %r14
movl %edx, %ebp
movq %rsi, %r12
movl %ecx, %r15d
movaps %xmm0, %xmm1
mulss %xmm0, %xmm1
movss %xmm1, 0xc(%rsp)
movq $0x0, 0x10(%rsp)
xorl %r13d, %r13d
movss %xmm0, 0x20(%rsp)
movq %r12, %rdi
leaq 0x1c(%rsp), %rsi
movl %r13d, %edx
movl %ebp, %ecx
callq 0x1c1e4
testl %eax, %eax
js 0x1b601
movl 0x1c(%rsp), %ecx
leal 0x1(%rcx), %eax
movl %eax, 0x18(%rsp)
incl %r13d
cmpl %r15d, %r13d
movl %r13d, 0x24(%rsp)
jge 0x1b5fa
movq %rcx, 0x30(%rsp)
movslq %ecx, %rax
leaq (%rax,%rax,2), %rbx
movq 0x5ddc3(%rip), %rcx     # 0x792d0
movq %rcx, 0x40(%rsp)
imulq $0x70, %rax, %rax
addq %r12, %rax
addq $0x64, %rax
movq %rax, 0x38(%rsp)
movq %r12, %rdi
leaq 0x18(%rsp), %rsi
movl %r13d, %edx
movl %ebp, %ecx
callq 0x1c1e4
testl %eax, %eax
js 0x1b5ee
movslq 0x18(%rsp), %rax
leaq (%rax,%rax,2), %rdx
movq 0x38(%rsp), %rcx
movslq (%rcx), %rcx
movq 0x40(%rsp), %rsi
movq (%rsi,%rcx,8), %rcx
imulq $0x70, %rax, %rsi
movslq 0x64(%r12,%rsi), %rsi
movss (%r14,%rdx,4), %xmm1
subss (%r14,%rbx,4), %xmm1
movl (%rcx,%rsi,4), %ecx
mulss %xmm1, %xmm1
ucomiss 0xc(%rsp), %xmm1
jbe 0x1b57d
testl %ecx, %ecx
js 0x1b5ee
movss 0x4(%r14,%rdx,4), %xmm0
subss 0x4(%r14,%rbx,4), %xmm0
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
ucomiss 0xc(%rsp), %xmm0
jbe 0x1b59e
testl %ecx, %ecx
js 0x1b5ee
movss 0x8(%r14,%rdx,4), %xmm1
subss 0x8(%r14,%rbx,4), %xmm1
mulss %xmm1, %xmm1
addss %xmm0, %xmm1
ucomiss 0xc(%rsp), %xmm1
jbe 0x1b5bf
testl %ecx, %ecx
js 0x1b5ee
movq 0x10(%rsp), %rdx
movslq %edx, %rdx
imulq $0xc8, %rdx, %rcx
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdi
movl %edi, (%rsi,%rcx)
movl %eax, 0x4(%rsi,%rcx)
incl %edx
movq %rdx, 0x10(%rsp)
cmpl 0x5dcec(%rip), %edx     # 0x792d8
jge 0x1b62c
incl %r13d
cmpl %r13d, %r15d
jne 0x1b522
movl 0x24(%rsp), %r13d
jmp 0x1b604
incl %r13d
cmpl %r15d, %r13d
jne 0x1b4c4
jmp 0x1b618
movq $0x0, 0x10(%rsp)
movq 0x10(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3b950(%rip), %rdi     # 0x56f83
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x20f0
xorps %xmm0, %xmm0
cvtss2sd 0x20(%rsp), %xmm0
leaq 0x3c2a2(%rip), %rdi     # 0x578f1
movl %r15d, %esi
movb $0x1, %al
callq 0x20f0
movl $0x8, %edi
callq 0x2280