// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movl %r9d, %r14d
movq %r8, %r12
movq %rcx, %r15
movl %edx, -0x2c(%rbp)
movq %rsi, %r13
movq %rdi, -0x50(%rbp)
movl 0x30(%rbp), %ecx
movl 0x28(%rbp), %ebx
xorl %eax, %eax
movl %eax, 0x600c3(%rip)     # 0x69114
movl %eax, 0x600c1(%rip)     # 0x69118
movl %eax, 0x600bf(%rip)     # 0x6911c
movl %eax, 0x600bd(%rip)     # 0x69120
movq %rsp, %rdi
leaq 0xf(,%rcx,4), %rax
andq $-0x10, %rax
subq %rax, %rdi
movq %rdi, %rsp
movl %ecx, %eax
testl %ecx, %ecx
movq %rdi, -0x40(%rbp)
movq %rax, -0x48(%rbp)
jle 0x909c
leaq (,%rax,4), %rdx
movl $0xff, %esi
callq 0x2110
movq -0x40(%rbp), %rdi
testl %ebx, %ebx
jle 0x90b7
movq 0x20(%rbp), %rax
movl %ebx, %ecx
xorl %edx, %edx
movslq (%rax,%rdx,4), %rsi
movl %edx, (%rdi,%rsi,4)
incq %rdx
cmpq %rdx, %rcx
jne 0x90a8
movl 0x38(%rbp), %ecx
movl %ecx, %edx
movq %rsp, %rbx
leaq 0xf(,%rdx,4), %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
testl %ecx, %ecx
movq %rdx, -0x38(%rbp)
jle 0x90ef
movq -0x38(%rbp), %rax
leaq (,%rax,4), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2110
movl %r14d, %eax
cmpl $0x0, 0x18(%rbp)
movl %r14d, -0x30(%rbp)
jle 0x9171
movq 0x10(%rbp), %rcx
testl %r14d, %r14d
setg %dl
movl 0x18(%rbp), %esi
xorl %edi, %edi
leaq 0x60002(%rip), %r8      # 0x69114
leaq 0x5ffff(%rip), %r9      # 0x69118
movl %edx, %r10d
testl %r14d, %r14d
jle 0x9153
movl (%r12), %r11d
movq %r8, %r10
cmpq %r11, %rdi
je 0x915d
movl $0x1, %r11d
movq %r11, %r10
cmpq %r11, %rax
je 0x9148
movl (%r12,%r10,4), %r14d
leaq 0x1(%r10), %r11
cmpq %r14, %rdi
jne 0x9133
cmpq %rax, %r10
setb %r10b
movl -0x30(%rbp), %r14d
testb %r10b, %r10b
movq %r9, %r10
cmovneq %r8, %r10
imulq $0x70, %rdi, %r11
movl 0x1c(%rcx,%r11), %r11d
addl %r11d, (%r10)
incq %rdi
cmpq %rsi, %rdi
jne 0x9119
movl -0x2c(%rbp), %r10d
testl %r10d, %r10d
jle 0x9299
testl %r14d, %r14d
setg %cl
xorl %edx, %edx
movslq (%r13), %rsi
imulq $0x70, %rsi, %rdi
movl 0x6c(%r15,%rdi), %r11d
movslq 0x4(%r13), %rsi
imulq $0x70, %rsi, %r8
movl 0x6c(%r15,%r8), %r9d
cmpl %r9d, %r11d
jne 0x91b8
addq $0xc8, %r13
incl %edx
cmpl %r10d, %edx
jne 0x9186
jmp 0x9299
movl %ecx, %r10d
testl %r14d, %r14d
jle 0x91e7
movb $0x1, %r10b
cmpl %r11d, (%r12)
je 0x91e7
movl $0x1, %esi
movq %rsi, %r10
cmpq %rsi, %rax
je 0x91e0
leaq 0x1(%r10), %rsi
cmpl %r11d, (%r12,%r10,4)
jne 0x91ce
cmpq %rax, %r10
setb %r10b
movl %ecx, %r11d
testl %r14d, %r14d
jle 0x9216
movb $0x1, %r11b
cmpl %r9d, (%r12)
je 0x9216
movl $0x1, %esi
movq %rsi, %r11
cmpq %rsi, %rax
je 0x920f
leaq 0x1(%r11), %rsi
cmpl %r9d, (%r12,%r11,4)
jne 0x91fd
cmpq %rax, %r11
setb %r11b
movl %r10d, %esi
andb %r11b, %sil
cmpb $0x1, %sil
jne 0x9244
movl 0x64(%r15,%r8), %esi
subl 0x64(%r15,%rdi), %esi
cmpl $0x3, %esi
movl -0x2c(%rbp), %r10d
jl 0x91a5
incl 0x5fedd(%rip)           # 0x6911c
jmp 0x91a5
movl %r10d, %esi
orb %r11b, %sil
testb $0x1, %sil
je 0x9277
cmpb %r11b, %r10b
movl -0x2c(%rbp), %r10d
je 0x91a5
movslq 0x64(%r15,%rdi), %rsi
movl $0x1, %edi
movl %edi, (%rbx,%rsi,4)
movslq 0x64(%r15,%r8), %rsi
movl %edi, (%rbx,%rsi,4)
jmp 0x91a5
movl 0x64(%r15,%r8), %esi
subl 0x64(%r15,%rdi), %esi
cmpl $0x3, %esi
movl -0x2c(%rbp), %r10d
jl 0x91a5
incl 0x5fe8c(%rip)           # 0x69120
jmp 0x91a5
xorl %r12d, %r12d
movl $0x0, %r13d
cmpl $0x0, 0x38(%rbp)
movq -0x50(%rbp), %r8
movq -0x40(%rbp), %r9
movq -0x38(%rbp), %rcx
jle 0x92c9
xorl %eax, %eax
xorl %r13d, %r13d
cmpl $0x1, (%rbx,%rax,4)
sbbl $-0x1, %r13d
incq %rax
cmpq %rax, %rcx
jne 0x92b9
movl $0x0, %r14d
movl 0x30(%rbp), %eax
testl %eax, %eax
movq -0x48(%rbp), %r10
jle 0x9321
xorl %eax, %eax
xorl %r14d, %r14d
xorl %r12d, %r12d
imulq $0x70, %rax, %rcx
movslq 0x64(%r15,%rcx), %rcx
cmpl $0x0, (%rbx,%rcx,4)
je 0x9319
movl (%r9,%rax,4), %ecx
testl %ecx, %ecx
js 0x9319
leal (%rcx,%rcx,2), %ecx
movslq %r14d, %rdx
leaq (%r8,%rdx,4), %rsi
xorl %edx, %edx
leal (%rcx,%rdx), %edi
movl %edi, (%rsi,%rdx,4)
incq %rdx
cmpl $0x3, %edx
jne 0x9305
incl %r12d
addl %edx, %r14d
incq %rax
cmpq %r10, %rax
jne 0x92e2
movl -0x30(%rbp), %esi
movl 0x18(%rbp), %edx
subl %esi, %edx
leaq 0x4bb42(%rip), %rdi     # 0x54e72
xorl %eax, %eax
callq 0x20f0
movl 0x28(%rbp), %eax
leal (%rax,%rax,2), %r10d
subq $0x8, %rsp
leaq 0x4bb55(%rip), %rdi     # 0x54e9e
movl %r13d, %esi
movl 0x38(%rbp), %edx
movl %r12d, %ecx
movl 0x30(%rbp), %r8d
movl %r14d, %r9d
xorl %eax, %eax
pushq %r10
callq 0x20f0
addq $0x10, %rsp
movl %r14d, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq