// File: /workspace/github_c_makefile_star2_O1/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 0x3d92d
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 0x3da41
movq 0x88(%rsp), %r12
movq 0x80(%rsp), %r14
movl %r13d, %eax
movq %rax, 0x18(%rsp)
xorl %ebp, %ebp
movl $0x1, %r15d
movq %r11, 0x20(%rsp)
movl (%r11,%rbp,4), %r13d
movq 0x28(%rsp), %rax
movsbl (%rax,%rbp), %edi
callq 0x1fbd8
movl %eax, 0xc(%rsp)
movq 0x30(%rsp), %rax
movsbl (%rax,%rbp), %edi
callq 0x1fbd8
movq 0x20(%rsp), %r11
cmpl $0x14, 0xc(%rsp)
sete %cl
cmpl $0x14, %eax
sete %al
orb %cl, %al
movzbl %al, %ecx
subl %ecx, %r13d
xorl %edi, %edi
testl %r13d, %r13d
js 0x3da21
cmpl $0x1, %edi
jne 0x3d9bc
movl (%r11,%rbp,4), %r13d
incl %r13d
cmpl 0x90(%rsp), %r13d
jge 0x3da21
movslq %r13d, %rcx
movq 0x70(%rsp), %rdx
movq (%rdx,%rcx,8), %r8
cmpl $0x0, (%r8)
js 0x3da21
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 0x3da0a
cmpl %r13d, %ecx
jne 0x3da78
movslq %ecx, %rcx
movl %r15d, (%rbx,%rdx,4)
movl %r15d, (%rbx,%rcx,4)
cmpl $0x0, 0x4(%r8,%r10)
leaq 0x4(%r10), %r10
jns 0x3d9da
testl %edi, %edi
leal 0x1(%rdi), %ecx
sete %dl
movl %ecx, %edi
testb %dl, %al
jne 0x3d9a1
incq %rbp
cmpq 0x18(%rsp), %rbp
jne 0x3d960
cmpl $0x0, 0x8(%rsp)
jle 0x3da64
xorl %ecx, %ecx
xorl %eax, %eax
movq 0x10(%rsp), %rdx
cmpl $0x1, (%rbx,%rcx,4)
sbbl $-0x1, %eax
incq %rcx
cmpq %rcx, %rdx
jne 0x3da51
decl %eax
jmp 0x3da69
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1ec5f(%rip), %rdi     # 0x5c6de
movl %r13d, %r8d
xorl %eax, %eax
callq 0x20f0
movl $0x8, %edi
callq 0x2270