// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movss %xmm0, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movss -0x14(%rbp), %xmm0
mulss -0x14(%rbp), %xmm0
movss %xmm0, -0x4c(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x1f7e3
movq -0x20(%rbp), %rdi
movl -0x58(%rbp), %edx
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %r8
leaq -0x30(%rbp), %rsi
callq 0x214a0
cmpl $0x0, %eax
jge 0x1f589
jmp 0x1f7d5
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x1f7d3
movq -0x20(%rbp), %rdi
movl -0x5c(%rbp), %edx
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %r8
leaq -0x34(%rbp), %rsi
callq 0x214a0
cmpl $0x0, %eax
jge 0x1f5db
jmp 0x1f7c5
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movsd (%rax), %xmm0
movq -0x40(%rbp), %rax
subsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x50(%rbp)
movss -0x50(%rbp), %xmm0
mulss -0x50(%rbp), %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x54(%rbp), %xmm0
ucomiss -0x4c(%rbp), %xmm0
jbe 0x1f626
jmp 0x1f7c5
movq -0x48(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x40(%rbp), %rax
subsd 0x8(%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x50(%rbp)
movss -0x50(%rbp), %xmm0
movss -0x50(%rbp), %xmm2
movss -0x54(%rbp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x54(%rbp), %xmm0
ucomiss -0x4c(%rbp), %xmm0
jbe 0x1f66d
jmp 0x1f7c5
movq -0x48(%rbp), %rax
movsd 0x10(%rax), %xmm0
movq -0x40(%rbp), %rax
subsd 0x10(%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x50(%rbp)
movss -0x50(%rbp), %xmm0
movss -0x50(%rbp), %xmm2
movss -0x54(%rbp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x54(%rbp), %xmm0
ucomiss -0x4c(%rbp), %xmm0
jbe 0x1f6b4
jmp 0x1f7c5
movl -0x30(%rbp), %ecx
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rdx
imulq $0xc8, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x34(%rbp), %ecx
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rdx
imulq $0xc8, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movss -0x54(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x1220
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0xc8, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x20(%rax)
movss 0x5c8dc(%rip), %xmm0    # 0x7bfec
ucomiss -0x54(%rbp), %xmm0
jb 0x1f755
movss -0x54(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x1220
movsd 0x5c8e4(%rip), %xmm1    # 0x7c010
mulsd %xmm1, %xmm0
movsd 0x5c8e0(%rip), %xmm1    # 0x7c018
addsd %xmm1, %xmm0
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0xc8, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x28(%rax)
jmp 0x1f791
movss -0x54(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x5c8a2(%rip), %xmm1    # 0x7c008
callq 0x1080
movaps %xmm0, %xmm1
movsd 0x5c88a(%rip), %xmm0    # 0x7c000
mulsd %xmm1, %xmm0
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0xc8, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x28(%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
leaq 0x7caf4(%rip), %rcx     # 0x9c298
cmpl (%rcx), %eax
jl 0x1f7c3
movl -0x2c(%rbp), %esi
leaq 0x5c929(%rip), %rdi     # 0x7c0db
movb $0x0, %al
callq 0x10d0
movl $0x8, %edi
callq 0x1210
jmp 0x1f7c5
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x1f5ae
jmp 0x1f7d5
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x1f55c
movl -0x2c(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)