// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/anharmonic_tnm.c
// Function: Energy_anharmonic
double Energy_anharmonic(float *r, atom *atoms, int natoms,
			 struct residue *seq, int nres,
			 struct interaction *Int_list, int N_int,
			 struct interaction **Int_KB, int NA,
			 struct axe *axe, int naxes,
			 double *delta_phi)
{
  if(INI_ENERGY==0){
    Initialize_energy(Int_list, N_int, r, atoms, natoms, nres);
  }

  double E_nat=0, E_nonat=0;
  for(int i=0; i<N_int_all; i++){
    int i1=Int_list_all[i].i1, i2=Int_list_all[i].i2;
    int n=nat_res1_res2[atoms[i1].res][atoms[i2].res];
    float d=Min_res_dist(r, atoms, &i1, &i2, n, natoms);
    if(d>=C_THR)continue;
    if(d<=0){
      printf("ERROR, d(%d,%d)= %.2g n=%d\n", i1, i2, d, n);
      exit(8);
    }
    if(n>=0){
      E_nat+=Compute_V(Int_list+n, d); //-Int_list[n].E_min;
    }else{
      int a=seq[atoms[i1].res].i_aa, b=seq[atoms[i2].res].i_aa;
      E_nonat+=Compute_V(Int_KB[a]+b, d); //-Int_KB[a][b].E_min;
    }
  }

  // Compute_torsional energy
  double E_phi=0, E_psi=0, E_omg=0, E_chi=0, E_BA=0, E_BL=0, E_BT=0;
  struct axe *ax=axe;
  for(int i=0; i<naxes; i++){
    float d2=delta_phi[i]*delta_phi[i];
    if(ax->type=='f'){E_phi+=d2;}
    else if(ax->type=='p'){E_psi+=d2;}
    else if(ax->type=='l'){E_BL+=d2;}
    else if(ax->type=='a'){E_BA+=d2;}
    else if(ax->type=='t'){E_BT+=d2;}
    else if(ax->type=='o'){E_omg+=d2;}
    else if(ax->type=='s'){E_chi+=d2;}
    ax++;
  }
  double E_tors=K_PHI*E_phi;
  if(E_psi)E_tors+=K_PSI*E_psi;
  if(E_omg)E_tors+=K_OMEGA*E_omg;
  if(E_chi)E_tors+=K_CHI*E_chi;
  if(E_BL)E_tors+=K_BL*E_BL;
  if(E_BA)E_tors+=K_BA*E_BA;
  if(E_BT)E_tors+=K_PHI*E_BT;
  return(E_nat+E_nonat+0.5*E_tors);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq 0x38(%rbp), %rax
movl 0x30(%rbp), %eax
movq 0x28(%rbp), %rax
movl 0x20(%rbp), %eax
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
cmpl $0x0, 0x76b8e(%rip)     # 0x9c24c
jne 0x256dc
movq -0x30(%rbp), %rdi
movl 0x10(%rbp), %esi
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rcx
movl -0x14(%rbp), %r8d
movl -0x24(%rbp), %r9d
callq 0x27680
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl 0x76b80(%rip), %eax     # 0x9c27c
jge 0x25897
movq 0x76b77(%rip), %rax     # 0x9c280
movslq -0x44(%rbp), %rcx
imulq $0xc8, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x48(%rbp)
movq 0x76b5d(%rip), %rax     # 0x9c280
movslq -0x44(%rbp), %rcx
imulq $0xc8, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x4c(%rbp)
movq 0x76b52(%rip), %rax     # 0x9c290
movq -0x10(%rbp), %rcx
movslq -0x48(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
movslq 0x64(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq -0x10(%rbp), %rcx
movslq -0x4c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
movslq 0x64(%rcx), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x50(%rbp), %r8d
movl -0x14(%rbp), %r9d
leaq -0x48(%rbp), %rdx
leaq -0x4c(%rbp), %rcx
callq 0x27350
movss %xmm0, -0x54(%rbp)
movss -0x54(%rbp), %xmm0
leaq 0x6688c(%rip), %rax     # 0x8c028
ucomiss (%rax), %xmm0
jb 0x257a6
jmp 0x25889
xorps %xmm0, %xmm0
ucomiss -0x54(%rbp), %xmm0
jb 0x257d9
movl -0x48(%rbp), %esi
movl -0x4c(%rbp), %edx
movss -0x54(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movl -0x50(%rbp), %ecx
leaq 0x57260(%rip), %rdi     # 0x7ca28
movb $0x1, %al
callq 0x10d0
movl $0x8, %edi
callq 0x1210
cmpl $0x0, -0x50(%rbp)
jl 0x2580b
movq -0x30(%rbp), %rdi
movslq -0x50(%rbp), %rax
imulq $0xc8, %rax, %rax
addq %rax, %rdi
movss -0x54(%rbp), %xmm0
callq 0x27810
cvtss2sd %xmm0, %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
jmp 0x25887
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x48(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
movslq 0x64(%rcx), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movswl 0x14(%rax), %eax
movl %eax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x4c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
movslq 0x64(%rcx), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movswl 0x14(%rax), %eax
movl %eax, -0x5c(%rbp)
movq 0x18(%rbp), %rax
movslq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x5c(%rbp), %rax
imulq $0xc8, %rax, %rax
addq %rax, %rdi
movss -0x54(%rbp), %xmm0
callq 0x27810
cvtss2sd %xmm0, %xmm0
addsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0x25889
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x256f3
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x78(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x80(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x88(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x90(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x98(%rbp)
movq 0x28(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl $0x0, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl 0x30(%rbp), %eax
jge 0x25a86
movq 0x38(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x38(%rbp), %rax
movslq -0xa4(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0xa8(%rbp)
movq -0xa0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x66, %eax
jne 0x25952
movss -0xa8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
jmp 0x25a5e
movq -0xa0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x70, %eax
jne 0x2597c
movss -0xa8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
jmp 0x25a5c
movq -0xa0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x6c, %eax
jne 0x259ac
movss -0xa8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
jmp 0x25a5a
movq -0xa0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x61, %eax
jne 0x259d9
movss -0xa8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
jmp 0x25a58
movq -0xa0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x74, %eax
jne 0x25a06
movss -0xa8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
jmp 0x25a56
movq -0xa0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x6f, %eax
jne 0x25a2d
movss -0xa8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
jmp 0x25a54
movq -0xa0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x73, %eax
jne 0x25a52
movss -0xa8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
jmp 0x25a54
jmp 0x25a56
jmp 0x25a58
jmp 0x25a5a
jmp 0x25a5c
jmp 0x25a5e
movq -0xa0(%rbp), %rax
addq $0x158, %rax            # imm = 0x158
movq %rax, -0xa0(%rbp)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x258ed
leaq 0x665d3(%rip), %rax     # 0x8c060
movsd (%rax), %xmm0
mulsd -0x68(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0x70(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x25ab0
jp 0x25ab0
jmp 0x25ad8
leaq 0x665a1(%rip), %rax     # 0x8c058
movsd (%rax), %xmm0
movsd -0x70(%rbp), %xmm2
movsd -0xb0(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0x78(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x25aea
jp 0x25aea
jmp 0x25b12
leaq 0x6655f(%rip), %rax     # 0x8c050
movsd (%rax), %xmm0
movsd -0x78(%rbp), %xmm2
movsd -0xb0(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0x80(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x25b24
jp 0x25b24
jmp 0x25b4c
leaq 0x6653d(%rip), %rax     # 0x8c068
movsd (%rax), %xmm0
movsd -0x80(%rbp), %xmm2
movsd -0xb0(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0x90(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x25b61
jp 0x25b61
jmp 0x25b8c
leaq 0x66510(%rip), %rax     # 0x8c078
movsd (%rax), %xmm0
movsd -0x90(%rbp), %xmm2
movsd -0xb0(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0x88(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x25ba1
jp 0x25ba1
jmp 0x25bcc
leaq 0x664c8(%rip), %rax     # 0x8c070
movsd (%rax), %xmm0
movsd -0x88(%rbp), %xmm2
movsd -0xb0(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0x98(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x25be1
jp 0x25be1
jmp 0x25c0c
leaq 0x66478(%rip), %rax     # 0x8c060
movsd (%rax), %xmm0
movsd -0x98(%rbp), %xmm2
movsd -0xb0(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0x38(%rbp), %xmm1
addsd -0x40(%rbp), %xmm1
movsd -0xb0(%rbp), %xmm0
movsd 0x503e2(%rip), %xmm2    # 0x76008
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
addq $0xb0, %rsp
popq %rbp
retq
nopw (%rax,%rax)