// File: /workspace/github_c_makefile_star2_O3/ugobas[P]tnm/mutation.c
// Function: Mut_neighbor
int Mut_neighbor(int *mut_neigh, int Na,
		 char *AAwt, int *Posmut, char *AAmut, int Nmut,
		 int **clist, int **cnum, struct interaction *Int_list,
		 atom *atoms, int nres)
{
  int i, iter;
  for(i=0; i<Na; i++)mut_neigh[i]=0;
  for(int kmut=0; kmut<Nmut; kmut++){
    int pmut=Posmut[kmut];
    int aaw=Code_AA(AAwt[kmut]);   // wild-type aa
    int aam=Code_AA(AAmut[kmut]);  // mutated aa
    if((aaw==20)||(aam==20)){pmut--; iter=2;} //
    else{iter=1;}
    for(int it=0; it<iter; it++){
      if(pmut<0)continue;
      if(it==1){pmut=Posmut[kmut]+1; if(pmut>=nres)continue;}
      int *ii=cnum[pmut];  // interaction label of the contact
      int *ic=clist[pmut]; // residue in contact with pmut
      while(*ic >= 0){
	//if(abs(pmut-(*ic))<3)goto next; // short range contact discarded
	int res1=atoms[Int_list[*ii].i1].res, res2=atoms[Int_list[*ii].i2].res;
	if((res1 !=pmut)&&(res2!=pmut)){
	  printf("ERROR in mutation, interaction %d res %d - %d pmut= %d\n",
		 *ii, res1, res2, pmut); exit(8);
	}
	mut_neigh[res1]=1;
	mut_neigh[res2]=1;
	ic++; ii++;
      }
    }
  }
  int n=0; for(i=0; i<Na; i++)if(mut_neigh[i])n++;
  return(n-1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, %r13d
movq %r8, 0x30(%rsp)
movq %rcx, %r11
movq %rdx, 0x28(%rsp)
movq %rdi, %rbx
movl %esi, %r14d
movl %esi, 0x8(%rsp)
testl %esi, %esi
jle 0x3d8fb
leaq (,%r14,4), %rdx
movq %rbx, %rdi
xorl %esi, %esi
movq %r11, %r15
callq 0x2110
movq %r15, %r11
movq %r14, 0x10(%rsp)
testl %r13d, %r13d
jle 0x3da10
movq 0x88(%rsp), %r12
movq 0x80(%rsp), %r14
movl %r13d, %eax
movq %rax, 0x18(%rsp)
xorl %r15d, %r15d
movl $0x1, %ebp
movq %r11, 0x20(%rsp)
movl (%r11,%r15,4), %r13d
movq 0x28(%rsp), %rax
movsbl (%rax,%r15), %edi
callq 0x1f488
movl %eax, 0xc(%rsp)
movq 0x30(%rsp), %rax
movsbl (%rax,%r15), %edi
callq 0x1f488
movq 0x20(%rsp), %r11
cmpl $0x14, 0xc(%rsp)
sete %cl
cmpl $0x14, %eax
sete %al
orb %cl, %al
movzbl %al, %ecx
subl %ecx, %r13d
movb $0x1, %dil
xorl %ecx, %ecx
testl %r13d, %r13d
js 0x3d9f2
testb $0x1, %cl
je 0x3d98f
movl (%r11,%r15,4), %r13d
incl %r13d
cmpl 0x90(%rsp), %r13d
jge 0x3da02
movslq %r13d, %rcx
movq 0x70(%rsp), %rdx
movq (%rdx,%rcx,8), %r8
cmpl $0x0, (%r8)
js 0x3d9f2
movq 0x78(%rsp), %rdx
movq (%rdx,%rcx,8), %r9
xorl %r10d, %r10d
movslq (%r9,%r10), %rsi
imulq $0xc8, %rsi, %rcx
movslq (%r14,%rcx), %rdx
imulq $0x70, %rdx, %rdx
movslq 0x64(%r12,%rdx), %rdx
movslq 0x4(%r14,%rcx), %rcx
imulq $0x70, %rcx, %rcx
movl 0x64(%r12,%rcx), %ecx
cmpl %r13d, %edx
je 0x3d9dd
cmpl %r13d, %ecx
jne 0x3da47
movslq %ecx, %rcx
movl %ebp, (%rbx,%rdx,4)
movl %ebp, (%rbx,%rcx,4)
cmpl $0x0, 0x4(%r8,%r10)
leaq 0x4(%r10), %r10
jns 0x3d9ad
movb $0x1, %cl
testb %dil, %al
movl $0x0, %edi
jne 0x3d974
incq %r15
cmpq 0x18(%rsp), %r15
jne 0x3d92e
cmpl $0x0, 0x8(%rsp)
jle 0x3da33
xorl %ecx, %ecx
xorl %eax, %eax
movq 0x10(%rsp), %rdx
cmpl $0x1, (%rbx,%rcx,4)
sbbl $-0x1, %eax
incq %rcx
cmpq %rcx, %rdx
jne 0x3da20
decl %eax
jmp 0x3da38
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1ec50(%rip), %rdi     # 0x5c69e
movl %r13d, %r8d
xorl %eax, %eax
callq 0x20f0
movl $0x8, %edi
callq 0x2280