// File: /workspace/github_c_makefile_star2_O2/ugobas[P]tnm/main_tnm.c
// Function: Get_interface
int Get_interface(int *Cart_interface,
		  struct interaction *Int_list, int N_int,
		  atom *atoms, int *apo_chain_num,
		  int n_apo, struct chain *chains, int Nchain,
		  int *atom_num, int N_ref, int natoms, int nres)
{
  N_res_1=0; N_res_2=0; N_cont_long_1=0; N_cont_long_2=0;

  int atom_ref[natoms], i;
  for(i=0; i<natoms; i++)atom_ref[i]=-1;
  for(i=0; i<N_ref; i++)atom_ref[atom_num[i]]=i;
  int res_inter[nres]; for(i=0; i<nres; i++)res_inter[i]=0;
  for(i=0; i<Nchain; i++){
    if(Belong_to_apo(i, apo_chain_num, n_apo)){N_res_1+=chains[i].nres;}
    else{N_res_2+=chains[i].nres;}
  }

  struct interaction *tmp=Int_list;
  for(int k=0; k<N_int; k++){
    if(atoms[tmp->i1].chain!=atoms[tmp->i2].chain){
      int apo1=Belong_to_apo(atoms[tmp->i1].chain, apo_chain_num, n_apo);
      int apo2=Belong_to_apo(atoms[tmp->i2].chain, apo_chain_num, n_apo);
      if(apo1 && apo2){
	if(atoms[tmp->i2].res-atoms[tmp->i1].res>2)N_cont_long_1++;
      }else if(apo1==0 && apo2==0){
	if(atoms[tmp->i2].res-atoms[tmp->i1].res>2)N_cont_long_2++;
      }else if((apo1 && apo2==0)||(apo1==0 && apo2)){
	res_inter[atoms[tmp->i1].res]=1;
	res_inter[atoms[tmp->i2].res]=1;
      }
    }
    tmp++;
  }
  int nres_inter=0, natom_inter=0, N_Cart_inter=0;
  for(i=0; i<nres; i++)if(res_inter[i])nres_inter++;
  for(i=0; i<natoms; i++){
    if(res_inter[atoms[i].res] && atom_ref[i]>=0){
      natom_inter++; int k=3*atom_ref[i];
      for(int j=0; j<3; j++){
	Cart_interface[N_Cart_inter]=k; N_Cart_inter++; k++;
      }
    }
  }

  printf("Interface between %d chains and %d chains:\n", n_apo, Nchain-n_apo);
  printf("%d residues out of %d "
	 "%d atoms out of %d "
	 "%d Cartesian coordinates out of %d\n",
	 nres_inter, nres, natom_inter, natoms, N_Cart_inter, 3*N_ref);
  return(N_Cart_inter);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %r9d, -0x44(%rbp)
movq %r8, -0x80(%rbp)
movl %edx, -0x2c(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdi, -0x88(%rbp)
movl 0x30(%rbp), %edx
movl 0x38(%rbp), %edi
movl 0x28(%rbp), %esi
andl $0x0, 0x5b5a4(%rip)     # 0x64114
movq 0x20(%rbp), %rax
andl $0x0, 0x5b59d(%rip)     # 0x64118
movl 0x18(%rbp), %r9d
andl $0x0, 0x5b596(%rip)     # 0x6411c
movq 0x10(%rbp), %r14
andl $0x0, 0x5b58f(%rip)     # 0x64120
movq %rsp, %r10
leaq 0xf(,%rdx,4), %r8
andq $-0x10, %r8
subq %r8, %r10
movq %r10, %rsp
xorl %r8d, %r8d
testl %edx, %edx
movl $0x0, %r11d
cmovgl %edx, %r11d
cmpq %r8, %r11
je 0x8bc4
orl $-0x1, (%r10,%r8,4)
incq %r8
jmp 0x8bb5
xorl %r8d, %r8d
testl %esi, %esi
movl $0x0, %edx
cmovgl %esi, %edx
cmpq %r8, %rdx
je 0x8be3
movslq (%rax,%r8,4), %rsi
movl %r8d, (%r10,%rsi,4)
incq %r8
jmp 0x8bd1
movl %edi, %eax
movq %rsp, %rdx
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rdx
movq %rdx, %rsp
xorl %eax, %eax
testl %edi, %edi
movl $0x0, %esi
cmovgl %edi, %esi
cmpq %rax, %rsi
je 0x8c14
andl $0x0, (%rdx,%rax,4)
incq %rax
jmp 0x8c06
movq %rsi, -0x40(%rbp)
movq %rdx, -0x50(%rbp)
movq %r11, -0x58(%rbp)
movq %r10, -0x60(%rbp)
movq %rcx, -0x68(%rbp)
xorl %r15d, %r15d
testl %r9d, %r9d
movl $0x0, %ebx
cmovgl %r9d, %ebx
addq $0x1c, %r14
xorl %r13d, %r13d
xorl %r12d, %r12d
cmpq %r15, %rbx
je 0x8c7b
movl %r15d, %edi
movq -0x80(%rbp), %rsi
movl -0x44(%rbp), %edx
callq 0x8ea9
movl (%r14), %ecx
testl %eax, %eax
je 0x8c68
addl %ecx, %r12d
movl %r12d, 0x5b4ae(%rip)    # 0x64114
jmp 0x8c72
addl %ecx, %r13d
movl %r13d, 0x5b4a6(%rip)    # 0x64118
incq %r15
addq $0x70, %r14
jmp 0x8c41
xorl %ecx, %ecx
movl -0x2c(%rbp), %eax
testl %eax, %eax
movl $0x0, -0x70(%rbp)
cmovlel %ecx, %eax
movl $0x0, -0x6c(%rbp)
movq -0x68(%rbp), %r9
movq -0x60(%rbp), %r10
movq -0x58(%rbp), %r11
movq -0x50(%rbp), %r15
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %rdx
movq -0x80(%rbp), %rbx
subl $0x1, %eax
jb 0x8de3
movl %eax, -0x2c(%rbp)
movslq (%rcx), %rax
imulq $0x70, %rax, %rdx
movl 0x6c(%r9,%rdx), %edi
movq %rcx, -0x38(%rbp)
movslq 0x4(%rcx), %rax
imulq $0x70, %rax, %r13
movl 0x6c(%r9,%r13), %r14d
cmpl %r14d, %edi
je 0x8dcc
movq %rdx, -0x78(%rbp)
movq %rbx, %rsi
movl -0x44(%rbp), %r15d
movl %r15d, %edx
callq 0x8ea9
movl %eax, %r12d
movl %r14d, %edi
movq %rbx, %rsi
movl %r15d, %edx
callq 0x8ea9
testl %r12d, %r12d
je 0x8d40
testl %eax, %eax
je 0x8d40
movq -0x68(%rbp), %r9
movl 0x64(%r9,%r13), %eax
movq -0x78(%rbp), %rcx
subl 0x64(%r9,%rcx), %eax
cmpl $0x3, %eax
movq -0x50(%rbp), %r15
jl 0x8dc4
movl -0x70(%rbp), %eax
incl %eax
movl %eax, -0x70(%rbp)
movl %eax, 0x5b3e1(%rip)     # 0x6411c
jmp 0x8dc4
movl %r12d, %ecx
orl %eax, %ecx
jne 0x8d76
movq -0x68(%rbp), %r9
movl 0x64(%r9,%r13), %eax
movq -0x78(%rbp), %rcx
subl 0x64(%r9,%rcx), %eax
cmpl $0x3, %eax
movq -0x60(%rbp), %r10
movq -0x58(%rbp), %r11
jl 0x8d9d
movl -0x6c(%rbp), %eax
incl %eax
movl %eax, -0x6c(%rbp)
movl %eax, 0x5b3ac(%rip)     # 0x64120
jmp 0x8d9d
testl %eax, %eax
sete %dl
setne %al
testl %r12d, %r12d
sete %cl
setne %sil
testb %dl, %sil
jne 0x8da3
andb %al, %cl
jne 0x8da3
movq -0x68(%rbp), %r9
movq -0x60(%rbp), %r10
movq -0x58(%rbp), %r11
movq -0x50(%rbp), %r15
jmp 0x8dcc
movq -0x68(%rbp), %r9
movq -0x78(%rbp), %rax
movslq 0x64(%r9,%rax), %rax
movq -0x50(%rbp), %r15
pushq $0x1
popq %rcx
movl %ecx, (%r15,%rax,4)
movslq 0x64(%r9,%r13), %rax
movl %ecx, (%r15,%rax,4)
movq -0x60(%rbp), %r10
movq -0x58(%rbp), %r11
movl -0x2c(%rbp), %eax
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %rdx
addq $0xc8, %rcx
jmp 0x8caf
xorl %eax, %eax
xorl %ebx, %ebx
cmpq %rax, %rdx
je 0x8df9
cmpl $0x1, (%r15,%rax,4)
sbbl $-0x1, %ebx
incq %rax
jmp 0x8de7
xorl %eax, %eax
xorl %r13d, %r13d
xorl %r14d, %r14d
cmpq %r11, %rax
je 0x8e55
imulq $0x70, %rax, %rcx
movslq 0x64(%r9,%rcx), %rcx
cmpl $0x0, (%r15,%rcx,4)
je 0x8e50
movl (%r10,%rax,4), %ecx
testl %ecx, %ecx
js 0x8e50
leal (%rcx,%rcx,2), %ecx
movslq %r14d, %rsi
leal 0x3(%rsi), %r14d
movslq %r14d, %rdx
subq %rsi, %rdx
movq -0x88(%rbp), %rdi
leaq (%rdi,%rsi,4), %rsi
xorl %edi, %edi
cmpq %rdi, %rdx
je 0x8e4d
leaq (%rcx,%rdi), %r8
movl %r8d, (%rsi,%rdi,4)
incq %rdi
jmp 0x8e3b
incl %r13d
incq %rax
jmp 0x8e01
movl -0x44(%rbp), %esi
movl 0x18(%rbp), %edx
subl %esi, %edx
leaq 0x45f92(%rip), %rdi     # 0x4edf6
xorl %eax, %eax
callq 0x20f0
movl 0x28(%rbp), %eax
leal (%rax,%rax,2), %r10d
subq $0x8, %rsp
leaq 0x45fa5(%rip), %rdi     # 0x4ee22
movl %ebx, %esi
movl 0x38(%rbp), %edx
movl %r13d, %ecx
movl 0x30(%rbp), %r8d
movl %r14d, %r9d
xorl %eax, %eax
pushq %r10
callq 0x20f0
popq %rcx
popq %rdx
movl %r14d, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq