// File: /workspace/github_c_makefile_star2_O2/ugobas[P]tnm/interactions_tnm.c
// Function: Print_contact_matrix
void Print_contact_matrix(struct interaction *Int_list, int N_int,
			  atom *atoms, struct residue *res,
			  char *name, char *pdb)
{
  char nameout[100]; sprintf(nameout, "%s_%s_Cont_Mat.txt", pdb,name);
  FILE *file_out=fopen(nameout, "w");
  printf("Writing contact matrix in %s\n", nameout);
  int i, SCR=0, ALL=1;
  if((strncmp(name,"SCR",3)==0))SCR=1;
  if((strncmp(name,"CA",2)==0)||(strncmp(name,"CB",2)==0)||
     (strncmp(name,"SCA",3)==0)||(strncmp(name,"SCB",3)==0))ALL=0;
  fprintf(file_out, "#res1\tres2\td");
  if(SCR)fprintf(file_out, "\tw");
  if(ALL)fprintf(file_out, "\tatom1\tatom2");
  fprintf(file_out, "\tcontacts=%d\n",N_int);
  for(i=0; i<N_int; i++){
    int ij=abs(atoms[Int_list[i].i1].res-atoms[Int_list[i].i2].res);
    if(ij<=2)continue;
    fprintf(file_out, "%s\t%s\t%.2f",
	    res[atoms[Int_list[i].i1].res].pdbres,
	    res[atoms[Int_list[i].i2].res].pdbres,
	    Int_list[i].r0);
    if(SCR)fprintf(file_out, "\t%.4f", Int_list[i].sec_der);
    if(ALL)fprintf(file_out, "\t%s\t%s",
		   atoms[Int_list[i].i1].name,
		   atoms[Int_list[i].i2].name);
    fprintf(file_out, "\n");
  }
  fclose(file_out);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r8, %rbp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, 0x8(%rsp)
movq %rdi, %r15
leaq 0x39725(%rip), %rsi     # 0x51111
movl $0x0, 0x4(%rsp)
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movq %r9, %rdx
movq %r8, %rcx
xorl %eax, %eax
callq 0x2260
leaq 0x39740(%rip), %rsi     # 0x51150
movq %r13, %rdi
callq 0x2210
movq %rax, %r12
leaq 0x39702(%rip), %rdi     # 0x51124
movq %r13, %rsi
xorl %eax, %eax
callq 0x20f0
movzbl (%rbp), %eax
cmpl $0x43, %eax
je 0x17a54
movl $0x0, (%rsp)
cmpl $0x53, %eax
jne 0x17aa1
cmpb $0x43, 0x1(%rbp)
jne 0x17a6b
cmpb $0x52, 0x2(%rbp)
sete %al
movl %eax, 0x4(%rsp)
jmp 0x17a73
movb $0x1, %al
movl %eax, (%rsp)
movl $0x0, 0x4(%rsp)
cmpb $0x41, 0x1(%rbp)
je 0x17aa1
pushq $0x1
jmp 0x17a8c
movl $0x0, 0x4(%rsp)
cmpb $0x43, 0x1(%rbp)
jne 0x17a84
movb $0x1, %al
movl %eax, (%rsp)
cmpb $0x41, 0x2(%rbp)
je 0x17aa1
cmpb $0x43, 0x1(%rbp)
jne 0x17a9a
pushq $0x2
popq %rax
cmpb $0x42, (%rbp,%rax)
sete %al
movl %eax, (%rsp)
jmp 0x17aa1
movl $0x0, (%rsp)
leaq 0x3969a(%rip), %rdi     # 0x51142
pushq $0xc
popq %rsi
pushq $0x1
popq %rdx
movq %r12, %rcx
callq 0x2280
cmpb $0x0, 0x4(%rsp)
je 0x17ad2
leaq 0x3968b(%rip), %rdi     # 0x5114f
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %r12, %rcx
callq 0x2280
cmpb $0x0, (%rsp)
jne 0x17aed
leaq 0x39673(%rip), %rdi     # 0x51152
pushq $0xc
popq %rsi
pushq $0x1
popq %rdx
movq %r12, %rcx
callq 0x2280
leaq 0x3966b(%rip), %rsi     # 0x5115f
xorl %r13d, %r13d
movq %r12, %rdi
movq 0x8(%rsp), %rbp
movl %ebp, %edx
xorl %eax, %eax
callq 0x2190
testl %ebp, %ebp
cmovlel %r13d, %ebp
imulq $0xc8, %rbp, %rbp
xorl %r13d, %r13d
cmpq %r13, %rbp
je 0x17bed
movslq (%r15,%r13), %rax
imulq $0x70, %rax, %rax
movslq 0x64(%r14,%rax), %rax
movslq 0x4(%r15,%r13), %rcx
imulq $0x70, %rcx, %rcx
movslq 0x64(%r14,%rcx), %rcx
movl %eax, %edx
subl %ecx, %edx
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
cmpl $0x3, %esi
jb 0x17be1
shlq $0x5, %rax
leaq (%rbx,%rax), %rdx
addq $0xd, %rdx
shlq $0x5, %rcx
addq %rbx, %rcx
addq $0xd, %rcx
movsd 0x20(%r15,%r13), %xmm0
movq %r12, %rdi
leaq 0x395f5(%rip), %rsi     # 0x5116d
movb $0x1, %al
callq 0x2190
cmpb $0x0, 0x4(%rsp)
je 0x17b9e
movsd 0x28(%r15,%r13), %xmm0
movq %r12, %rdi
leaq 0x3b303(%rip), %rsi     # 0x52e9a
movb $0x1, %al
callq 0x2190
cmpb $0x0, (%rsp)
jne 0x17bd6
movslq (%r15,%r13), %rax
imulq $0x70, %rax, %rax
leaq (%r14,%rax), %rdx
addq $0x18, %rdx
movslq 0x4(%r15,%r13), %rax
imulq $0x70, %rax, %rax
leaq (%r14,%rax), %rcx
addq $0x18, %rcx
movq %r12, %rdi
leaq 0x395a9(%rip), %rsi     # 0x51178
xorl %eax, %eax
callq 0x2190
pushq $0xa
popq %rdi
movq %r12, %rsi
callq 0x2140
addq $0xc8, %r13
jmp 0x17b18
movq %r12, %rdi
callq 0x20c0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq