// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
leaq -0xf0(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0x18abf(%rip), %rsi     # 0x7ae23
movb $0x0, %al
callq 0x1200
leaq -0xf0(%rbp), %rdi
leaq 0x19ff9(%rip), %rsi     # 0x7c372
callq 0x11b0
movq %rax, -0x100(%rbp)
leaq -0xf0(%rbp), %rsi
leaq 0x1515b(%rip), %rdi     # 0x774ee
movb $0x0, %al
callq 0x10d0
xorps %xmm0, %xmm0
movsd %xmm0, -0x108(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x110(%rbp)
movl $0x0, -0x114(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x118(%rbp)
movss 0x1a013(%rip), %xmm0    # 0x7c3e0
movss %xmm0, -0x11c(%rbp)
movl $0x0, -0xf4(%rbp)
movl -0xf4(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x6251a
movq -0x8(%rbp), %rax
movslq -0xf4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0xf4(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, -0x128(%rbp)
movl -0xf4(%rbp), %eax
addl $0x2, %eax
movl %eax, -0xf8(%rbp)
movl -0xf8(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x62504
movq -0x128(%rbp), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x108(%rbp), %xmm0
movsd %xmm0, -0x108(%rbp)
movq -0x128(%rbp), %rax
movss (%rax), %xmm0
movq -0x128(%rbp), %rax
mulss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x110(%rbp), %xmm0
movsd %xmm0, -0x110(%rbp)
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
movq -0x128(%rbp), %rax
movss (%rax), %xmm0
ucomiss -0x118(%rbp), %xmm0
jbe 0x624b3
movq -0x128(%rbp), %rax
movss (%rax), %xmm0
movss %xmm0, -0x118(%rbp)
movq -0x128(%rbp), %rax
movss (%rax), %xmm1
movss -0x11c(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x624de
movq -0x128(%rbp), %rax
movss (%rax), %xmm0
movss %xmm0, -0x11c(%rbp)
movq -0x128(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x128(%rbp)
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
jmp 0x62425
jmp 0x62506
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x623df
cvtsi2sdl -0x114(%rbp), %xmm1
movsd -0x108(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x108(%rbp)
movsd -0x110(%rbp), %xmm1
cvtsi2sdl -0x114(%rbp), %xmm0
mulsd -0x108(%rbp), %xmm0
movsd -0x108(%rbp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movl -0x114(%rbp), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
callq 0x1220
movsd %xmm0, -0x110(%rbp)
movsd -0x108(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x625a8
jp 0x625a8
jmp 0x625e8
movsd -0x110(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x625bd
jp 0x625bd
jmp 0x625e8
movsd -0x108(%rbp), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x625e8
movsd -0x110(%rbp), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x625e8
jmp 0x626d5
movq -0x20(%rbp), %rsi
leaq 0x200ed(%rip), %rdi     # 0x826e0
movb $0x0, %al
callq 0x10d0
movl $0x0, -0xf4(%rbp)
movl -0xf4(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x6269b
movq -0x8(%rbp), %rax
movslq -0xf4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x130(%rbp)
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
movl -0xf8(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x62679
movq -0x130(%rbp), %rax
movslq -0xf8(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x1f29f(%rip), %rdi     # 0x81900
movb $0x1, %al
callq 0x10d0
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
jmp 0x62638
leaq 0x1b9f8(%rip), %rdi     # 0x7e078
movb $0x0, %al
callq 0x10d0
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x62604
movq -0x20(%rbp), %rsi
leaq 0x2003a(%rip), %rdi     # 0x826e0
movb $0x0, %al
callq 0x10d0
movsd -0x108(%rbp), %xmm0
movsd -0x110(%rbp), %xmm1
leaq 0x20040(%rip), %rdi     # 0x82704
movb $0x2, %al
callq 0x10d0
movl $0x8, %edi
callq 0x1210
movsd -0x108(%rbp), %xmm1
leaq 0x27b1c(%rip), %rax     # 0x8a200
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd -0x110(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x138(%rbp)
movsd -0x108(%rbp), %xmm1
leaq 0x27aed(%rip), %rax     # 0x8a200
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd -0x110(%rbp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x140(%rbp)
movsd -0x138(%rbp), %xmm0
movss -0x118(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x6278c
movss -0x118(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x108(%rbp), %xmm0
movsd 0x138d8(%rip), %xmm1    # 0x76058
divsd %xmm1, %xmm0
movsd %xmm0, -0x138(%rbp)
movsd -0x140(%rbp), %xmm1
movss -0x11c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jb 0x627ce
movss -0x11c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x108(%rbp), %xmm0
movsd 0x13896(%rip), %xmm1    # 0x76058
divsd %xmm1, %xmm0
movsd %xmm0, -0x140(%rbp)
movq -0x100(%rbp), %rdi
movsd -0x108(%rbp), %xmm0
movsd -0x110(%rbp), %xmm1
movsd -0x140(%rbp), %xmm2
movsd -0x138(%rbp), %xmm3
leaq 0x27a04(%rip), %rax     # 0x8a200
movss (%rax), %xmm4
cvtss2sd %xmm4, %xmm4
leaq 0x1ff10(%rip), %rsi     # 0x8271b
movb $0x5, %al
callq 0x1150
movq -0x100(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x1ff2a(%rip), %rsi     # 0x8274e
movb $0x0, %al
callq 0x1150
movq -0x100(%rbp), %rdi
leaq 0x1ff3d(%rip), %rsi     # 0x82776
movb $0x0, %al
callq 0x1150
movl $0x0, -0xf4(%rbp)
movl -0xf4(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x62949
movq -0x8(%rbp), %rax
movslq -0xf4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x148(%rbp)
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
movl -0xf8(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x62933
cmpl $0x0, -0x24(%rbp)
je 0x628e5
cmpl $0x0, -0x24(%rbp)
jle 0x628ba
movq -0x148(%rbp), %rax
movslq -0xf8(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd -0x138(%rbp), %xmm0
jae 0x628e5
cmpl $0x0, -0x24(%rbp)
jge 0x6291d
movq -0x148(%rbp), %rax
movslq -0xf8(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm1
movsd -0x140(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x6291d
movq -0x100(%rbp), %rdi
movl -0xf4(%rbp), %edx
movl -0xf8(%rbp), %ecx
movq -0x148(%rbp), %rax
movslq -0xf8(%rbp), %rsi
movss (%rax,%rsi,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x1fe75(%rip), %rsi     # 0x8278b
movb $0x1, %al
callq 0x1150
jmp 0x6291f
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
jmp 0x6287e
jmp 0x62935
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x6284a
movq -0x100(%rbp), %rdi
callq 0x10a0
xorl %eax, %eax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq