// File: /workspace/github_c_makefile_star2_O1/ugobas[P]tnm/interactions_tnm.c
// Function: Compute_interactions
void Compute_interactions(int *N_int, struct interaction **Int_list,
			  char *INT_TYPE, atom *atoms, int natoms,
			  int nres, char *nameout)
{
  INT_MAX=100*nres;
  struct interaction *Int_tmp=malloc(INT_MAX*sizeof(struct interaction));
  if(Int_tmp==NULL){
    printf("ERROR, no memory available for storing %d interactions\n",
	   INT_MAX); exit(8);
  }
  if(C_THR<1){
    printf("ERROR, Rc= %.2g\n", C_THR); exit(8);
  }

  if(HNM){
    *N_int=Interactions_hnm(Int_tmp, "CA", 20, atoms, natoms, nres);
  }else if((strncmp(INT_TYPE, "CA", 2)==0)||(strncmp(INT_TYPE, "CB", 2)==0)){
    *N_int=Interactions(Int_tmp, INT_TYPE, C_THR, atoms, natoms, nres);
  }else if((strncmp(INT_TYPE, "SCA", 3)==0)||
	   (strncmp(INT_TYPE, "SCB", 3)==0)){
    *N_int=Interactions_all_ref(Int_tmp, C_THR, atoms, natoms, nres, REF);
  }else if(strncmp(INT_TYPE, "MIN", 3)==0){
    if(N_RESRES==1){
      *N_int=Interactions_min(Int_tmp, C_THR, atoms, natoms, nres);
    }else{
      //*N_int=Interactions_all(Int_tmp, C_THR, atoms, natoms, nres);
      *N_int=Interactions_min_M(Int_tmp, C_THR, atoms, natoms, nres);
    }
  }else if(strncmp(INT_TYPE, "HYD", 3)==0){
    *N_int=Interactions_min(Int_tmp, C_THR, atoms, natoms, nres);
    //Heavy_atoms_interactors(Int_tmp, *N_int,atoms);
  }else if(strncmp(INT_TYPE, "SCR", 3)==0){
    *N_int=Screened_Interactions(Int_tmp,C_THR,atoms,natoms,nres,
				 3,S_THR);
  }else if(strncmp(INT_TYPE, "SHA", 3)==0){
    *N_int=Screened_Interactions(Int_tmp,C_THR,atoms,natoms,nres,
				 S_TYPE,S_THR);
  }else if(strncmp(INT_TYPE, "HB", 2)==0){
    *N_int=Interactions_HB(Int_tmp, C_THR, atoms, natoms, nres,
			   DA_THR, COS_DAA, ENE_HB);
  }else{
    printf("WARNING, incorrect interaction type %s\n", INT_TYPE);
    printf("Setting to default MIN\n"); strcpy(INT_TYPE, "MIN");
    *N_int=Interactions_min(Int_tmp, C_THR, atoms, natoms, nres);
  }
  printf("%d interactions of type %s found\n", *N_int, INT_TYPE);

  int k;
  for(k=0; k<*N_int; k++){
    Int_tmp[k].res1=atoms[Int_tmp[k].i1].res;
    Int_tmp[k].res2=atoms[Int_tmp[k].i2].res;
  }

  // Each atoms only interacts once per residue
  if((ONEINT)&&
     ((strncmp(INT_TYPE, "SCR", 3)==0)||(strncmp(INT_TYPE, "SHA", 3)==0))){
    //Purge_interactions_atom_res(N_int, Int_list, nres);
    Purge_interactions_res_pair(N_int, Int_tmp, nres);
  }
 
  C0=C0_MIN;
  if((strncmp(INT_TYPE,"CA",2)==0)||(strncmp(INT_TYPE,"CB",2)==0)||HNM)
    C0=C0_CA;
  Compute_sec_der(Int_tmp, *N_int, nameout);
  //Compute_sec_der(Int_tmp, *N_int, POW, EXP_HESSIAN, C0, C1_THR, C_THR);
  //Compute_sec_der_old(Int_tmp, *N_int, EXP_HESSIAN);

  *Int_list=malloc((*N_int)*sizeof(struct interaction));
  for(k=0; k<*N_int; k++)(*Int_list)[k]=Int_tmp[k];
  free(Int_tmp);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, 0x4(%rsp)
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r14
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movl %r9d, 0x8(%rsp)
imull $0x64, %r9d, %ebp
leaq 0x6227f(%rip), %rax     # 0x792d8
movl %ebp, (%rax)
movslq %ebp, %rax
imulq $0xc8, %rax, %rdi
callq 0x21d0
testq %rax, %rax
je 0x17478
leaq 0x51fee(%rip), %rbp     # 0x69068
movss (%rbp), %xmm1
movss 0x39f89(%rip), %xmm0    # 0x51010
ucomiss %xmm1, %xmm0
ja 0x1748a
movq %rax, %r15
leaq 0x5204e(%rip), %rax     # 0x690e8
cmpl $0x0, (%rax)
je 0x170c9
leaq 0x3e0c4(%rip), %rsi     # 0x5516a
movss 0x3fe36(%rip), %xmm0    # 0x56ee4
movq %r15, %rdi
movq %r12, %rdx
movl 0x4(%rsp), %ecx
movl 0x8(%rsp), %ebp
movl %ebp, %r8d
callq 0x174a9
jmp 0x172e4
movss %xmm1, 0xc(%rsp)
leaq 0x3e094(%rip), %rsi     # 0x5516a
movl $0x2, %edx
movq %r13, %rdi
callq 0x2070
testl %eax, %eax
je 0x171fa
leaq 0x3a0d2(%rip), %rsi     # 0x511c4
movl $0x2, %edx
movq %r13, %rdi
callq 0x2070
testl %eax, %eax
je 0x171fa
leaq 0x3a074(%rip), %rsi     # 0x51182
movl $0x3, %edx
movq %r13, %rdi
callq 0x2070
testl %eax, %eax
je 0x1721e
leaq 0x3a099(%rip), %rsi     # 0x511c3
movl $0x3, %edx
movq %r13, %rdi
callq 0x2070
testl %eax, %eax
je 0x1721e
leaq 0x40176(%rip), %rsi     # 0x572bc
movl $0x3, %edx
movq %r13, %rdi
callq 0x2070
testl %eax, %eax
je 0x17245
leaq 0x3a0fd(%rip), %rsi     # 0x5125f
movl $0x3, %edx
movq %r13, %rdi
callq 0x2070
testl %eax, %eax
je 0x17251
leaq 0x46d25(%rip), %rsi     # 0x5dea3
movl $0x3, %edx
movq %r13, %rdi
callq 0x2070
testl %eax, %eax
je 0x1728b
leaq 0x3a2cb(%rip), %rsi     # 0x51465
movl $0x3, %edx
movq %r13, %rdi
callq 0x2070
testl %eax, %eax
je 0x172b4
leaq 0x3b61b(%rip), %rsi     # 0x527d1
movl $0x2, %edx
movq %r13, %rdi
callq 0x2070
testl %eax, %eax
je 0x1744d
leaq 0x3fda7(%rip), %rdi     # 0x56f79
movq %r13, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x400c6(%rip), %rdi     # 0x572a9
callq 0x2090
movl $0x4e494d, (%r13)       # imm = 0x4E494D
movss (%rbp), %xmm0
movq %r15, %rdi
jmp 0x1725a
movq %r15, %rdi
movq %r13, %rsi
movss 0xc(%rsp), %xmm0
movq %r12, %rdx
movl 0x4(%rsp), %ecx
movl 0x8(%rsp), %ebp
movl %ebp, %r8d
callq 0x176eb
jmp 0x172e4
leaq 0x51f0b(%rip), %r8      # 0x69130
movq %r15, %rdi
movss 0xc(%rsp), %xmm0
movq %r12, %rsi
movl 0x4(%rsp), %edx
movl 0x8(%rsp), %ebp
movl %ebp, %ecx
callq 0x178c4
jmp 0x172e4
leaq 0x51ea0(%rip), %rax     # 0x690ec
cmpl $0x1, (%rax)
jne 0x1726e
movq %r15, %rdi
movss 0xc(%rsp), %xmm0
movq %r12, %rsi
movl 0x4(%rsp), %edx
movl 0x8(%rsp), %ebp
movl %ebp, %ecx
callq 0x17d26
jmp 0x172e4
movq %r15, %rdi
movss 0xc(%rsp), %xmm0
movq %r12, %rsi
movl 0x4(%rsp), %edx
movl 0x8(%rsp), %ebp
movl %ebp, %ecx
callq 0x17ffd
jmp 0x172e4
leaq 0x51e52(%rip), %rax     # 0x690e4
movss (%rax), %xmm1
movq %r15, %rdi
movss 0xc(%rsp), %xmm0
movq %r12, %rsi
movl 0x4(%rsp), %edx
movl 0x8(%rsp), %ebp
movl %ebp, %ecx
movl $0x3, %r8d
jmp 0x172df
leaq 0x51e21(%rip), %rax     # 0x690dc
movl (%rax), %r8d
leaq 0x51e1f(%rip), %rax     # 0x690e4
movss (%rax), %xmm1
movq %r15, %rdi
movss 0xc(%rsp), %xmm0
movq %r12, %rsi
movl 0x4(%rsp), %edx
movl 0x8(%rsp), %ebp
movl %ebp, %ecx
callq 0x1fe44
movl %eax, (%r14)
leaq 0x3fcb3(%rip), %rdi     # 0x56fa1
movl %eax, %esi
movq %r13, %rdx
xorl %eax, %eax
callq 0x20f0
movslq (%r14), %rax
testq %rax, %rax
jle 0x1733c
imulq $0xc8, %rax, %rax
xorl %ecx, %ecx
movslq (%r15,%rcx), %rdx
imulq $0x70, %rdx, %rdx
movl 0x64(%r12,%rdx), %edx
movl %edx, 0x8(%r15,%rcx)
movslq 0x4(%r15,%rcx), %rdx
imulq $0x70, %rdx, %rdx
movl 0x64(%r12,%rdx), %edx
movl %edx, 0xc(%r15,%rcx)
addq $0xc8, %rcx
cmpq %rcx, %rax
jne 0x1730b
leaq 0x51d9d(%rip), %rax     # 0x690e0
cmpl $0x0, (%rax)
je 0x17385
leaq 0x46b54(%rip), %rsi     # 0x5dea3
movl $0x3, %edx
movq %r13, %rdi
callq 0x2070
testl %eax, %eax
je 0x17378
leaq 0x3a0fe(%rip), %rsi     # 0x51465
movl $0x3, %edx
movq %r13, %rdi
callq 0x2070
testl %eax, %eax
jne 0x17385
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x188c2
movss 0x514af(%rip), %xmm0    # 0x6883c
leaq 0x51ce0(%rip), %r12     # 0x69074
movss %xmm0, (%r12)
leaq 0x3ddc9(%rip), %rsi     # 0x5516a
movl $0x2, %edx
movq %r13, %rdi
callq 0x2070
testl %eax, %eax
je 0x173d6
leaq 0x39e0b(%rip), %rsi     # 0x511c4
movl $0x2, %edx
movq %r13, %rdi
callq 0x2070
testl %eax, %eax
je 0x173d6
leaq 0x51d17(%rip), %rax     # 0x690e8
cmpl $0x0, (%rax)
je 0x173e4
movss 0x5145a(%rip), %xmm0    # 0x68838
movss %xmm0, (%r12)
movl (%r14), %esi
movq %r15, %rdi
movq 0x10(%rsp), %rdx
callq 0x18a1d
movslq (%r14), %r12
imulq $0xc8, %r12, %rdi
callq 0x21d0
movq %rax, (%rbx)
testq %r12, %r12
jle 0x17437
xorl %r12d, %r12d
xorl %r13d, %r13d
movq (%rbx), %rdi
addq %r12, %rdi
leaq (%r15,%r12), %rsi
movl $0xc8, %edx
callq 0x21a0
incq %r13
movslq (%r14), %rax
addq $0xc8, %r12
cmpq %rax, %r13
jl 0x17411
movq %r15, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2050
leaq 0x511a0(%rip), %rax     # 0x685f4
movss (%rax), %xmm1
movq %r15, %rdi
movss 0xc(%rsp), %xmm0
movq %r12, %rsi
movl 0x4(%rsp), %edx
movl 0x8(%rsp), %ebp
movl %ebp, %ecx
callq 0x18452
jmp 0x172e4
leaq 0x3fab1(%rip), %rdi     # 0x56f30
movl %ebp, %esi
xorl %eax, %eax
callq 0x20f0
jmp 0x1749f
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
leaq 0x3fad0(%rip), %rdi     # 0x56f68
movb $0x1, %al
callq 0x20f0
movl $0x8, %edi
callq 0x2270