// File: /workspace/github_c_makefile_star2_O3/ugobas[P]tnm/dof_tnm.c
// Function: Axe_prot_side
void Axe_prot_side(struct axe *axe_side, int *N_side, struct side_chain *sc,
		   struct bond *bond, int ibond,
		   atom *atoms, int natoms, int *refatom)
{
  if(bond->atom->res!=sc->res){
    // Residue start
    sc->res=bond->atom->res;
    sc->aa= bond->atom->aa;
    if((sc->aa=='G')||(sc->aa=='A')||(sc->aa=='P'))return;
    
    // Find first and last atom in side chain
    sc->first_atom=-1;
    sc->last_atom=-1;
    sc->first_ref=-1;
    sc->last_ref=-1;
    int i;
    for(i=bond->i_atom; i<natoms; i++){
      atom *atom_i=atoms+i;
      if((atom_i->res>sc->res)||
	 (strncmp(atom_i->name,"OT", 2)==0)||
	 (strncmp(atom_i->name,"OX", 2)==0))
	break;
      if((strncmp(atom_i->name,"N ", 2)==0)||
	 (strncmp(atom_i->name,"CA", 2)==0)||
	 (strncmp(atom_i->name,"CB", 2)==0))continue;
      if((strncmp(atom_i->name,"C ", 2)!=0)&&
	 (strncmp(atom_i->name,"O ", 2)!=0)){
	sc->last_atom=i;
	if(sc->first_atom<0)sc->first_atom=i;
	int iref=refatom[i];
	if(iref>=0){
	  sc->last_ref=iref; if(sc->first_ref<0)sc->first_ref=iref;
	}
      }
    }
    sc->ndof=0; sc->numdof=0; sc->oldref=0;
  }
  
  if((bond->terminal)||
     (strncmp(bond->atom->name,"N ", 2)==0)||
     (strncmp(bond->atom->name,"CA", 2)==0)||
     (strncmp(bond->atom->name,"C ", 2)==0)||
     (strncmp(bond->atom->name,"O ", 2)==0))
    return;
    
  if((sc->first_atom<0)||(sc->first_ref<0)||
     (sc->aa=='G')||(sc->aa=='A')||(sc->aa=='P'))return;
  
  if(((strncmp(bond->atom->name,"CB", 2)!=0)&&
      (strncmp(bond->atom->name,"CG", 2)==0))&&
     ((sc->aa=='F')||(sc->aa=='W')||(sc->aa=='Y')||(sc->aa=='H'))){
    return;  // if aromatic ring, exit
  }

  //sprintf(type, "%1d", sc->numdof);
  struct axe *axe=axe_side+*N_side;
  int first_atom=(Next_bond(bond, ibond, natoms))->i_atom;
  if(Set_dof(&axe, N_side, 's', bond, first_atom, &sc->ndof,
	     &sc->oldref, refatom, natoms, sc->last_atom, sc->last_ref)){
    sc->numdof++;
  }
  return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %r12
movq 0x58(%rsp), %rbp
movl 0x50(%rsp), %r14d
movq (%rcx), %rax
movl 0x64(%rax), %ecx
cmpl 0x4(%rdx), %ecx
jne 0x140cd
cmpl $0x0, 0x30(%r15)
jne 0x140e8
movzbl 0x18(%rax), %ecx
cmpl $0x43, %ecx
je 0x141cf
cmpl $0x4f, %ecx
je 0x14007
cmpl $0x4e, %ecx
jne 0x14011
cmpb $0x20, 0x19(%rax)
je 0x140e8
xorl %ecx, %ecx
cmpl $0x0, 0xc(%rbx)
js 0x140e8
cmpl $0x0, 0x10(%rbx)
js 0x140e8
movzbl (%rbx), %edx
leal -0x41(%rdx), %esi
cmpl $0xf, %esi
ja 0x14042
movl $0x8041, %r9d           # imm = 0x8041
btl %esi, %r9d
jb 0x140e8
testb %cl, %cl
je 0x14068
cmpb $0x42, 0x19(%rax)
je 0x14068
cmpb $0x47, 0x19(%rax)
jne 0x14068
addl $-0x46, %edx
cmpl $0x13, %edx
ja 0x14068
movl $0xa0005, %eax          # imm = 0xA0005
btl %edx, %eax
jb 0x140e8
movslq (%r12), %rax
imulq $0x158, %rax, %rax      # imm = 0x158
addq %rax, %rdi
leaq 0x10(%rsp), %r13
movq %rdi, (%r13)
movq %r15, %rdi
movl %r8d, %esi
movl %r14d, %edx
callq 0x14222
movl 0x20(%rax), %r8d
leaq 0x1c(%rbx), %r9
leaq 0x20(%rbx), %rax
movl 0x14(%rbx), %r10d
movl 0x18(%rbx), %r11d
subq $0x8, %rsp
movq %r13, %rdi
movq %r12, %rsi
movl $0x73, %edx
movq %r15, %rcx
pushq %r11
pushq %r10
pushq %r14
pushq %rbp
pushq %rax
callq 0x13c74
addq $0x30, %rsp
testl %eax, %eax
je 0x140e8
incl 0x24(%rbx)
jmp 0x140e8
movl %ecx, 0x4(%rbx)
movzbl 0x68(%rax), %edx
movb %dl, (%rbx)
addl $-0x41, %edx
cmpl $0xf, %edx
ja 0x140f7
movl $0x8041, %esi           # imm = 0x8041
btl %edx, %esi
jae 0x140f7
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0xc(%rbx)
movl 0x20(%r15), %edx
cmpl %r14d, %edx
jge 0x141bb
leaq 0xc(%rbx), %rsi
movq %rsi, 0x8(%rsp)
movslq %edx, %rsi
imulq $0x70, %rsi, %r10
addq %r10, %r9
addq $0x18, %r9
leaq (,%rsi,4), %r10
addq %rbp, %r10
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
cmpl %ecx, 0x4c(%r9)
jg 0x141bb
movzbl (%r9), %r13d
cmpl $0x43, %r13d
je 0x14166
cmpl $0x4e, %r13d
je 0x14174
cmpl $0x4f, %r13d
jne 0x1417b
cmpb $0x54, 0x1(%r9)
je 0x141bb
cmpb $0x58, 0x1(%r9)
jne 0x14174
jmp 0x141bb
cmpb $0x41, 0x1(%r9)
je 0x1419e
cmpb $0x42, 0x1(%r9)
je 0x1419e
cmpb $0x20, 0x1(%r9)
je 0x1419e
movl %edx, 0x14(%rbx)
testl %r11d, %r11d
jns 0x1418e
movq 0x8(%rsp), %r11
movl %edx, (%r11)
movl %edx, %r11d
movl (%r10), %r13d
testl %r13d, %r13d
js 0x1419e
movl %r13d, 0x18(%rbx)
testl %esi, %esi
js 0x141b5
movl %esi, %r13d
incl %edx
addq $0x70, %r9
addq $0x4, %r10
movl %r13d, %esi
cmpl %edx, %r14d
jne 0x1413a
jmp 0x141bb
movl %r13d, 0x10(%rbx)
jmp 0x141a1
movq $0x0, 0x1c(%rbx)
movl $0x0, 0x24(%rbx)
jmp 0x13fe5
cmpb $0x41, 0x19(%rax)
je 0x140e8
movb $0x1, %cl
cmpb $0x20, 0x19(%rax)
jne 0x14013
jmp 0x140e8