// File: /workspace/github_c_makefile_star2_O2/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 %r8, %r14
movl %ecx, %ebx
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, 0x28(%rsp)
leaq 0xc(%rsp), %rax
andl $0x0, (%rax)
movss %xmm0, 0x1c(%rsp)
mulss %xmm0, %xmm0
movss %xmm0, 0x4(%rsp)
xorl %r13d, %r13d
testl %ecx, %ecx
movl $0x0, %eax
cmovgl %ecx, %eax
movl %eax, 0x20(%rsp)
movq $0x0, 0x10(%rsp)
cmpl 0x20(%rsp), %r13d
je 0x19db1
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
movl %r13d, %edx
movl %ebp, %ecx
callq 0x1a89f
testl %eax, %eax
js 0x19da9
movslq 0xc(%rsp), %rcx
leaq (%rcx,%rcx,2), %r12
leal 0x1(%rcx), %eax
movl %eax, 0x8(%rsp)
movq 0x5a62d(%rip), %rax     # 0x742d0
movq %rax, 0x40(%rsp)
movq %rcx, 0x30(%rsp)
imulq $0x70, %rcx, %rax
addq %r15, %rax
addq $0x64, %rax
movq %rax, 0x38(%rsp)
movl %r13d, 0x24(%rsp)
incl %r13d
cmpl %ebx, %r13d
jge 0x19da4
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
movl %r13d, %edx
movl %ebp, %ecx
callq 0x1a89f
testl %eax, %eax
js 0x19cc2
movslq 0x8(%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(%r15,%rsi), %rsi
movss (%r14,%rdx,4), %xmm1
subss (%r14,%r12,4), %xmm1
movl (%rcx,%rsi,4), %ecx
mulss %xmm1, %xmm1
ucomiss 0x4(%rsp), %xmm1
jbe 0x19d25
testl %ecx, %ecx
js 0x19cc2
movss 0x4(%r14,%rdx,4), %xmm0
subss 0x4(%r14,%r12,4), %xmm0
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
ucomiss 0x4(%rsp), %xmm0
jbe 0x19d4a
testl %ecx, %ecx
js 0x19cc2
movss 0x8(%r14,%rdx,4), %xmm1
subss 0x8(%r14,%r12,4), %xmm1
mulss %xmm1, %xmm1
addss %xmm0, %xmm1
ucomiss 0x4(%rsp), %xmm1
jbe 0x19d6f
testl %ecx, %ecx
js 0x19cc2
movq 0x10(%rsp), %rsi
movslq %esi, %rsi
imulq $0xc8, %rsi, %rcx
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %rdi
movl %edi, (%rdx,%rcx)
movl %eax, 0x4(%rdx,%rcx)
incl %esi
movq %rsi, 0x10(%rsp)
cmpl 0x5a53c(%rip), %esi     # 0x742d8
jl 0x19cc2
jmp 0x19dc5
movl 0x24(%rsp), %r13d
incl %r13d
jmp 0x19c67
movq 0x10(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x37107(%rip), %rdi     # 0x50ed3
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x20f0
cvtss2sd 0x1c(%rsp), %xmm0
leaq 0x37a6c(%rip), %rdi     # 0x51851
movl %ebx, %esi
movb $0x1, %al
callq 0x20f0
pushq $0x8
popq %rdi
callq 0x2270