// File: /workspace/github_c_makefile_star2_O2/ugobas[P]tnm/anharmonic_tnm.c
// Function: Assign_interactions_SB_old
void Assign_interactions_SB_old(struct interaction *Int_list, int N_int,
				int POW, float EXPO, float k0)
{
  float A2; int n;
  if(POW){
    lambda=EXPO/4-0.5; lambda_2=2*lambda;
    A2=k0*pow(C0,EXPO)/(lambda_2*lambda_2);
    for(n=0; n<N_int; n++){
      Int_list[n].A2=A2*pow(Int_list[n].r0,-lambda_2);
    }
  }else{
    lambda=EXPO/4; lambda_2=2*lambda;
    A2=k0*exp(C0*EXPO)/(lambda_2*lambda_2);
    for(int n=0; n<N_int; n++){
      Int_list[n].A2=A2*exp(-Int_list[n].r0*lambda_2);
    }
  }
  float A4=A2/2;
  E_repulsion=A4;
  float kk0=A2*lambda_2*lambda_2, kk, EPS=0.005; int err=0;
  struct interaction *Int=Int_list;
  for(n=0; n<N_int; n++){
    Int->A4=A4;
    Int->A1=0;
    Int->A0=0;
    Int->r1=(Int->r0+C_THR)/2;
    Int->A0=-Compute_V(Int, C_THR);
    Int->E_min=Compute_V(Int, Int->r0);
    // Interpolation(Int_list+n);
    // Check force constant
    if(POW){kk=kk0*pow(Int->r0,-EXPO);}
    else{kk=kk0*exp(-Int->r0*EXPO);}
    if(fabs(kk-Int->sec_der)>EPS){
      err++;
      if(err <= 10){
	printf("ERROR in Assign_int n=%d r= %.2f ", n, Int->r0);
	printf("k= %.4g (old) %.4g (new) /= %.3f\n", 
	       Int->sec_der, kk, Int->sec_der/kk);
      }else{
	printf(".");
      }
    }
    Int++;
  }
  if(err){
    printf("\n%d errors in Assign_int, POW= %d EXPO= %.1f K0= %.4g r0= %.1f\n",
	   err, POW, EXPO, k0, C0); exit(8);
  }

  // Print energy versus r0
  char name_out[200]="Anharmonic_energy_TNM.dat";
  FILE *file_out=fopen(name_out, "w");
  printf("Writing %s\n", name_out);
  if(POW){ // power law: C0^-e
    fprintf(file_out, "# f(r)= %.2f r^(-%.2f)\n", -A4, EXPO);
  }else{ // Exponential
    fprintf(file_out, "# f(r)= %.2f exp(-%.2f*r)\n", -A4, EXPO);
  }
  for(float r=2.0; r<4.6; r+=0.005){
    float f;
    if(POW){f=-A4*pow(r,-EXPO);}
    else{f=-A4*exp(-EXPO*r);}
    fprintf(file_out, "%.2f %.4g\n", r, f);
  }
  fclose(file_out);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movaps %xmm0, %xmm2
movl %edx, %ebx
movl %esi, %r14d
movq %rdi, %r15
movss 0x34120(%rip), %xmm0    # 0x511f4
mulss %xmm2, %xmm0
testl %edx, %edx
movaps %xmm2, 0x40(%rsp)
movss %xmm1, 0x24(%rsp)
je 0x1d1ad
addss 0x34105(%rip), %xmm0    # 0x511f8
leaq 0x46fda(%rip), %rax     # 0x640d4
movss %xmm0, (%rax)
addss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x571d2(%rip)    # 0x742e0
cvtss2sd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x46f55(%rip), %rax     # 0x64074
cvtss2sd (%rax), %xmm0
cvtss2sd %xmm2, %xmm1
movsd %xmm1, 0x10(%rsp)
callq 0x20a0
mulsd 0x8(%rsp), %xmm0
movsd 0x571a0(%rip), %xmm1    # 0x742e0
mulsd %xmm1, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %r12d, %r12d
testl %r14d, %r14d
cmovlel %r12d, %r14d
imulq $0xc8, %r14, %r13
cmpq %r12, %r13
je 0x1d1a3
movsd 0x20(%r15,%r12), %xmm0
movsd 0x57160(%rip), %xmm1    # 0x742e0
xorpd 0x2df38(%rip), %xmm1    # 0x4b0c0
callq 0x20a0
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x40(%r15,%r12)
addq $0xc8, %r12
jmp 0x1d16c
movaps 0x40(%rsp), %xmm1
jmp 0x1d26a
leaq 0x46f20(%rip), %rax     # 0x640d4
movss %xmm0, (%rax)
addss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x57118(%rip)    # 0x742e0
cvtss2sd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x46e9b(%rip), %rax     # 0x64074
movss (%rax), %xmm0
mulss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x22a0
mulsd 0x8(%rsp), %xmm0
movsd 0x570e8(%rip), %xmm1    # 0x742e0
mulsd %xmm1, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %r12d, %r12d
testl %r14d, %r14d
cmovlel %r12d, %r14d
imulq $0xc8, %r14, %r13
cmpq %r12, %r13
je 0x1d25b
movsd 0x20(%r15,%r12), %xmm0
xorpd 0x2de88(%rip), %xmm0    # 0x4b0c0
mulsd 0x570a0(%rip), %xmm0    # 0x742e0
callq 0x22a0
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x40(%r15,%r12)
addq $0xc8, %r12
jmp 0x1d224
movaps 0x40(%rsp), %xmm1
cvtss2sd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movaps 0x30(%rsp), %xmm2
mulss 0x3289d(%rip), %xmm2    # 0x4fb14
leaq 0x46e5a(%rip), %rax     # 0x640d8
movss %xmm2, (%rax)
movsd 0x57056(%rip), %xmm0    # 0x742e0
movsd 0x8(%rsp), %xmm3
mulsd %xmm0, %xmm3
mulsd %xmm0, %xmm3
cvtsd2ss %xmm3, %xmm0
movaps %xmm2, 0x30(%rsp)
cvtss2sd %xmm2, %xmm2
movsd %xmm2, 0x8(%rsp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
xorps 0x335a4(%rip), %xmm1    # 0x50860
movaps %xmm1, 0x40(%rsp)
cvtss2sd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
xorl %ebp, %ebp
xorl %r13d, %r13d
cmpl %ebp, %r14d
je 0x1d403
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x48(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r15)
leaq 0x46d74(%rip), %rax     # 0x64068
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm1
addsd 0x20(%r15), %xmm1
mulsd 0x2dd66(%rip), %xmm1    # 0x4b070
cvtsd2ss %xmm1, %xmm1
movss %xmm1, 0x10(%r15)
movq %r15, %rdi
callq 0x1ac14
xorps 0x3353d(%rip), %xmm0    # 0x50860
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x30(%r15)
cvtsd2ss 0x20(%r15), %xmm0
movq %r15, %rdi
callq 0x1ac14
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0xb8(%r15)
movsd 0x20(%r15), %xmm0
testl %ebx, %ebx
je 0x1d35f
movsd 0x28(%rsp), %xmm1
callq 0x20a0
jmp 0x1d372
xorpd 0x2dd59(%rip), %xmm0    # 0x4b0c0
mulsd 0x10(%rsp), %xmm0
callq 0x22a0
mulsd 0x18(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm1
movaps %xmm1, %xmm0
subsd 0x28(%r15), %xmm0
andpd 0x33eaf(%rip), %xmm0    # 0x51240
ucomisd 0x33f57(%rip), %xmm0    # 0x512f0
jbe 0x1d3e5
leal 0x1(%r13), %r12d
cmpl $0x9, %r13d
jg 0x1d3ea
movsd 0x20(%r15), %xmm0
leaq 0x34c9c(%rip), %rdi     # 0x5204e
movl %ebp, %esi
movb $0x1, %al
movsd %xmm1, 0x58(%rsp)
callq 0x20f0
movsd 0x28(%r15), %xmm0
movapd %xmm0, %xmm2
movsd 0x58(%rsp), %xmm1
divsd %xmm1, %xmm2
leaq 0x34c94(%rip), %rdi     # 0x52070
movb $0x3, %al
callq 0x20f0
jmp 0x1d3f2
movl %r13d, %r12d
jmp 0x1d3f2
pushq $0x2e
popq %rdi
callq 0x2060
addq $0xc8, %r15
incl %ebp
movl %r12d, %r13d
jmp 0x1d2d0
testl %r13d, %r13d
jne 0x1d51b
leaq 0x33f6d(%rip), %rsi     # 0x51380
leaq 0x60(%rsp), %r15
movl $0xc8, %edx
movq %r15, %rdi
callq 0x21a0
leaq 0x33d24(%rip), %rsi     # 0x51150
movq %r15, %rdi
callq 0x2210
movq %rax, %r14
leaq 0x2e869(%rip), %rdi     # 0x4bca7
movq %r15, %rsi
xorl %eax, %eax
callq 0x20f0
testl %ebx, %ebx
movaps 0x30(%rsp), %xmm0
xorps 0x3340a(%rip), %xmm0    # 0x50860
cvtss2sd %xmm0, %xmm0
leaq 0x34c89(%rip), %rax     # 0x520ea
leaq 0x34c6a(%rip), %rsi     # 0x520d2
cmoveq %rax, %rsi
movq %r14, %rdi
movsd %xmm0, 0x18(%rsp)
movsd 0x10(%rsp), %xmm1
movb $0x2, %al
callq 0x2190
movss 0x3397a(%rip), %xmm0    # 0x50e04
leaq 0x34baf(%rip), %r15     # 0x52040
cvtss2sd %xmm0, %xmm2
movsd 0x33e5b(%rip), %xmm1    # 0x512f8
ucomisd %xmm2, %xmm1
jbe 0x1d501
testl %ebx, %ebx
movsd %xmm2, 0x8(%rsp)
je 0x1d4bd
movaps %xmm2, %xmm0
movsd 0x28(%rsp), %xmm1
callq 0x20a0
jmp 0x1d4cc
mulss 0x40(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x22a0
mulsd 0x18(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm1
movq %r14, %rdi
movq %r15, %rsi
movsd 0x8(%rsp), %xmm0
movb $0x2, %al
callq 0x2190
movsd 0x8(%rsp), %xmm0
addsd 0x333a5(%rip), %xmm0    # 0x508a0
cvtsd2ss %xmm0, %xmm0
jmp 0x1d491
movq %r14, %rdi
callq 0x20c0
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cvtss2sd 0x24(%rsp), %xmm1
leaq 0x46b4c(%rip), %rax     # 0x64074
cvtss2sd (%rax), %xmm2
leaq 0x34b5f(%rip), %rdi     # 0x52092
movl %r13d, %esi
movl %ebx, %edx
movsd 0x10(%rsp), %xmm0
movb $0x3, %al
callq 0x20f0
pushq $0x8
popq %rdi
callq 0x2270
nopl (%rax)