// File: /workspace/github_c_makefile_star2_O2/ugobas[P]tnm/anharmonic_tnm.c
// Function: Determine_Ak
int Determine_Ak(struct interaction *Int, double V0, double KK, int n)
{
  int err=0;
  double f, fc, V2=KK/(lambda*lambda);
  Int->r1=100;
  if(POW){
    f=pow(Int->r0, -lambda);
    fc=pow(C_THR, -lambda);
    V2*=(Int->r0*Int->r0);
  }else{
    f=exp(-lambda*Int->r0);
    fc=exp(-lambda*C_THR);
  }
  double alpha=fc/f, a2=alpha*alpha, aa=1.-alpha;
  double f2=f*f, fc2=fc*fc;
  // Condition on V
  Int->A4=(V0+0.5*V2*aa*aa)/(f2*f2*(3.0-a2*a2+6*a2-8.0*alpha));
  if(Int->A4<0){
    printf("ERROR A4= %.3g <0 n= %d", Int->A4, n);
    printf(" alpha=%.2g V0= %.2g V2= %.2g\n", alpha, V0, V2); 
    err=-1;
  }
  Int->A2=-6.0*Int->A4*f2+0.5*V2/f2; // Condition on V''
  Int->A1=8.0*Int->A4*f2*f-V2/f;     // Condition on V'
  Int->A0=-Int->A4*fc2*fc2-Int->A2*fc2-Int->A1*fc; // Condition at C_THR
  { // Test
    float EPS=0.01;
    float V0_1=Compute_V(Int, Int->r0);
    float V1_1=Compute_V1(Int, Int->r0);
    float V2_1=Compute_V2(Int, Int->r0, 0);
    if(err ||(fabs(V0_1-V0)>EPS)||(fabs(V1_1)>EPS)||(fabs(V2_1-KK)>EPS)){
      printf("ERROR in Determine_Ak n= %d r0= %.2f r1= %.2f A4= %.2g\n",
	     n, Int->r0, Int->r1, Int->A4);
      printf("V(Rc)= %.4g\n",  Compute_V(Int, C_THR));
      printf("V(r0)  = %.4g (old) %.4g (new)\n", V0, V0_1);
      printf("V'(r0) = 0 (old) %.4g (new)\n", V1_1);
      printf("V''(r0)= %.4g (old) %.4g (new)\n", KK, V2_1);
      return(-1);
    }
  }
  return(err);

}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x90, %rsp
movl %esi, %ebp
movsd %xmm0, 0x8(%rsp)
movq %rdi, %rbx
leaq 0x47b0c(%rip), %r14     # 0x640d4
movss (%r14), %xmm2
movaps %xmm2, %xmm0
mulss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm1, 0x38(%rsp)
divsd %xmm0, %xmm1
movapd %xmm1, 0x10(%rsp)
movl $0x42c80000, 0x10(%rdi) # imm = 0x42C80000
leaq 0x46ff6(%rip), %rax     # 0x635ec
cmpl $0x0, (%rax)
je 0x1c650
movsd 0x20(%rbx), %xmm0
xorps 0x34259(%rip), %xmm2    # 0x50860
cvtss2sd %xmm2, %xmm1
callq 0x20a0
leaq 0x47a51(%rip), %rax     # 0x64068
cvtss2sd (%rax), %xmm2
movaps %xmm0, 0x20(%rsp)
movss (%r14), %xmm0
xorps 0x34234(%rip), %xmm0    # 0x50860
cvtss2sd %xmm0, %xmm1
movaps %xmm2, %xmm0
callq 0x20a0
movaps %xmm0, %xmm5
movsd 0x20(%rbx), %xmm0
mulsd %xmm0, %xmm0
movapd 0x10(%rsp), %xmm4
mulsd %xmm0, %xmm4
jmp 0x1c694
xorps 0x34209(%rip), %xmm2    # 0x50860
cvtss2sd %xmm2, %xmm0
mulsd 0x20(%rbx), %xmm0
callq 0x22a0
movapd %xmm0, 0x20(%rsp)
movss (%r14), %xmm0
xorps 0x341e9(%rip), %xmm0    # 0x50860
leaq 0x479ea(%rip), %rax     # 0x64068
mulss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x22a0
movaps %xmm0, %xmm5
movapd 0x10(%rsp), %xmm4
movaps %xmm5, %xmm11
movapd 0x20(%rsp), %xmm8
divsd %xmm8, %xmm11
movapd %xmm11, %xmm0
mulsd %xmm11, %xmm0
movsd 0x2e992(%rip), %xmm1    # 0x4b048
subsd %xmm11, %xmm1
movapd %xmm8, %xmm9
mulsd %xmm8, %xmm9
movaps %xmm5, %xmm7
mulsd %xmm5, %xmm7
movsd 0x2e99b(%rip), %xmm10   # 0x4b070
mulsd %xmm4, %xmm10
movapd %xmm10, %xmm6
mulsd %xmm1, %xmm6
mulsd %xmm1, %xmm6
addsd 0x8(%rsp), %xmm6
movapd %xmm9, %xmm1
mulsd %xmm9, %xmm1
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
movsd 0x34b99(%rip), %xmm3    # 0x512a0
subsd %xmm2, %xmm3
mulsd 0x34ba5(%rip), %xmm0    # 0x512b8
addsd %xmm3, %xmm0
movsd 0x34bb9(%rip), %xmm2    # 0x512d8
mulsd %xmm11, %xmm2
addsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
divsd %xmm2, %xmm6
movsd %xmm6, 0x48(%rbx)
xorl %r14d, %r14d
xorpd %xmm0, %xmm0
ucomisd %xmm6, %xmm0
movapd %xmm6, 0x40(%rsp)
movapd %xmm6, %xmm0
movapd %xmm8, %xmm3
jbe 0x1c7e6
pushq $-0x1
popq %r14
leaq 0x35563(%rip), %rdi     # 0x51cc3
movaps 0x40(%rsp), %xmm0
movl %ebp, %esi
movb $0x1, %al
movapd %xmm4, 0x10(%rsp)
movsd %xmm5, 0x68(%rsp)
movsd %xmm7, 0x60(%rsp)
movapd %xmm9, 0x80(%rsp)
movapd %xmm10, 0x70(%rsp)
movsd %xmm11, 0x58(%rsp)
callq 0x20f0
leaq 0x3553c(%rip), %rdi     # 0x51cdb
movsd 0x58(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movapd 0x10(%rsp), %xmm2
movb $0x3, %al
callq 0x20f0
movapd 0x70(%rsp), %xmm10
movapd 0x80(%rsp), %xmm9
movsd 0x60(%rsp), %xmm7
movsd 0x68(%rsp), %xmm5
movapd 0x20(%rsp), %xmm3
movapd 0x10(%rsp), %xmm4
movsd 0x48(%rbx), %xmm0
movsd 0x34af2(%rip), %xmm1    # 0x512e0
mulsd %xmm0, %xmm1
movapd 0x2e8c6(%rip), %xmm2    # 0x4b0c0
xorpd %xmm2, %xmm4
unpcklpd %xmm9, %xmm3            # xmm3 = xmm3[0],xmm9[0]
shufpd $0x2, 0x34a44(%rip), %xmm1 # xmm1 = xmm1[0],mem[1]
unpcklpd %xmm0, %xmm9            # xmm9 = xmm9[0],xmm0[0]
mulpd %xmm9, %xmm1
unpcklpd %xmm10, %xmm4           # xmm4 = xmm4[0],xmm10[0]
divpd %xmm3, %xmm4
mulpd %xmm3, %xmm1
addpd %xmm4, %xmm1
movupd %xmm1, 0x38(%rbx)
xorpd %xmm2, %xmm0
mulsd %xmm7, %xmm0
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
mulsd %xmm7, %xmm2
mulsd %xmm7, %xmm0
subsd %xmm2, %xmm0
mulsd %xmm5, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rbx)
cvtsd2ss 0x20(%rbx), %xmm0
movq %rbx, %rdi
callq 0x1ac14
movss %xmm0, 0x20(%rsp)
cvtsd2ss 0x20(%rbx), %xmm0
movq %rbx, %rdi
callq 0x1b4a6
movaps %xmm0, 0x10(%rsp)
cvtsd2ss 0x20(%rbx), %xmm0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1b776
movaps %xmm0, %xmm1
xorps %xmm0, %xmm0
ucomisd 0x40(%rsp), %xmm0
cvtss2sd 0x20(%rsp), %xmm2
ja 0x1c8ed
movaps %xmm2, %xmm0
subsd 0x8(%rsp), %xmm0
andpd 0x34992(%rip), %xmm0    # 0x51240
ucomisd 0x34a32(%rip), %xmm0    # 0x512e8
ja 0x1c8ed
movaps 0x34971(%rip), %xmm0    # 0x51230
andps 0x10(%rsp), %xmm0
ucomiss 0x34935(%rip), %xmm0    # 0x51200
ja 0x1c8ed
cvtss2sd %xmm1, %xmm0
subsd 0x38(%rsp), %xmm0
andpd 0x34961(%rip), %xmm0    # 0x51240
ucomisd 0x34a01(%rip), %xmm0    # 0x512e8
jbe 0x1c989
movss %xmm1, 0x20(%rsp)
cvtss2sd 0x10(%rbx), %xmm1
movsd 0x20(%rbx), %xmm0
movsd %xmm2, 0x40(%rsp)
movsd 0x48(%rbx), %xmm2
leaq 0x353eb(%rip), %rdi     # 0x51cfa
movl %ebp, %esi
movb $0x3, %al
callq 0x20f0
leaq 0x47749(%rip), %rax     # 0x64068
movss (%rax), %xmm0
movq %rbx, %rdi
callq 0x1ac14
cvtss2sd %xmm0, %xmm0
leaq 0x353fc(%rip), %rdi     # 0x51d32
movb $0x1, %al
callq 0x20f0
leaq 0x353fb(%rip), %rdi     # 0x51d3f
movsd 0x8(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movb $0x2, %al
callq 0x20f0
cvtss2sd 0x10(%rsp), %xmm0
leaq 0x353fb(%rip), %rdi     # 0x51d5f
movb $0x1, %al
callq 0x20f0
cvtss2sd 0x20(%rsp), %xmm1
leaq 0x35404(%rip), %rdi     # 0x51d7c
movsd 0x38(%rsp), %xmm0
movb $0x2, %al
callq 0x20f0
pushq $-0x1
popq %r14
movl %r14d, %eax
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
retq