// File: /workspace/github_c_makefile_star2_O3/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, 0xc(%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 0x6287f(%rip), %rax     # 0x792d8
movl %ebp, (%rax)
movslq %ebp, %rax
imulq $0xc8, %rax, %rdi
callq 0x21e0
testq %rax, %rax
je 0x16dcf
leaq 0x525ee(%rip), %rbp     # 0x69068
movss (%rbp), %xmm0
movss 0x3a695(%rip), %xmm1    # 0x5111c
ucomiss %xmm0, %xmm1
ja 0x16de1
movq %rax, %r15
leaq 0x5264e(%rip), %rax     # 0x690e8
cmpl $0x0, (%rax)
je 0x16ac7
leaq 0x3e6f0(%rip), %rsi     # 0x55196
movss 0x403f6(%rip), %xmm0    # 0x56ea4
movq %r15, %rdi
movq %r12, %rdx
movl 0xc(%rsp), %ecx
movl 0x8(%rsp), %r8d
callq 0x16dfd
jmp 0x16c84
movzbl (%r13), %eax
cmpl $0x4c, %eax
jg 0x16b23
cmpl $0x43, %eax
je 0x16b74
cmpl $0x48, %eax
jne 0x16c47
cmpb $0x59, 0x1(%r13)
jne 0x16af5
cmpb $0x44, 0x2(%r13)
je 0x16c71
cmpb $0x42, 0x1(%r13)
jne 0x16c47
leaq 0x51aed(%rip), %rax     # 0x685f4
movss (%rax), %xmm1
movq %r15, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x17d52
jmp 0x16c84
cmpl $0x4d, %eax
je 0x16ba2
cmpl $0x53, %eax
jne 0x16c47
cmpb $0x43, 0x1(%r13)
jne 0x16b3f
cmpb $0x41, 0x2(%r13)
je 0x16b55
cmpb $0x43, 0x1(%r13)
jne 0x16be0
cmpb $0x42, 0x2(%r13)
jne 0x16be0
leaq 0x525d4(%rip), %r8      # 0x69130
movq %r15, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x171ac
jmp 0x16c84
cmpb $0x41, 0x1(%r13)
je 0x16b86
cmpb $0x42, 0x1(%r13)
jne 0x16c47
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
movl 0xc(%rsp), %ecx
movl 0x8(%rsp), %r8d
callq 0x17000
jmp 0x16c84
cmpb $0x49, 0x1(%r13)
jne 0x16c47
cmpb $0x4e, 0x2(%r13)
jne 0x16c47
leaq 0x5252d(%rip), %rax     # 0x690ec
cmpl $0x1, (%rax)
je 0x16c71
movq %r15, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x178e3
jmp 0x16c84
cmpb $0x43, 0x1(%r13)
jne 0x16c0f
cmpb $0x52, 0x2(%r13)
jne 0x16c0f
leaq 0x524ef(%rip), %rax     # 0x690e4
movss (%rax), %xmm1
movq %r15, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
movl $0x3, %r8d
jmp 0x16c40
cmpb $0x48, 0x1(%r13)
jne 0x16c47
cmpb $0x41, 0x2(%r13)
jne 0x16c47
leaq 0x524b8(%rip), %rax     # 0x690dc
movl (%rax), %r8d
leaq 0x524b6(%rip), %rax     # 0x690e4
movss (%rax), %xmm1
movq %r15, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x1f6f0
jmp 0x16c84
leaq 0x402eb(%rip), %rdi     # 0x56f39
movq %r13, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x4060a(%rip), %rdi     # 0x57269
callq 0x2090
movl $0x4e494d, (%r13)       # imm = 0x4E494D
movss (%rbp), %xmm0
movq %r15, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x1760c
movq 0x10(%rsp), %rbp
movl %eax, (%r14)
leaq 0x402ce(%rip), %rdi     # 0x56f61
movl %eax, %esi
movq %r13, %rdx
xorl %eax, %eax
callq 0x20f0
movslq (%r14), %rax
testq %rax, %rax
jle 0x16ce1
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 0x16cb0
leaq 0x523f8(%rip), %rax     # 0x690e0
cmpl $0x0, (%rax)
je 0x16d1f
cmpb $0x53, (%r13)
jne 0x16d1f
cmpb $0x43, 0x1(%r13)
jne 0x16d02
cmpb $0x52, 0x2(%r13)
je 0x16d10
cmpb $0x48, 0x1(%r13)
jne 0x16d1f
cmpb $0x41, 0x2(%r13)
jne 0x16d1f
movq %r14, %rdi
movq %r15, %rsi
movl 0x8(%rsp), %edx
callq 0x1819f
movss 0x51b15(%rip), %xmm0    # 0x6883c
leaq 0x52346(%rip), %rax     # 0x69074
movss %xmm0, (%rax)
cmpb $0x43, (%r13)
jne 0x16d4a
cmpb $0x41, 0x1(%r13)
je 0x16d5c
cmpb $0x42, 0x1(%r13)
sete %cl
jmp 0x16d4c
xorl %ecx, %ecx
testb %cl, %cl
jne 0x16d5c
leaq 0x52391(%rip), %rcx     # 0x690e8
cmpl $0x0, (%rcx)
je 0x16d68
movss 0x51ad4(%rip), %xmm0    # 0x68838
movss %xmm0, (%rax)
movl (%r14), %esi
movq %r15, %rdi
movq %rbp, %rdx
callq 0x182fb
movslq (%r14), %r12
imulq $0xc8, %r12, %rdi
callq 0x21e0
movq %rax, (%rbx)
testq %r12, %r12
jle 0x16db9
xorl %r12d, %r12d
xorl %r13d, %r13d
movq (%rbx), %rdi
addq %r12, %rdi
leaq (%r15,%r12), %rsi
movl $0xc8, %edx
callq 0x21b0
incq %r13
movslq (%r14), %rax
addq $0xc8, %r12
cmpq %rax, %r13
jl 0x16d93
movq %r15, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2050
leaq 0x4011a(%rip), %rdi     # 0x56ef0
movl %ebp, %esi
xorl %eax, %eax
callq 0x20f0
jmp 0x16df3
cvtss2sd %xmm0, %xmm0
leaq 0x4013c(%rip), %rdi     # 0x56f28
movb $0x1, %al
callq 0x20f0
movl $0x8, %edi
callq 0x2280