// File: /workspace/github_c_makefile_star2_O1/ugobas[P]tnm/main_tnm.c
// Function: Apo_interactions
struct interaction *Apo_interactions(int *N_int_apo,
				     struct interaction **Int_list_inter,
				     int *N_int_inter,
				     struct interaction *Int_list, int N_int,
				     atom *atoms, int *apo_chain_num,
				     int n_apo, int Nchain)
{
  struct interaction *Int_list_apo=
    malloc(N_int*sizeof(struct interaction)), *tmp=Int_list;
  *N_int_apo=0; *N_int_inter=0;
  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==0) || (apo1==0 && apo2)){
	(*N_int_inter)++; goto next_int;
      }
    }
    Int_list_apo[*N_int_apo]=*tmp; (*N_int_apo)++; 
  next_int:
    tmp++;
  }
  printf("%d interactions belong to the interface "
	 "between %d chains and %d chains\n",
	 N_int-*N_int_apo, n_apo, Nchain-n_apo);

  *Int_list_inter=malloc(*N_int_inter*sizeof(struct interaction));
  int n=0; tmp=Int_list; struct interaction *store=*Int_list_inter;
  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==0) || (apo1==0 && apo2)){
	*store=*tmp; store++; n++; 
      }
    }
    tmp++;
  }
  if(n!=*N_int_inter){printf("ERROR of Interface interactions\n"); exit(8);}

  return(Int_list_apo);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %rbx
movq %rcx, %r13
movq %rdx, %r15
movq %rsi, 0x28(%rsp)
movq %rdi, %rbp
movl 0x78(%rsp), %r12d
movl %r8d, 0xc(%rsp)
movslq %r8d, %r14
imulq $0xc8, %r14, %rdi
callq 0x21d0
movl %r12d, %edx
movq %rax, 0x18(%rsp)
xorl %eax, %eax
movq %rbp, 0x20(%rsp)
movl %eax, (%rbp)
movq %r15, 0x10(%rsp)
movl $0x0, 0x8(%rsp)
movl %eax, (%r15)
movl %r12d, %ebp
testl %r14d, %r14d
jle 0x8ed1
testl %edx, %edx
setg 0x7(%rsp)
xorl %r14d, %r14d
movq %r13, %r15
movq %r13, 0x30(%rsp)
movq 0x20(%rsp), %r12
movslq (%r15), %rax
imulq $0x70, %rax, %rax
movl 0x6c(%rbx,%rax), %edi
movslq 0x4(%r15), %rax
imulq $0x70, %rax, %rax
movl 0x6c(%rbx,%rax), %eax
cmpl %eax, %edi
je 0x8e89
movb 0x7(%rsp), %cl
testl %edx, %edx
movq 0x70(%rsp), %r8
jle 0x8e3e
movb $0x1, %cl
cmpl %edi, (%r8)
je 0x8e3e
movl $0x1, %esi
movq %rsi, %rcx
cmpq %rsi, %rbp
je 0x8e38
leaq 0x1(%rcx), %rsi
cmpl %edi, (%r8,%rcx,4)
jne 0x8e26
cmpq %rbp, %rcx
setb %cl
movb 0x7(%rsp), %sil
testl %edx, %edx
jle 0x8e6d
movb $0x1, %sil
cmpl %eax, (%r8)
je 0x8e6d
movl $0x1, %esi
movq %rsi, %rdi
cmpq %rsi, %rbp
je 0x8e66
leaq 0x1(%rdi), %rsi
cmpl %eax, (%r8,%rdi,4)
jne 0x8e54
cmpq %rbp, %rdi
setb %sil
xorl %eax, %eax
cmpb %sil, %cl
je 0x8e80
movq 0x10(%rsp), %rax
incl (%rax)
movl $0x5, %eax
cmpl $0x5, %eax
je 0x8ebc
testl %eax, %eax
jne 0x8ed1
movq %rbx, %r13
movslq (%r12), %rbx
imulq $0xc8, %rbx, %rdi
addq 0x18(%rsp), %rdi
movl $0xc8, %edx
movq %r15, %rsi
callq 0x21a0
movl 0x78(%rsp), %edx
leal 0x1(%rbx), %eax
movq %r13, %rbx
movq 0x30(%rsp), %r13
movl %eax, (%r12)
addq $0xc8, %r15
incl %r14d
cmpl 0xc(%rsp), %r14d
jne 0x8df2
movl 0xc(%rsp), %r14d
movl %r14d, %esi
movq 0x20(%rsp), %rax
subl (%rax), %esi
movl 0x80(%rsp), %ecx
subl %edx, %ecx
leaq 0x4bf39(%rip), %rdi     # 0x54e29
xorl %eax, %eax
callq 0x20f0
movq 0x10(%rsp), %rax
movslq (%rax), %rax
imulq $0xc8, %rax, %rdi
callq 0x21d0
movl 0x78(%rsp), %edi
movq %rax, %r12
movq 0x28(%rsp), %rax
movq %r12, (%rax)
testl %r14d, %r14d
movq 0x70(%rsp), %r8
jle 0x8fe8
testl %edi, %edi
setg %r15b
xorl %r14d, %r14d
movl $0x0, 0x8(%rsp)
movslq (%r13), %rax
imulq $0x70, %rax, %rax
movl 0x6c(%rbx,%rax), %edx
movslq 0x4(%r13), %rax
imulq $0x70, %rax, %rax
movl 0x6c(%rbx,%rax), %eax
cmpl %eax, %edx
je 0x8fd3
movl %r15d, %ecx
testl %edi, %edi
jle 0x8f80
movb $0x1, %cl
cmpl %edx, (%r8)
je 0x8f80
movl $0x1, %esi
movq %rsi, %rcx
cmpq %rsi, %rbp
je 0x8f7a
leaq 0x1(%rcx), %rsi
cmpl %edx, (%r8,%rcx,4)
jne 0x8f68
cmpq %rbp, %rcx
setb %cl
movl %r15d, %edx
testl %edi, %edi
jle 0x8fab
movb $0x1, %dl
cmpl %eax, (%r8)
je 0x8fab
movl $0x1, %esi
movq %rsi, %rdx
cmpq %rsi, %rbp
je 0x8fa5
leaq 0x1(%rdx), %rsi
cmpl %eax, (%r8,%rdx,4)
jne 0x8f93
cmpq %rbp, %rdx
setb %dl
cmpb %dl, %cl
je 0x8fd3
movl $0xc8, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x21a0
movq 0x70(%rsp), %r8
movl 0x78(%rsp), %edi
addq $0xc8, %r12
incl 0x8(%rsp)
addq $0xc8, %r13
incl %r14d
cmpl 0xc(%rsp), %r14d
jne 0x8f39
movq 0x10(%rsp), %rax
movl 0x8(%rsp), %ecx
cmpl (%rax), %ecx
jne 0x9009
movq 0x18(%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4c980(%rip), %rdi     # 0x55990
callq 0x2090
movl $0x8, %edi
callq 0x2270