// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/allostery.c
// Function: Chain_coup
double **Chain_coup(float **Coupling, double **norm, float **Proximity,
		    int Nchain, char *ch, int Na)
{
  if(Coupling==NULL)return(NULL);
  double **Chain_coup=Allocate_mat2_d(Nchain, Nchain);
  int ichain, jchain;
  for(ichain=0; ichain<Nchain; ichain++){
    for(jchain=0; jchain<=ichain; jchain++)norm[ichain][jchain]=0;
  }

  char ch_old_i=ch[0]; ichain=0;
  for(int ia=0; ia<Na; ia++){
    if(ch[ia]!=ch_old_i){ch_old_i=ch[ia]; ichain++;}
    char ch_old_j=ch[0]; jchain=0;
    for(int ja=0; ja<ia; ja++){
      if(ch[ja]!=ch_old_j){ch_old_j=ch[ja]; jchain++;}
      float w=Proximity[ia][ja];
      Chain_coup[ichain][jchain]+=w*Coupling[ia][ja];
      norm[ichain][jchain]+=w;
    }
  }
  for(ichain=0; ichain<Nchain; ichain++){
    for(jchain=0; jchain<=ichain; jchain++){
      Chain_coup[ichain][jchain]/=norm[ichain][jchain];
      if(jchain!=ichain){
	Chain_coup[jchain][ichain]=Chain_coup[ichain][jchain];
	norm[jchain][ichain]=norm[ichain][jchain];
      }
    }
  }
  return(Chain_coup);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x642b3
movq $0x0, -0x8(%rbp)
jmp 0x6451c
movl -0x24(%rbp), %edi
movl -0x24(%rbp), %esi
callq 0x694a0
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x64310
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x44(%rbp), %eax
jg 0x64303
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x48(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x642d8
jmp 0x64305
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x642c9
movq -0x30(%rbp), %rax
movb (%rax), %al
movb %al, -0x49(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x6443f
movq -0x30(%rbp), %rax
movslq -0x50(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movsbl -0x49(%rbp), %ecx
cmpl %ecx, %eax
je 0x6435e
movq -0x30(%rbp), %rax
movslq -0x50(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x49(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movq -0x30(%rbp), %rax
movb (%rax), %al
movb %al, -0x51(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0x6442f
movq -0x30(%rbp), %rax
movslq -0x58(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movsbl -0x51(%rbp), %ecx
cmpl %ecx, %eax
je 0x643ac
movq -0x30(%rbp), %rax
movslq -0x58(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x51(%rbp)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movslq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x58(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x5c(%rbp)
movss -0x5c(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x58(%rbp), %rcx
mulss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x40(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x48(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movss -0x5c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x48(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x64375
jmp 0x64431
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x64327
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x64514
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x44(%rbp), %eax
jg 0x64504
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x48(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x40(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x48(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x48(%rbp), %eax
cmpl -0x44(%rbp), %eax
je 0x644f4
movq -0x40(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x48(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x40(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x44(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x48(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x44(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x644f6
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x64459
jmp 0x64506
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x64446
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)