// File: /workspace/github_c_makefile_star2_O1/ugobas[P]tnm/interactions_tnm.c
// Function: Interactions
int Interactions(struct interaction *Int_list, char *atom_type, float thr,
		 atom *atoms, int N_atoms, int N_res)
{
  int N_int=0, i1=0, i2;
  atom *atom1=atoms, *atom2;
  float thr2=thr*thr;
  //float t_max2=t_max+22; t_max2*=t_max2;
  float d, d2;
  int res1, res2;

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

    if(Find_atom(atoms, &i1, res1, N_atoms, atom_type)< 0)continue;
    atom1=atoms+i1; i2=i1+1;

    for(res2=res1+1; res2<N_res; res2++){
      if(Find_atom(atoms, &i2, res2, N_atoms, atom_type)< 0)continue;
      atom2=atoms+i2;

      // Interatomic distance
      d=atom2->r[0]-atom1->r[0]; d2 =d*d; if(d2>thr2)continue;
      d=atom2->r[1]-atom1->r[1]; d2+=d*d; if(d2>thr2)continue;
      d=atom2->r[2]-atom1->r[2]; d2+=d*d; if(d2>thr2)continue;

      // store interaction
      Int_list[N_int].i1=i1; Int_list[N_int].i2=i2;
      Int_list[N_int].r0=sqrt(d2); Int_list[N_int].sec_der=1;
      N_int++;
      if(N_int >= INT_MAX){
	printf("ERROR, too many interactions %d\n", N_int); exit(8);
      }

    }
  }
  return(N_int);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, 0x28(%rsp)
movq %rdi, 0x20(%rsp)
movl $0x0, 0x14(%rsp)
testl %r8d, %r8d
jle 0x1788d
movl %r8d, %ebx
movl %ecx, %ebp
movq %rdx, %r14
mulss %xmm0, %xmm0
movss %xmm0, 0x1c(%rsp)
xorl %r12d, %r12d
movl $0x0, 0xc(%rsp)
movl %ecx, 0x18(%rsp)
movq %r14, %rdi
leaq 0x14(%rsp), %rsi
movl %r12d, %edx
movl %ebp, %ecx
movq 0x28(%rsp), %r8
callq 0x18d9f
testl %eax, %eax
movq %r12, 0x30(%rsp)
js 0x1787a
movslq 0x14(%rsp), %rdx
leal 0x1(%rdx), %eax
movl %eax, 0x10(%rsp)
leal 0x1(%r12), %r13d
cmpl %ebx, %r13d
jge 0x1787a
imulq $0x70, %rdx, %r12
addq %r14, %r12
movq %rdx, %r15
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
movl %r13d, %edx
movl %ebp, %ecx
movq 0x28(%rsp), %r8
callq 0x18d9f
testl %eax, %eax
js 0x177c0
movslq 0x10(%rsp), %rax
imulq $0x70, %rax, %rcx
movsd (%r14,%rcx), %xmm0
subsd (%r12), %xmm0
cvtsd2ss %xmm0, %xmm0
mulss %xmm0, %xmm0
movss 0x1c(%rsp), %xmm2
ucomiss %xmm2, %xmm0
jbe 0x177d0
movq %r15, %rdx
incl %r13d
cmpl %r13d, %ebx
jne 0x1777a
jmp 0x1787a
addq %r14, %rcx
movsd 0x8(%rcx), %xmm1
subsd 0x8(%r12), %xmm1
cvtsd2ss %xmm1, %xmm1
mulss %xmm1, %xmm1
addss %xmm0, %xmm1
ucomiss %xmm2, %xmm1
movq %r15, %rdx
ja 0x177c3
movsd 0x10(%rcx), %xmm0
subsd 0x10(%r12), %xmm0
cvtsd2ss %xmm0, %xmm0
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
ucomiss %xmm2, %xmm0
ja 0x177c3
movslq 0xc(%rsp), %rcx
imulq $0xc8, %rcx, %rbp
movq 0x20(%rsp), %rcx
movl %edx, (%rcx,%rbp)
movl %eax, 0x4(%rcx,%rbp)
cvtss2sd %xmm0, %xmm0
ucomisd 0x3982c(%rip), %xmm0    # 0x51060
jb 0x1783c
sqrtsd %xmm0, %xmm0
jmp 0x17844
callq 0x2290
movq %r15, %rdx
addq 0x20(%rsp), %rbp
movsd %xmm0, 0x20(%rbp)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x28(%rbp)
movl 0xc(%rsp), %eax
incl %eax
movl %eax, 0xc(%rsp)
leaq 0x61a6b(%rip), %rcx     # 0x792d8
cmpl (%rcx), %eax
jge 0x178a8
movl 0x18(%rsp), %ebp
jmp 0x177c3
movq 0x30(%rsp), %r12
incl %r12d
cmpl %ebx, %r12d
jne 0x17735
jmp 0x17895
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3f714(%rip), %rdi     # 0x56fc3
movl 0xc(%rsp), %esi
xorl %eax, %eax
callq 0x20f0
movl $0x8, %edi
callq 0x2270