// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/anharmonic_tnm.c
// Function: Assign_interactions_KB
void Assign_interactions_KB(struct interaction **Int_KB, int Na,
			    int POW, float EXPO, float k0)
{
  // Only repulsion
  printf("Assigning knowledge-based interactions\n");
  printf("--> NPAR = %8d        number of parameters: ", NPAR);
  printf("2 (only repulsion), 3 (barrier)\n");
  printf("--> Na   = %8d        amino acids or atom types\n",Na);
  printf("--> POW  = %8d        1 power law, 0 exponential (kappa)\n", POW);
  printf("--> EXPO = %8.2f        kappa exponent\n",EXPO);
  printf("--> k0   = %8.2f        kappa0 (default value or Bfactor fit)\n",k0);
  printf("--> OUTPUT: Int_KB[%d][%d]\n",Na,Na);
  printf("\n");

  double A4, Scale;
  if(POW){
    lambda=EXPO/4-0.5;
    A4=k0*pow(C0,EXPO); ///(8*lambda*lambda);
    Scale=Scale_Prop_POW/(lambda*lambda);
  }else{
    lambda=EXPO/4;
    A4=k0*exp(C0*EXPO); ///(4*lambda*lambda);
    Scale=Scale_Prop_EXP/(lambda*lambda);
  }
  A4/=(8*lambda*lambda);
  lambda_2=2*lambda;
  lambda_4=4*lambda;
  E_repulsion=A4;
  double A2=2*A4;

  int a, b, n=0, n_err=0; 
  for(a=0; a<Na; a++){
    for(b=a; b<Na; b++){
      double fc2, r3;
      struct interaction *Int_ptr=Int_KB[a]+b;
      Int_ptr->r1=100;
      if(NPAR==2){
	Int_ptr->r0=C_THR;
	Int_ptr->E_min=0;
	if(POW){fc2=pow(C_THR, -lambda_2);}
	else{fc2=exp(-lambda_2*C_THR);}
	Int_ptr->A1=0;
	Int_ptr->A2=-A2*fc2;
	Int_ptr->A4=A4;
	Int_ptr->A0=-Int_ptr->A4*fc2*fc2-Int_ptr->A2*fc2;
	r3=C1_THR;
      }else{ // Three parameters fit
	if(D_Res[a][b]>=C_THR){
	  printf("ERROR, too large KB distance %.2f (> %.2f)",
		 D_Res[a][b], C_THR);
	  printf("for residues %d and %d\n", a, b); exit(8);
	}
	Int_ptr->r0=D_Res[a][b];
	double V0=U_Res[a][b]*Scale;
	if(Determine_Ak(Int_ptr, V0, K_Residues[a][b], n))n_err++;
	r3=(Int_ptr->r0+C_THR)*0.5;
	if(r3>C1_THR)r3=C1_THR;
	Int_ptr->E_min=Compute_V(Int_ptr, Int_ptr->r0);
      }
      Int_ptr->r1=r3;
      Int_ptr->r2=r3;
      Int_ptr->sec_der=Compute_V2(Int_ptr, Int_ptr->r0, 0);
      Int_ptr->a0=0; Int_ptr->a1=0; Int_ptr->a2=0;
      Int_ptr->a3=0; Int_ptr->a4=0; Int_ptr->a5=0;
      //Interpolation(Int_ptr, NULL, r3, C_THR);
      if(b!=a)Int_KB[b][a]=*Int_ptr;
      n++;
    }
  }
  if(n_err){
    printf("ERRORS in KB in %d pairs of residues/atoms out of %d\n",
	   n_err, n); exit(8);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movss %xmm0, -0x14(%rbp)
movss %xmm1, -0x18(%rbp)
leaq 0x5335c(%rip), %rdi     # 0x7cd1f
movb $0x0, %al
callq 0x10d0
movl 0x62470(%rip), %esi     # 0x8be40
leaq 0x53370(%rip), %rdi     # 0x7cd47
movb $0x0, %al
callq 0x10d0
leaq 0x5338f(%rip), %rdi     # 0x7cd74
movb $0x0, %al
callq 0x10d0
movl -0xc(%rbp), %esi
leaq 0x5339f(%rip), %rdi     # 0x7cd95
movb $0x0, %al
callq 0x10d0
movl -0x10(%rbp), %esi
leaq 0x533bf(%rip), %rdi     # 0x7cdc6
movb $0x0, %al
callq 0x10d0
movss -0x14(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x533e2(%rip), %rdi     # 0x7ce00
movb $0x1, %al
callq 0x10d0
movss -0x18(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x533f3(%rip), %rdi     # 0x7ce28
movb $0x1, %al
callq 0x10d0
movl -0xc(%rbp), %esi
movl -0xc(%rbp), %edx
leaq 0x5341e(%rip), %rdi     # 0x7ce67
movb $0x0, %al
callq 0x10d0
leaq 0x54621(%rip), %rdi     # 0x7e078
movb $0x0, %al
callq 0x10d0
cmpl $0x0, -0x10(%rbp)
je 0x29b01
movss -0x14(%rbp), %xmm0
movss 0x52577(%rip), %xmm1    # 0x7bfec
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x4c583(%rip), %xmm1    # 0x76008
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
leaq 0x62600(%rip), %rax     # 0x8c094
movss %xmm0, (%rax)
movss -0x18(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
leaq 0x62587(%rip), %rax     # 0x8c034
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x14(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
callq 0x1080
movaps %xmm0, %xmm1
movsd -0x68(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movss 0x62384(%rip), %xmm0    # 0x8be60
leaq 0x625b1(%rip), %rax     # 0x8c094
movss (%rax), %xmm1
leaq 0x625a6(%rip), %rax     # 0x8c094
mulss (%rax), %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x29b80
movss -0x14(%rbp), %xmm0
movss 0x524de(%rip), %xmm1    # 0x7bfec
divss %xmm1, %xmm0
leaq 0x6257b(%rip), %rax     # 0x8c094
movss %xmm0, (%rax)
movss -0x18(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
leaq 0x62502(%rip), %rax     # 0x8c034
movss (%rax), %xmm0
mulss -0x14(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x1230
movaps %xmm0, %xmm1
movsd -0x70(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movss 0x6230b(%rip), %xmm0    # 0x8be68
leaq 0x62530(%rip), %rax     # 0x8c094
movss (%rax), %xmm1
leaq 0x62525(%rip), %rax     # 0x8c094
mulss (%rax), %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
movss 0x5285c(%rip), %xmm0    # 0x7c3e4
leaq 0x62505(%rip), %rax     # 0x8c094
mulss (%rax), %xmm0
leaq 0x624fa(%rip), %rax     # 0x8c094
mulss (%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd -0x20(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movss 0x4c4dc(%rip), %xmm0    # 0x76094
leaq 0x624d5(%rip), %rax     # 0x8c094
mulss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x726d1(%rip)    # 0x9c2a0
movss 0x52415(%rip), %xmm0    # 0x7bfec
leaq 0x624b6(%rip), %rax     # 0x8c094
mulss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x726ba(%rip)    # 0x9c2a8
movsd -0x20(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
leaq 0x6249a(%rip), %rax     # 0x8c098
movss %xmm0, (%rax)
movsd 0x4c44e(%rip), %xmm0    # 0x76058
mulsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x2a068
movl -0x34(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x2a058
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
imulq $0xc8, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movss 0x4c43f(%rip), %xmm0    # 0x760b0
movss %xmm0, 0x10(%rax)
cmpl $0x2, 0x621c3(%rip)     # 0x8be40
jne 0x29de3
leaq 0x6239e(%rip), %rax     # 0x8c028
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x58(%rbp), %rax
movsd %xmm0, 0x20(%rax)
movq -0x58(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0xb8(%rax)
cmpl $0x0, -0x10(%rbp)
je 0x29cea
leaq 0x62371(%rip), %rax     # 0x8c028
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x725d9(%rip), %xmm1    # 0x9c2a0
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
callq 0x1080
movsd %xmm0, -0x48(%rbp)
jmp 0x29d26
movsd 0x725ae(%rip), %xmm0    # 0x9c2a0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
leaq 0x62318(%rip), %rax     # 0x8c028
movss (%rax), %xmm1
cvtss2sd %xmm1, %xmm1
mulsd %xmm1, %xmm0
callq 0x1230
movsd %xmm0, -0x48(%rbp)
movq -0x58(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x38(%rax)
movsd -0x30(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd -0x48(%rbp), %xmm0
movq -0x58(%rbp), %rax
movsd %xmm0, 0x40(%rax)
movsd -0x20(%rbp), %xmm0
movq -0x58(%rbp), %rax
movsd %xmm0, 0x48(%rax)
movq -0x58(%rbp), %rax
movsd 0x48(%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd -0x48(%rbp), %xmm0
movsd -0x48(%rbp), %xmm2
movq -0x58(%rbp), %rax
movsd 0x40(%rax), %xmm1
mulsd -0x48(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x58(%rbp), %rax
movsd %xmm0, 0x30(%rax)
leaq 0x6225f(%rip), %rax     # 0x8c030
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
jmp 0x29f74
movslq -0x34(%rbp), %rcx
leaq 0x629a2(%rip), %rax     # 0x8c790
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
leaq 0x62223(%rip), %rax     # 0x8c028
ucomiss (%rax), %xmm0
jb 0x29e64
movslq -0x34(%rbp), %rcx
leaq 0x6297b(%rip), %rax     # 0x8c790
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x621f8(%rip), %rax     # 0x8c028
movss (%rax), %xmm1
cvtss2sd %xmm1, %xmm1
leaq 0x53044(%rip), %rdi     # 0x7ce83
movb $0x2, %al
callq 0x10d0
movl -0x34(%rbp), %esi
movl -0x38(%rbp), %edx
leaq 0x52570(%rip), %rdi     # 0x7c3c3
movb $0x0, %al
callq 0x10d0
movl $0x8, %edi
callq 0x1210
movslq -0x34(%rbp), %rcx
leaq 0x62921(%rip), %rax     # 0x8c790
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x58(%rbp), %rax
movsd %xmm0, 0x20(%rax)
movslq -0x34(%rbp), %rcx
leaq 0x622b9(%rip), %rax     # 0x8c150
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
mulsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x58(%rbp), %rdi
movsd -0x60(%rbp), %xmm0
movslq -0x34(%rbp), %rcx
leaq 0x61937(%rip), %rax     # 0x8b800
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
movss (%rax,%rcx,4), %xmm1
cvtss2sd %xmm1, %xmm1
movl -0x3c(%rbp), %esi
callq 0x2a0a0
cmpl $0x0, %eax
je 0x29ef3
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movq -0x58(%rbp), %rax
movsd 0x20(%rax), %xmm0
leaq 0x62125(%rip), %rax     # 0x8c028
movss (%rax), %xmm1
cvtss2sd %xmm1, %xmm1
addsd %xmm1, %xmm0
movsd 0x4c0f1(%rip), %xmm1    # 0x76008
mulsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
leaq 0x62104(%rip), %rax     # 0x8c030
movss (%rax), %xmm1
cvtss2sd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x29f4e
leaq 0x620ef(%rip), %rax     # 0x8c030
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x58(%rbp), %rdi
movq -0x58(%rbp), %rax
movsd 0x20(%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x27810
cvtss2sd %xmm0, %xmm0
movq -0x58(%rbp), %rax
movsd %xmm0, 0xb8(%rax)
movsd -0x50(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x58(%rbp), %rax
movss %xmm0, 0x10(%rax)
movsd -0x50(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x58(%rbp), %rax
movss %xmm0, 0x14(%rax)
movq -0x58(%rbp), %rdi
movq -0x58(%rbp), %rax
movsd 0x20(%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
xorl %esi, %esi
callq 0x28af0
cvtss2sd %xmm0, %xmm0
movq -0x58(%rbp), %rax
movsd %xmm0, 0x28(%rax)
movq -0x58(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x70(%rax)
movq -0x58(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x78(%rax)
movq -0x58(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x80(%rax)
movq -0x58(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x88(%rax)
movq -0x58(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x90(%rax)
movq -0x58(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x98(%rax)
movl -0x38(%rbp), %eax
cmpl -0x34(%rbp), %eax
je 0x2a041
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x34(%rbp), %rax
imulq $0xc8, %rax, %rax
addq %rax, %rdi
movq -0x58(%rbp), %rsi
movl $0xc8, %edx
callq 0x1160
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x29c3b
jmp 0x2a05a
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x29c29
cmpl $0x0, -0x40(%rbp)
je 0x2a08c
movl -0x40(%rbp), %esi
movl -0x3c(%rbp), %edx
leaq 0x52e33(%rip), %rdi     # 0x7ceae
movb $0x0, %al
callq 0x10d0
movl $0x8, %edi
callq 0x1210
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)