// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/screened_interactions.c
// Function: Axis_distance_S
int Axis_distance_S(float *d2_nb, float *d2_bo, float S_NB, float S_BO,
		    struct store *store1, float d2_ij,
		    atom *atom_i, atom *atom_j, atom *atoms)
{
  int resi=atom_i->res, resj=atom_j->res;
  float d2, d2_jk, d2_k, d2_c, S, S2;
  float S2_NB=S_NB*S_NB;
  float S2_BO=S_BO*S_BO;
  float S4_NB=4*S2_NB;
  float S4_BO=4*S2_BO;
  float d_ij=sqrt(d2_ij);
  while(store1 != NULL){
    if(store1->x > d2_ij)break;
    atom *atom_k=atoms+store1->i;
    if(atom_k!=atom_j){
      d2_jk=Dist2(atom_j->r, atom_k->r);
      if(d2_jk >= d2_ij)goto next2;
      if(d2_jk > store1->x){
	d2_k=d2_jk;
	d2_c=Scalar(atom_j->r, atom_i->r, atom_k->r);
      }else{
	d2_k=store1->x;
	d2_c=Scalar(atom_i->r, atom_j->r, atom_k->r);
      }
      d2=d2_k-d2_c*d2_c/d2_ij;
      // d2 is the squared distance between atom k and the axis ij
      if(d2 > S4_NB)goto next2; // No screening if d > 2*S
      int bond=Bond(atom_k->res, resi, store1->x, resj, d2_jk);
      if(bond){
	if(d2 > S4_BO)goto next2;
	if(d2 < S2_BO){*d2_bo=0; return(1);} // There is shadow on the axis
	S=S_BO; S2=S2_BO;
      }else{
	if(d2 < S2_NB){*d2_nb=0; return(1);}
	S=S_NB; S2=S2_NB;
      }
      float ang=asin(sqrt(d2/d2_k)); if(ang<0)ang=-ang;
      float ang1=asin(S/d_ij); if(ang1<0)ang1=-ang1;
      float ang2=ang-ang1, s2;
      if(ang2<=0){*d2_nb=0; return(1);}
      else{s2=sin(ang2); s2*=s2;} // s2=sin(ang2)^2
      if(d2_jk > store1->x){d2=s2*d2_jk;}
      else{d2=s2*store1->x;}
      if(d2<S2){*d2_nb=0; return(1);}

      /*float d2_ic=d2_k-d2;       // Sq. dist. from atom i to projection of k
      // Sq. distance from bottom of atom k to axis
      if(bond){d2=(d2+S2_BO-2*S_BO*sqrt(d2));}
      else{d2=(d2+S2_NB-2*S_NB*sqrt(d2));}
      float d2a_ij=d2*d2_ij/d2_ic; // Sq. dist. from shadow to axis at j
      if(bond){if(d2a_ij < *d2_bo)*d2_bo=d2a_ij;}
      else{if(d2a_ij < *d2_nb)*d2_nb=d2a_ij;}*/
    }
  next2:
    store1=store1->next;
  }
  return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movss %xmm0, -0x1c(%rbp)
movss %xmm1, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movss %xmm2, -0x2c(%rbp)
movq %rcx, -0x38(%rbp)
movq %r8, -0x40(%rbp)
movq %r9, -0x48(%rbp)
movq -0x38(%rbp), %rax
movl 0x64(%rax), %eax
movl %eax, -0x4c(%rbp)
movq -0x40(%rbp), %rax
movl 0x64(%rax), %eax
movl %eax, -0x50(%rbp)
movss -0x1c(%rbp), %xmm0
mulss -0x1c(%rbp), %xmm0
movss %xmm0, -0x6c(%rbp)
movss -0x20(%rbp), %xmm0
mulss -0x20(%rbp), %xmm0
movss %xmm0, -0x70(%rbp)
movss 0x4e9a0(%rip), %xmm0    # 0x7bfec
mulss -0x6c(%rbp), %xmm0
movss %xmm0, -0x74(%rbp)
movss 0x4e98e(%rip), %xmm0    # 0x7bfec
mulss -0x70(%rbp), %xmm0
movss %xmm0, -0x78(%rbp)
movss -0x2c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x1220
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x7c(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x2d9a3
movq -0x28(%rbp), %rax
movss 0x4(%rax), %xmm0
ucomiss -0x2c(%rbp), %xmm0
jbe 0x2d69e
jmp 0x2d9a3
movq -0x48(%rbp), %rax
movq -0x28(%rbp), %rcx
movslq (%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x2d990
movq -0x40(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x2db20
movss %xmm0, -0x58(%rbp)
movss -0x58(%rbp), %xmm0
ucomiss -0x2c(%rbp), %xmm0
jb 0x2d6ed
jmp 0x2d992
movss -0x58(%rbp), %xmm0
movq -0x28(%rbp), %rax
ucomiss 0x4(%rax), %xmm0
jbe 0x2d721
movss -0x58(%rbp), %xmm0
movss %xmm0, -0x5c(%rbp)
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x88(%rbp), %rdx
callq 0x2dbd0
movss %xmm0, -0x60(%rbp)
jmp 0x2d748
movq -0x28(%rbp), %rax
movss 0x4(%rax), %xmm0
movss %xmm0, -0x5c(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x88(%rbp), %rdx
callq 0x2dbd0
movss %xmm0, -0x60(%rbp)
movss -0x5c(%rbp), %xmm0
movss -0x60(%rbp), %xmm1
mulss -0x60(%rbp), %xmm1
divss -0x2c(%rbp), %xmm1
subss %xmm1, %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x54(%rbp), %xmm0
ucomiss -0x74(%rbp), %xmm0
jbe 0x2d775
jmp 0x2d992
movq -0x88(%rbp), %rax
movl 0x64(%rax), %edi
movl -0x4c(%rbp), %esi
movq -0x28(%rbp), %rax
movss 0x4(%rax), %xmm0
movl -0x50(%rbp), %edx
movss -0x58(%rbp), %xmm1
callq 0x21a70
movl %eax, -0x8c(%rbp)
cmpl $0x0, -0x8c(%rbp)
je 0x2d7f3
movss -0x54(%rbp), %xmm0
ucomiss -0x78(%rbp), %xmm0
jbe 0x2d7b7
jmp 0x2d992
movss -0x54(%rbp), %xmm1
movss -0x70(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x2d7dd
movq -0x18(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x2d9aa
movss -0x20(%rbp), %xmm0
movss %xmm0, -0x64(%rbp)
movss -0x70(%rbp), %xmm0
movss %xmm0, -0x68(%rbp)
jmp 0x2d82d
movss -0x54(%rbp), %xmm1
movss -0x6c(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x2d819
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x2d9aa
movss -0x1c(%rbp), %xmm0
movss %xmm0, -0x64(%rbp)
movss -0x6c(%rbp), %xmm0
movss %xmm0, -0x68(%rbp)
movss -0x54(%rbp), %xmm0
divss -0x5c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x1220
callq 0x11f0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x90(%rbp)
xorps %xmm0, %xmm0
ucomiss -0x90(%rbp), %xmm0
jbe 0x2d87a
movss -0x90(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movss %xmm0, -0x90(%rbp)
movss -0x64(%rbp), %xmm0
divss -0x7c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x11f0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x94(%rbp)
xorps %xmm0, %xmm0
ucomiss -0x94(%rbp), %xmm0
jbe 0x2d8c2
movss -0x94(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movss %xmm0, -0x94(%rbp)
movss -0x90(%rbp), %xmm0
subss -0x94(%rbp), %xmm0
movss %xmm0, -0x98(%rbp)
xorps %xmm0, %xmm0
ucomiss -0x98(%rbp), %xmm0
jb 0x2d8fd
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x2d9aa
movss -0x98(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x11c0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x9c(%rbp)
movss -0x9c(%rbp), %xmm0
mulss -0x9c(%rbp), %xmm0
movss %xmm0, -0x9c(%rbp)
movss -0x58(%rbp), %xmm0
movq -0x28(%rbp), %rax
ucomiss 0x4(%rax), %xmm0
jbe 0x2d955
movss -0x9c(%rbp), %xmm0
mulss -0x58(%rbp), %xmm0
movss %xmm0, -0x54(%rbp)
jmp 0x2d96b
movss -0x9c(%rbp), %xmm0
movq -0x28(%rbp), %rax
mulss 0x4(%rax), %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x54(%rbp), %xmm1
movss -0x68(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x2d98e
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x2d9aa
jmp 0x2d990
jmp 0x2d992
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x2d67f
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)