// File: /workspace/github_c_makefile_star2_O1/ugobas[P]tnm/allostery.c
// Function: Print_links
int Print_links(float **Coupling, int N, char *nameout1, char *ext, int sign)
{
  char nameout[200]; int i, j;
  sprintf(nameout, "%s%s", nameout1, ext);
  FILE *file_out=fopen(nameout, "w");
  printf("Writing %s\n", nameout);

  // Mean and standard deviation
  double sum1=0, sum2=0; int norm=0;
  float max=0, min=1000;
  for(i=0; i<N; i++){
    float *c=Coupling[i]+i+2;
    for(j=i+2; j<N; j++){
      sum1+=*c; sum2+=(*c)*(*c); norm++;
      if(*c>max){max=*c;}
      if(*c<min){min=*c;} c++;
    }
  }
  sum1/=norm; sum2=sqrt((sum2-norm*sum1*sum1)/(norm-1));
  if(sum1==0 || sum2==0 || isnan(sum1)|| isnan(sum2)){
    printf("ERROR in Print_links, coupling= %s\n", ext);
    for(i=0; i<N; i++){
      float *c=Coupling[i];
      for(j=i+1; j<N; j++){printf("%.3g ",c[j]);} printf("\n");
    }
    printf("ERROR in Print_links, coupling= %s\n", ext);
    printf("Mean= %.3g s.d.= %.3g\n", sum1, sum2); exit(8);
  }

  double thrmax=sum1+SIGMA*sum2, thrmin=sum1-SIGMA*sum2;
  if(thrmax>=max){thrmax=(max+sum1)/2;}
  if(thrmin<=min){thrmin=(min+sum1)/2;}
  fprintf(file_out, "# mean= %.3g s.d.= %.3g thr=%.2g %.2g SIGMA= %.3g\n",
	  sum1, sum2, thrmin, thrmax, SIGMA);
  fprintf(file_out, "#Residue names written in %s.names.dat\n", nameout1);
  fprintf(file_out, "#resi resj coupling\n");
  for(i=0; i<N; i++){
    float *c=Coupling[i];
    for(j=i+1; j<N; j++){
      if((sign==0)||
	 ((sign>0)&&(c[j]>=thrmax))||
	 ((sign<0)&&(c[j]<=thrmin))){
	fprintf(file_out, "%d %d %.3g\n", i, j, c[j]);
      }
    }
  }
  fclose(file_out);
  return(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %r8d, %ebp
movq %rcx, %rbx
movq %rdx, %r14
movl %esi, %r15d
movq %rdi, 0x10(%rsp)
leaq 0x1169b(%rip), %rsi     # 0x55d24
xorl %r13d, %r13d
leaq 0x40(%rsp), %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x2260
leaq 0x12b9e(%rip), %rsi     # 0x57240
movq %r12, %rdi
callq 0x2210
movq %rax, (%rsp)
leaq 0xd626(%rip), %rdi      # 0x51cdb
movq %r12, %rsi
xorl %eax, %eax
callq 0x20f0
xorpd %xmm1, %xmm1
movl %r15d, %r8d
testl %r15d, %r15d
jle 0x4475f
leal -0x2(%r15), %eax
xorpd %xmm0, %xmm0
xorl %ecx, %ecx
xorps %xmm3, %xmm3
movss 0x12bfc(%rip), %xmm2    # 0x572e0
xorl %r13d, %r13d
xorpd %xmm6, %xmm6
leaq 0x2(%rcx), %rdx
cmpq %r8, %rdx
jae 0x44745
movq 0x10(%rsp), %rdx
movq (%rdx,%rcx,8), %rdx
leaq (%rdx,%rcx,4), %rsi
addq $0x8, %rsi
xorl %edx, %edx
movaps %xmm3, %xmm4
movaps %xmm2, %xmm5
movss (%rsi), %xmm2
xorps %xmm3, %xmm3
cvtss2sd %xmm2, %xmm3
addsd %xmm3, %xmm6
movaps %xmm2, %xmm3
mulss %xmm2, %xmm3
cvtss2sd %xmm3, %xmm3
addsd %xmm3, %xmm0
movaps %xmm2, %xmm3
maxss %xmm4, %xmm3
minss %xmm5, %xmm2
addq $0x4, %rsi
decl %edx
movl %eax, %edi
addl %edx, %edi
jne 0x44707
subl %edx, %r13d
incq %rcx
decl %eax
cmpq %r8, %rcx
jne 0x446eb
cvtss2sd %xmm3, %xmm3
movaps %xmm3, 0x20(%rsp)
cvtss2sd %xmm2, %xmm8
jmp 0x44778
movsd 0x16658(%rip), %xmm8    # 0x5adc0
xorpd %xmm6, %xmm6
xorpd %xmm0, %xmm0
xorps %xmm2, %xmm2
movaps %xmm2, 0x20(%rsp)
xorps %xmm2, %xmm2
cvtsi2sd %r13d, %xmm2
divsd %xmm2, %xmm6
mulsd %xmm6, %xmm2
mulsd %xmm6, %xmm2
decl %r13d
xorps %xmm3, %xmm3
cvtsi2sd %r13d, %xmm3
subsd %xmm2, %xmm0
divsd %xmm3, %xmm0
ucomisd %xmm1, %xmm0
movq %r8, 0x8(%rsp)
jb 0x447b3
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
jmp 0x447d6
movsd %xmm6, 0x30(%rsp)
movsd %xmm8, 0x18(%rsp)
callq 0x2290
movsd 0x18(%rsp), %xmm8
movsd 0x30(%rsp), %xmm6
movapd %xmm0, %xmm1
ucomisd %xmm6, %xmm6
jp 0x44988
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm6
jne 0x447f0
jnp 0x44988
ucomisd %xmm0, %xmm1
jne 0x447fc
jnp 0x44988
ucomisd %xmm1, %xmm1
jp 0x44988
leaq 0x22a33(%rip), %rax     # 0x67240
xorps %xmm4, %xmm4
cvtss2sd (%rax), %xmm4
movaps %xmm4, %xmm0
mulsd %xmm1, %xmm0
movapd %xmm6, %xmm7
subsd %xmm0, %xmm7
addsd %xmm6, %xmm0
movapd %xmm6, %xmm2
movapd 0x20(%rsp), %xmm3
addsd %xmm3, %xmm2
movsd 0xc81b(%rip), %xmm5     # 0x51058
mulsd %xmm5, %xmm2
cmpnlesd %xmm0, %xmm3
andpd %xmm3, %xmm0
andnpd %xmm2, %xmm3
orpd %xmm0, %xmm3
movapd %xmm6, %xmm0
addsd %xmm8, %xmm0
mulsd %xmm5, %xmm0
movapd %xmm7, %xmm2
cmpnlesd %xmm8, %xmm2
andpd %xmm2, %xmm7
andnpd %xmm0, %xmm2
orpd %xmm7, %xmm2
leaq 0x18adc(%rip), %rsi     # 0x5d358
movq (%rsp), %rbx
movq %rbx, %rdi
movapd %xmm6, %xmm0
movapd %xmm2, 0x30(%rsp)
movapd %xmm3, 0x20(%rsp)
movb $0x5, %al
callq 0x2190
leaq 0x18aea(%rip), %rsi     # 0x5d38b
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2190
leaq 0x18afe(%rip), %rdi     # 0x5d3b3
movl $0x1, %r14d
movl $0x14, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2280
testl %r15d, %r15d
movq 0x8(%rsp), %rcx
jle 0x4496b
xorl %r12d, %r12d
leaq 0x18ae3(%rip), %r15     # 0x5d3c8
leaq 0x1(%r12), %rax
movq %rax, 0x18(%rsp)
cmpq %rcx, %rax
jae 0x4495a
movq 0x10(%rsp), %rax
movq (%rax,%r12,8), %rbx
movq %r14, %r13
testl %ebp, %ebp
je 0x44930
jle 0x44917
xorps %xmm0, %xmm0
cvtss2sd (%rbx,%r13,4), %xmm0
ucomisd 0x20(%rsp), %xmm0
jae 0x44930
testl %ebp, %ebp
jns 0x44952
xorps %xmm0, %xmm0
cvtss2sd (%rbx,%r13,4), %xmm0
movapd 0x30(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x44952
xorps %xmm0, %xmm0
cvtss2sd (%rbx,%r13,4), %xmm0
movq (%rsp), %rdi
movq %r15, %rsi
movl %r12d, %edx
movl %r13d, %ecx
movb $0x1, %al
callq 0x2190
movq 0x8(%rsp), %rcx
incq %r13
cmpq %r13, %rcx
jne 0x44900
incq %r14
movq 0x18(%rsp), %r12
cmpq %rcx, %r12
jne 0x448e5
movq (%rsp), %rdi
callq 0x20c0
xorl %eax, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsd %xmm1, 0x20(%rsp)
movsd %xmm6, 0x30(%rsp)
leaq 0x18982(%rip), %rdi     # 0x5d31d
movq %rbx, (%rsp)
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
testl %r15d, %r15d
movq 0x8(%rsp), %rcx
jle 0x44a16
xorl %r15d, %r15d
leaq 0x17bdd(%rip), %r14     # 0x5c59a
movq %rcx, %r12
xorl %eax, %eax
leaq 0x1(%rax), %rbx
cmpq %rcx, %rbx
jae 0x449f8
movq 0x10(%rsp), %rcx
movq (%rcx,%rax,8), %r13
addq %r15, %r13
movl $0x1, %ebp
xorps %xmm0, %xmm0
cvtss2sd (%r13,%rbp,4), %xmm0
movq %r14, %rdi
movb $0x1, %al
callq 0x20f0
incq %rbp
cmpq %rbp, %r12
jne 0x449dc
movl $0xa, %edi
callq 0x2060
addq $0x4, %r15
decq %r12
movq %rbx, %rax
movq 0x8(%rsp), %rcx
cmpq %rcx, %rbx
jne 0x449c2
leaq 0x18900(%rip), %rdi     # 0x5d31d
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x18912(%rip), %rdi     # 0x5d341
movsd 0x30(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
movb $0x2, %al
callq 0x20f0
movl $0x8, %edi
callq 0x2270