// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/contacts.c
// Function: Contact_overlap
float Contact_overlap(struct interaction *Int_list1, int N_int1,
		      struct interaction *Int_list2, int N_int2, int *alires)
{
  // Make contact matrix 1
  short *cont1_i, *cont1_j; int Nc1=N_int1;
  Write_contact_list(&cont1_i, &cont1_j, Int_list1, &Nc1);
  short *cont2_i, *cont2_j; int Nc2=N_int2;
  Write_contact_list(&cont2_i, &cont2_j, Int_list2, &Nc2);
  printf("Computing contact overlap\n");
  printf("Initial number of contacts: PDB1 %d PDB2 %d\n", N_int1, N_int2);
  printf("After identifying residues: PDB1 %d PDB2 %d\n", Nc1, Nc2);
  int k;
  for(k=0; k<Nc1; k++){
    cont1_i[k]=alires[cont1_i[k]];
    cont1_j[k]=alires[cont1_j[k]];
  }
  int overlap=0, k2=0;
  for(k=0; k<Nc1; k++){
    if((cont1_i[k]<0)||(cont1_j[k]<0))continue;
    while((k2<Nc2)&&(cont2_i[k2] < cont1_i[k]))k2++;
    while((k2<Nc2)&&(cont2_i[k2]== cont1_i[k])&&
	  (cont2_j[k2] < cont1_j[k]))k2++;
    if((cont1_i[k]==cont2_i[k2])&&(cont1_j[k]==cont2_j[k2])){
      overlap++; k2++;
    }
  }
  free(cont1_i);free(cont1_j); //modyves: was never freed
  free(cont2_i);free(cont2_j); //modyves: was never freed
  float q=(float)overlap/sqrt((float)(Nc1*Nc2));
  printf("Contact overlap: %.3f\n", q);
  return(q);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rdx
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x3c(%rbp), %rcx
callq 0x2bb50
movl -0x1c(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rdx
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x54(%rbp), %rcx
callq 0x2bb50
leaq 0x51cb1(%rip), %rdi     # 0x7d5a8
movb $0x0, %al
callq 0x10d0
movl -0xc(%rbp), %esi
movl -0x1c(%rbp), %edx
leaq 0x51cb8(%rip), %rdi     # 0x7d5c3
movb $0x0, %al
callq 0x10d0
movl -0x3c(%rbp), %esi
movl -0x54(%rbp), %edx
leaq 0x51cd1(%rip), %rdi     # 0x7d5f0
movb $0x0, %al
callq 0x10d0
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x2b986
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
movslq -0x58(%rbp), %rdx
movswq (%rcx,%rdx,2), %rcx
movl (%rax,%rcx,4), %eax
movw %ax, %dx
movq -0x30(%rbp), %rax
movslq -0x58(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movq -0x28(%rbp), %rax
movq -0x38(%rbp), %rcx
movslq -0x58(%rbp), %rdx
movswq (%rcx,%rdx,2), %rcx
movl (%rax,%rcx,4), %eax
movw %ax, %dx
movq -0x38(%rbp), %rax
movslq -0x58(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x2b92d
movl $0x0, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x2bacf
movq -0x30(%rbp), %rax
movslq -0x58(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
jl 0x2b9c9
movq -0x38(%rbp), %rax
movslq -0x58(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
jge 0x2b9ce
jmp 0x2bac1
jmp 0x2b9d0
movl -0x60(%rbp), %ecx
xorl %eax, %eax
cmpl -0x54(%rbp), %ecx
movb %al, -0x65(%rbp)
jge 0x2b9fd
movq -0x48(%rbp), %rax
movslq -0x60(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movq -0x30(%rbp), %rcx
movslq -0x58(%rbp), %rdx
movswl (%rcx,%rdx,2), %ecx
cmpl %ecx, %eax
setl %al
movb %al, -0x65(%rbp)
movb -0x65(%rbp), %al
testb $0x1, %al
jne 0x2ba06
jmp 0x2ba11
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x2b9d0
jmp 0x2ba13
movl -0x60(%rbp), %ecx
xorl %eax, %eax
cmpl -0x54(%rbp), %ecx
movb %al, -0x66(%rbp)
jge 0x2ba61
movq -0x48(%rbp), %rax
movslq -0x60(%rbp), %rcx
movswl (%rax,%rcx,2), %ecx
movq -0x30(%rbp), %rax
movslq -0x58(%rbp), %rdx
movswl (%rax,%rdx,2), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x66(%rbp)
jne 0x2ba61
movq -0x50(%rbp), %rax
movslq -0x60(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movq -0x38(%rbp), %rcx
movslq -0x58(%rbp), %rdx
movswl (%rcx,%rdx,2), %ecx
cmpl %ecx, %eax
setl %al
movb %al, -0x66(%rbp)
movb -0x66(%rbp), %al
testb $0x1, %al
jne 0x2ba6a
jmp 0x2ba75
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x2ba13
movq -0x30(%rbp), %rax
movslq -0x58(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movq -0x48(%rbp), %rcx
movslq -0x60(%rbp), %rdx
movswl (%rcx,%rdx,2), %ecx
cmpl %ecx, %eax
jne 0x2babf
movq -0x38(%rbp), %rax
movslq -0x58(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movq -0x50(%rbp), %rcx
movslq -0x60(%rbp), %rdx
movswl (%rcx,%rdx,2), %ecx
cmpl %ecx, %eax
jne 0x2babf
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x2bac1
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x2b99b
movq -0x30(%rbp), %rdi
callq 0x1040
movq -0x38(%rbp), %rdi
callq 0x1040
movq -0x48(%rbp), %rdi
callq 0x1040
movq -0x50(%rbp), %rdi
callq 0x1040
cvtsi2ssl -0x5c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
movl -0x3c(%rbp), %eax
imull -0x54(%rbp), %eax
cvtsi2ss %eax, %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x1220
movaps %xmm0, %xmm1
movsd -0x70(%rbp), %xmm0
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x64(%rbp)
movss -0x64(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x51ae3(%rip), %rdi     # 0x7d61d
movb $0x1, %al
callq 0x10d0
movss -0x64(%rbp), %xmm0
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)