// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movl 0x30(%rbp), %eax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x578db
movq -0x8(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x578b9
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x57aa0
movq -0x20(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %edi
callq 0x2bec0
movl %eax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %edi
callq 0x2bec0
movl %eax, -0x44(%rbp)
cmpl $0x14, -0x40(%rbp)
je 0x57930
cmpl $0x14, -0x44(%rbp)
jne 0x57942
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
movl $0x2, -0x34(%rbp)
jmp 0x57949
movl $0x1, -0x34(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x57a90
cmpl $0x0, -0x3c(%rbp)
jge 0x57967
jmp 0x57a82
cmpl $0x1, -0x48(%rbp)
jne 0x5798d
movq -0x20(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl 0x30(%rbp), %eax
jl 0x5798b
jmp 0x57a82
jmp 0x5798d
movq 0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
movq 0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpl $0x0, (%rax)
jl 0x57a80
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rcx
movq -0x50(%rbp), %rdx
movslq (%rdx), %rdx
imulq $0xc8, %rdx, %rdx
addq %rdx, %rcx
movslq (%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x64(%rax), %eax
movl %eax, -0x5c(%rbp)
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rcx
movq -0x50(%rbp), %rdx
movslq (%rdx), %rdx
imulq $0xc8, %rdx, %rdx
addq %rdx, %rcx
movslq 0x4(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x64(%rax), %eax
movl %eax, -0x60(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
je 0x57a45
movl -0x60(%rbp), %eax
cmpl -0x3c(%rbp), %eax
je 0x57a45
movq -0x50(%rbp), %rax
movl (%rax), %esi
movl -0x5c(%rbp), %edx
movl -0x60(%rbp), %ecx
movl -0x3c(%rbp), %r8d
leaq 0x2a010(%rip), %rdi     # 0x81a44
movb $0x0, %al
callq 0x10d0
movl $0x8, %edi
callq 0x1210
movq -0x8(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movslq -0x60(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0x58(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rbp)
jmp 0x579ad
jmp 0x57a82
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x57950
jmp 0x57a92
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x578e2
movl $0x0, -0x64(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x57ada
movq -0x8(%rbp), %rax
movslq -0x30(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x57acd
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x57acf
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x57aae
movl -0x64(%rbp), %eax
subl $0x1, %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)