// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/allostery.c
// Function: Get_zeta
int Get_zeta(float **Coupling, int N)
{
  // Mean and standard deviation depending on l=|i-j|
  // Compute z=(c_{i,i+l}-<c>_l)/sigma_l
  // If |z| > 1, amplify c -> c*z
  int i, j, l, ll=-1, num_l=0;;
  float *c1=malloc(N*sizeof(float));
  float *c2=malloc(N*sizeof(float));
  double sum1_l=0, sum2_l=0;
  for(l=0; l<N; l++){
    double sum1=0, sum2=0; int num=N-l;
    for(i=0; i<(N-l); i++){
      float c=Coupling[i][i+l];
      sum1+=c; sum2+=c*c;
    }
    if(l==0){
      c1[l]=sum1/num;
      c2[l]=sqrt((sum2-num*c1[l]*c1[l])/(num-1));
    }else if((ll<0) && (l<N-9) && (fabs(c1[l]-c1[l-1]) > 3*c2[l-1]/sqrt(num))){
      c1[l]=sum1/num;
      c2[l]=sqrt((sum2-sum1*sum1/num)/(num-1));
    }else{
      if(ll<0){ll=l;} sum1_l+=sum1; sum2_l+=sum2; num_l+=num;
    }
  }
  sum1_l/=num_l;
  sum2_l=sqrt((sum2_l-num_l*sum1_l*sum1_l)/(num_l-1));
  for(l=ll; l<N; l++){
    c1[l]=sum1_l;
    c2[l]=sum2_l;
  }

  for(i=0; i<N; i++){
    float *c=Coupling[i];
    for(j=i+1; j<N; j++){
      float z=(c[j]-c1[j-i])/c2[j-i];
      if(z<0)z=-z;
      if(z>1){c[j]*=z; Coupling[j][i]=c[j];}
    }
  }
  free(c1); free(c2);
  return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x20(%rbp)
movslq -0xc(%rbp), %rdi
shlq $0x2, %rdi
callq 0x1180
movq %rax, -0x28(%rbp)
movslq -0xc(%rbp), %rdi
shlq $0x2, %rdi
callq 0x1180
movq %rax, -0x30(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x660f9
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
movl -0xc(%rbp), %eax
subl -0x18(%rbp), %eax
movl %eax, -0x54(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movl -0xc(%rbp), %ecx
subl -0x18(%rbp), %ecx
cmpl %ecx, %eax
jge 0x65f47
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x10(%rbp), %ecx
addl -0x18(%rbp), %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x58(%rbp)
movss -0x58(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movss -0x58(%rbp), %xmm0
mulss -0x58(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x65ee5
cmpl $0x0, -0x18(%rbp)
jne 0x65fc1
movsd -0x48(%rbp), %xmm0
cvtsi2sdl -0x54(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movsd -0x50(%rbp), %xmm0
cvtsi2ssl -0x54(%rbp), %xmm1
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
mulss (%rax,%rcx,4), %xmm1
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
mulss (%rax,%rcx,4), %xmm1
cvtss2sd %xmm1, %xmm1
subsd %xmm1, %xmm0
movl -0x54(%rbp), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
callq 0x1220
cvtsd2ss %xmm0, %xmm0
movq -0x30(%rbp), %rax
movslq -0x18(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x660e9
cmpl $0x0, -0x1c(%rbp)
jge 0x660b4
movl -0x18(%rbp), %eax
movl -0xc(%rbp), %ecx
subl $0x9, %ecx
cmpl %ecx, %eax
jge 0x660b4
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movq -0x28(%rbp), %rax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
subss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movaps 0x1648a(%rip), %xmm1    # 0x7c490
pand %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x30(%rbp), %rax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movss 0x10054(%rip), %xmm0    # 0x76078
mulss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x78(%rbp)
cvtsi2sdl -0x54(%rbp), %xmm0
callq 0x1220
movsd -0x78(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x70(%rbp), %xmm0
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x660b4
movsd -0x48(%rbp), %xmm0
cvtsi2sdl -0x54(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movsd -0x50(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
mulsd -0x48(%rbp), %xmm1
cvtsi2sdl -0x54(%rbp), %xmm2
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movl -0x54(%rbp), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
callq 0x1220
cvtsd2ss %xmm0, %xmm0
movq -0x30(%rbp), %rax
movslq -0x18(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x660e7
cmpl $0x0, -0x1c(%rbp)
jge 0x660c0
movl -0x18(%rbp), %eax
movl %eax, -0x1c(%rbp)
movsd -0x48(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x50(%rbp), %xmm0
addsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movl -0x54(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x660e9
jmp 0x660eb
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x65eb9
cvtsi2sdl -0x20(%rbp), %xmm1
movsd -0x38(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x40(%rbp), %xmm1
cvtsi2sdl -0x20(%rbp), %xmm0
mulsd -0x38(%rbp), %xmm0
movsd -0x38(%rbp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movl -0x20(%rbp), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
callq 0x1220
movsd %xmm0, -0x40(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x6619c
movsd -0x38(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movsd -0x40(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x30(%rbp), %rax
movslq -0x18(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x6615d
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x66295
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x60(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x66285
movq -0x60(%rbp), %rax
movslq -0x14(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movq -0x28(%rbp), %rax
movl -0x14(%rbp), %ecx
subl -0x10(%rbp), %ecx
movslq %ecx, %rcx
subss (%rax,%rcx,4), %xmm0
movq -0x30(%rbp), %rax
movl -0x14(%rbp), %ecx
subl -0x10(%rbp), %ecx
movslq %ecx, %rcx
divss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x64(%rbp)
xorps %xmm0, %xmm0
ucomiss -0x64(%rbp), %xmm0
jbe 0x6622a
movss -0x64(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movss %xmm0, -0x64(%rbp)
movss -0x64(%rbp), %xmm0
movss 0xfe59(%rip), %xmm1     # 0x76090
ucomiss %xmm1, %xmm0
jbe 0x66275
movss -0x64(%rbp), %xmm0
movq -0x60(%rbp), %rax
movslq -0x14(%rbp), %rcx
mulss (%rax,%rcx,4), %xmm0
movss %xmm0, (%rax,%rcx,4)
movq -0x60(%rbp), %rax
movslq -0x14(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x66277
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x661c8
jmp 0x66287
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x661a3
movq -0x28(%rbp), %rdi
callq 0x1040
movq -0x30(%rbp), %rdi
callq 0x1040
xorl %eax, %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)