// File: /workspace/github_c_makefile_star2_O2/ugobas[P]tnm/interactions_tnm.c
// Function: Interactions_hnm
int Interactions_hnm(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 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);
      if(d2<=4){
	Int_list[N_int].sec_der=205*sqrt(d2)-571.2;
      }else{
	Int_list[N_int].sec_der=305.9*pow(d2, -3);
      }
      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
movl %r8d, %ebx
movl %ecx, %ebp
movq %rdx, %r14
leaq 0x14(%rsp), %rax
andl $0x0, (%rax)
movq %rsi, %r13
movq %rdi, 0x20(%rsp)
mulss %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
movl $0x0, 0x8(%rsp)
testl %r8d, %r8d
movl $0x0, %eax
cmovgl %r8d, %eax
movl %eax, 0x18(%rsp)
xorl %r15d, %r15d
cmpl 0x18(%rsp), %r15d
je 0x15c3e
movq %r14, %rdi
leaq 0x14(%rsp), %rsi
movl %r15d, %edx
movl %ebp, %ecx
movq %r13, %r8
callq 0x1712c
testl %eax, %eax
js 0x15c36
movslq 0x14(%rsp), %rcx
imulq $0x70, %rcx, %r12
addq %r14, %r12
movq %rcx, 0x30(%rsp)
leal 0x1(%rcx), %eax
movl %eax, 0x10(%rsp)
movl %r15d, 0x1c(%rsp)
incl %r15d
cmpl %ebx, %r15d
jge 0x15c31
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
movl %r15d, %edx
movl %ebp, %ecx
movq %r13, %r8
callq 0x1712c
testl %eax, %eax
js 0x15b11
movslq 0x10(%rsp), %rax
imulq $0x70, %rax, %rcx
movsd (%r14,%rcx), %xmm0
subsd (%r12), %xmm0
cvtsd2ss %xmm0, %xmm0
mulss %xmm0, %xmm0
ucomiss 0xc(%rsp), %xmm0
ja 0x15b11
addq %r14, %rcx
movsd 0x8(%rcx), %xmm1
subsd 0x8(%r12), %xmm1
cvtsd2ss %xmm1, %xmm1
mulss %xmm1, %xmm1
addss %xmm0, %xmm1
ucomiss 0xc(%rsp), %xmm1
ja 0x15b11
movsd 0x10(%rcx), %xmm0
subsd 0x10(%r12), %xmm0
cvtsd2ss %xmm0, %xmm2
mulss %xmm2, %xmm2
addss %xmm1, %xmm2
ucomiss 0xc(%rsp), %xmm2
ja 0x15b11
movslq 0x8(%rsp), %rcx
imulq $0xc8, %rcx, %rsi
movq 0x20(%rsp), %rcx
movq 0x30(%rsp), %rdx
movl %edx, (%rcx,%rsi)
movl %eax, 0x4(%rcx,%rsi)
cvtss2sd %xmm2, %xmm1
sqrtsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rcx,%rsi)
movss 0x3b226(%rip), %xmm3    # 0x50df8
ucomiss %xmm2, %xmm3
jae 0x15bfc
movapd %xmm1, %xmm0
movsd 0x3b23d(%rip), %xmm1    # 0x50e20
movq %rsi, 0x28(%rsp)
callq 0x20a0
movq 0x28(%rsp), %rsi
mulsd 0x3b22e(%rip), %xmm0    # 0x50e28
jmp 0x15c0c
mulsd 0x3b20c(%rip), %xmm0    # 0x50e10
addsd 0x3b20c(%rip), %xmm0    # 0x50e18
addq 0x20(%rsp), %rsi
movsd %xmm0, 0x28(%rsi)
movl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x8(%rsp)
leaq 0x5e6b1(%rip), %rcx     # 0x742d8
cmpl (%rcx), %eax
jl 0x15b11
jmp 0x15c51
movl 0x1c(%rsp), %r15d
incl %r15d
jmp 0x15acc
movl 0x8(%rsp), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3b27b(%rip), %rdi     # 0x50ed3
movl 0x8(%rsp), %esi
xorl %eax, %eax
callq 0x20f0
pushq $0x8
popq %rdi
callq 0x2270