// File: /workspace/github_c_makefile_star2_O2/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 0x5ebd7(%rip), %rax     # 0x742d8
movl %ebp, (%rax)
movslq %ebp, %rax
imulq $0xc8, %rax, %rdi
callq 0x21d0
testq %rax, %rax
je 0x15a55
leaq 0x4e946(%rip), %rbp     # 0x64068
movss (%rbp), %xmm0
movss 0x358e1(%rip), %xmm1    # 0x4b010
ucomiss %xmm0, %xmm1
ja 0x15a67
movq %rax, %r15
leaq 0x4e9a6(%rip), %rax     # 0x640e8
cmpl $0x0, (%rax)
je 0x1576f
leaq 0x399a0(%rip), %rsi     # 0x4f0ee
movss 0x3b69e(%rip), %xmm0    # 0x50df4
movq %r15, %rdi
movq %r12, %rdx
movl 0xc(%rsp), %ecx
movl 0x8(%rsp), %r8d
callq 0x15a81
jmp 0x1590b
movzbl (%r13), %eax
cmpl $0x53, %eax
je 0x1583c
cmpl $0x48, %eax
je 0x157be
cmpl $0x4d, %eax
je 0x157fe
cmpl $0x43, %eax
jne 0x158ce
cmpb $0x41, 0x1(%r13)
je 0x157a2
cmpb $0x42, 0x1(%r13)
jne 0x158ce
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
movl 0xc(%rsp), %ecx
movl 0x8(%rsp), %r8d
callq 0x15c6b
jmp 0x1590b
cmpb $0x59, 0x1(%r13)
jne 0x157d0
cmpb $0x44, 0x2(%r13)
je 0x158f8
cmpb $0x42, 0x1(%r13)
jne 0x158ce
leaq 0x4de12(%rip), %rax     # 0x635f4
movss (%rax), %xmm1
movq %r15, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x16884
jmp 0x1590b
cmpb $0x49, 0x1(%r13)
jne 0x158ce
cmpb $0x4e, 0x2(%r13)
jne 0x158ce
leaq 0x4e8d1(%rip), %rax     # 0x640ec
cmpl $0x1, (%rax)
je 0x158f8
movq %r15, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x16498
jmp 0x1590b
cmpb $0x43, 0x1(%r13)
jne 0x1584a
cmpb $0x41, 0x2(%r13)
je 0x15858
cmpb $0x43, 0x1(%r13)
jne 0x15877
cmpb $0x42, 0x2(%r13)
jne 0x15877
leaq 0x4e8d1(%rip), %r8      # 0x64130
movq %r15, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x15e1b
jmp 0x1590b
cmpb $0x43, 0x1(%r13)
jne 0x15896
cmpb $0x52, 0x2(%r13)
jne 0x15896
leaq 0x4e858(%rip), %rax     # 0x640e4
movss (%rax), %xmm1
pushq $0x3
popq %r8
jmp 0x158b9
cmpb $0x48, 0x1(%r13)
jne 0x158ce
cmpb $0x41, 0x2(%r13)
jne 0x158ce
leaq 0x4e831(%rip), %rax     # 0x640dc
movl (%rax), %r8d
leaq 0x4e82f(%rip), %rax     # 0x640e4
movss (%rax), %xmm1
movq %r15, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x1db8c
jmp 0x1590b
leaq 0x3b5b4(%rip), %rdi     # 0x50e89
movq %r13, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x3b8d3(%rip), %rdi     # 0x511b9
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 0x16202
movl %eax, (%r14)
leaq 0x3b59c(%rip), %rdi     # 0x50eb1
xorl %ebp, %ebp
movl %eax, %esi
movq %r13, %rdx
xorl %eax, %eax
callq 0x20f0
movl (%r14), %eax
testl %eax, %eax
cmovlel %ebp, %eax
imulq $0xc8, %rax, %rax
cmpq %rbp, %rax
je 0x15965
movslq (%r15,%rbp), %rcx
imulq $0x70, %rcx, %rcx
movl 0x64(%r12,%rcx), %ecx
movl %ecx, 0x8(%r15,%rbp)
movslq 0x4(%r15,%rbp), %rcx
imulq $0x70, %rcx, %rcx
movl 0x64(%r12,%rcx), %ecx
movl %ecx, 0xc(%r15,%rbp)
addq $0xc8, %rbp
jmp 0x15932
leaq 0x4e774(%rip), %rax     # 0x640e0
cmpl $0x0, (%rax)
je 0x159a3
cmpb $0x53, (%r13)
jne 0x159a3
cmpb $0x43, 0x1(%r13)
jne 0x15986
cmpb $0x52, 0x2(%r13)
je 0x15994
cmpb $0x48, 0x1(%r13)
jne 0x159a3
cmpb $0x41, 0x2(%r13)
jne 0x159a3
movq %r14, %rdi
movq %r15, %rsi
movl 0x8(%rsp), %edx
callq 0x16c80
movss 0x4de91(%rip), %xmm0    # 0x6383c
leaq 0x4e6c2(%rip), %rax     # 0x64074
movss %xmm0, (%rax)
cmpb $0x43, (%r13)
jne 0x159ce
cmpb $0x41, 0x1(%r13)
je 0x159e0
cmpb $0x42, 0x1(%r13)
sete %cl
jmp 0x159d0
xorl %ecx, %ecx
testb %cl, %cl
jne 0x159e0
leaq 0x4e70d(%rip), %rcx     # 0x640e8
cmpl $0x0, (%rcx)
je 0x159ec
movss 0x4de50(%rip), %xmm0    # 0x63838
movss %xmm0, (%rax)
movl (%r14), %esi
movq %r15, %rdi
movq 0x10(%rsp), %rdx
callq 0x16de2
movslq (%r14), %rbp
imulq $0xc8, %rbp, %rdi
callq 0x21d0
movq %rax, (%rbx)
xorl %r12d, %r12d
xorl %r13d, %r13d
movslq %ebp, %rax
cmpq %rax, %r13
jge 0x15a3f
movq (%rbx), %rdi
addq %r12, %rdi
leaq (%r15,%r12), %rsi
movl $0xc8, %edx
callq 0x21a0
incq %r13
movl (%r14), %ebp
addq $0xc8, %r12
jmp 0x15a14
movq %r15, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2050
leaq 0x3b3e4(%rip), %rdi     # 0x50e40
movl %ebp, %esi
xorl %eax, %eax
callq 0x20f0
jmp 0x15a79
cvtss2sd %xmm0, %xmm0
leaq 0x3b406(%rip), %rdi     # 0x50e78
movb $0x1, %al
callq 0x20f0
pushq $0x8
popq %rdi
callq 0x2270