// File: /workspace/github_c_makefile_star2_O3/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, 0x28(%rsp)
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, 0x30(%rsp)
movq %rdi, %r12
movq 0x70(%rsp), %r13
movl %r8d, 0x8(%rsp)
movslq %r8d, %r14
imulq $0xc8, %r14, %rdi
callq 0x21e0
movq %rax, 0x20(%rsp)
xorl %eax, %eax
movq %r12, 0x18(%rsp)
movl %eax, (%r12)
movq %r15, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
movl %eax, (%r15)
movl 0x78(%rsp), %ebp
testl %r14d, %r14d
jle 0x8ec1
xorl %r15d, %r15d
movq %rbx, %r12
cmpl $0x0, 0x78(%rsp)
setle %cl
movslq (%r12), %rax
imulq $0x70, %rax, %rax
movq 0x28(%rsp), %rsi
movl 0x6c(%rsi,%rax), %edx
movslq 0x4(%r12), %rax
imulq $0x70, %rax, %rax
movl 0x6c(%rsi,%rax), %eax
cmpl %eax, %edx
sete %sil
orb %cl, %sil
je 0x8e48
movq %rbx, %r13
movq 0x18(%rsp), %rbx
movslq (%rbx), %r14
imulq $0xc8, %r14, %rdi
addq 0x20(%rsp), %rdi
movl $0xc8, %edx
movq %r12, %rsi
callq 0x21b0
movq %rbx, %rax
movq %r13, %rbx
movq 0x70(%rsp), %r13
jmp 0x8ea6
movl (%r13), %esi
movb $0x1, %cl
cmpl %edx, %esi
je 0x8e70
movl $0x1, %edi
movq %rdi, %rcx
cmpq %rdi, %rbp
je 0x8e6a
leaq 0x1(%rcx), %rdi
cmpl %edx, (%r13,%rcx,4)
jne 0x8e57
cmpq %rbp, %rcx
setb %cl
cmpl %eax, %esi
jne 0x8e7a
testb %cl, %cl
jne 0x8e17
jmp 0x8e9e
movl $0x1, %esi
movq %rsi, %rdx
cmpq %rsi, %rbp
je 0x8e92
leaq 0x1(%rdx), %rsi
cmpl %eax, (%r13,%rdx,4)
jne 0x8e7f
cmpq %rbp, %rdx
sbbb $0x0, %cl
je 0x8e17
movq 0x10(%rsp), %rax
movl (%rax), %r14d
incl %r14d
movl %r14d, (%rax)
addq $0xc8, %r12
incl %r15d
cmpl 0x8(%rsp), %r15d
jne 0x8de6
movl 0x8(%rsp), %r12d
movl %r12d, %esi
movq 0x18(%rsp), %rax
subl (%rax), %esi
movl 0x78(%rsp), %edx
movl 0x80(%rsp), %ecx
subl %edx, %ecx
leaq 0x4bf71(%rip), %rdi     # 0x54e55
xorl %eax, %eax
callq 0x20f0
movq 0x10(%rsp), %rax
movslq (%rax), %r14
imulq $0xc8, %r14, %rdi
callq 0x21e0
movq %rax, %r15
movq 0x30(%rsp), %rax
movq %r15, (%rax)
testl %r12d, %r12d
jle 0x8fd6
xorl %r12d, %r12d
xorl %r14d, %r14d
cmpl $0x0, 0x78(%rsp)
setle %cl
movslq (%rbx), %rax
imulq $0x70, %rax, %rax
movq 0x28(%rsp), %rsi
movl 0x6c(%rsi,%rax), %edx
movslq 0x4(%rbx), %rax
imulq $0x70, %rax, %rax
movl 0x6c(%rsi,%rax), %eax
cmpl %eax, %edx
sete %sil
orb %cl, %sil
jne 0x8fb4
movl (%r13), %esi
movb $0x1, %cl
cmpl %edx, %esi
je 0x8f70
movl $0x1, %edi
movq %rdi, %rcx
cmpq %rdi, %rbp
je 0x8f6a
leaq 0x1(%rcx), %rdi
cmpl %edx, (%r13,%rcx,4)
jne 0x8f57
cmpq %rbp, %rcx
setb %cl
cmpl %eax, %esi
jne 0x8f7a
testb %cl, %cl
je 0x8f9a
jmp 0x8fb4
movl $0x1, %esi
movq %rsi, %rdx
cmpq %rsi, %rbp
je 0x8f92
leaq 0x1(%rdx), %rsi
cmpl %eax, (%r13,%rdx,4)
jne 0x8f7f
cmpq %rbp, %rdx
sbbb $0x0, %cl
je 0x8fb4
movl $0xc8, %edx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x21b0
addq $0xc8, %r15
incl %r14d
addq $0xc8, %rbx
incl %r12d
cmpl 0x8(%rsp), %r12d
jne 0x8f19
movl %r14d, 0xc(%rsp)
movq 0x10(%rsp), %rax
movl (%rax), %r14d
cmpl %r14d, 0xc(%rsp)
jne 0x8ff1
movq 0x20(%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4c9c4(%rip), %rdi     # 0x559bc
callq 0x2090
movl $0x8, %edi
callq 0x2280