// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/anharmonic_tnm.c
// Function: Compute_corr_inv
double **Compute_corr_inv(int npara, int nsam)
{
  //C_ab= sum_i=1^4 i^a*i^b = sum_i=1^4 i^(a+b)
  double **Corr=Allocate_mat2_d(npara, npara); int a,b,k;
  for(a=0; a<npara; a++){
    for(b=0; b<=a; b++){
      double C=0;
      for(k=1; k<nsam; k++)C+=pow(k,a+b);
      Corr[a][b]=C; Corr[b][a]=C;
    }
  }
  Corr[0][0]=nsam+1;
  double **Corr_inv=Allocate_mat2_d(npara, npara);
  if(choldc(Corr, Corr, npara)==0){ //
    printf("Inverting correlation through Cholevsky decomposition\n");
    double **L_inv=Cholevsky_inversion(Corr, npara);
    for(k=0; k<npara; k++){
      double *v=L_inv[k];
      for(a=0; a<npara; a++)for(b=0; b<=a; b++)Corr_inv[a][b]+=v[a]*v[b];
    }
    Empty_matrix_d(L_inv, npara);
  }else{
    printf("Inverting correlation through diagonalization\n");
    float **eigen_vector=Allocate_mat2_f(npara, npara), eigen_value[npara];
    d_Diagonalize(npara, Corr, eigen_value, eigen_vector, 1);
    int num=0;
    for(k=0; k<npara; k++){
      if(eigen_value[k]<=0){num++; continue;}
      double t=1./eigen_value[k];
      float *v=eigen_vector[k];
      for(a=0; a<npara; a++){
	for(b=0; b<=a; b++)Corr_inv[a][b]+=t*v[a]*v[b];
      }
    }
    if(num)printf("WARNING, correlation has %d null modes\n", num);
    Empty_matrix_f(eigen_vector, npara);
  }
  for(a=0; a<npara; a++)for(b=0; b<a; b++)Corr_inv[b][a]=Corr_inv[a][b];
  Empty_matrix_d(Corr, npara);
  return(Corr_inv);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl -0x4(%rbp), %edi
movl -0x4(%rbp), %esi
callq 0x694a0
movq %rax, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x25d18
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x25d08
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
movl $0x1, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x25cc6
cvtsi2sdl -0x1c(%rbp), %xmm0
movl -0x14(%rbp), %eax
addl -0x18(%rbp), %eax
cvtsi2sd %eax, %xmm1
callq 0x1080
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x25c95
movsd -0x28(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x28(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x25c7a
jmp 0x25d0a
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x25c67
movl -0x8(%rbp), %eax
addl $0x1, %eax
cvtsi2sd %eax, %xmm0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsd %xmm0, (%rax)
movl -0x4(%rbp), %edi
movl -0x4(%rbp), %esi
callq 0x694a0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x4(%rbp), %edx
callq 0x69540
cmpl $0x0, %eax
jne 0x25e29
leaq 0x576f2(%rip), %rdi     # 0x7d44e
movb $0x0, %al
callq 0x10d0
movq -0x10(%rbp), %rdi
movl -0x4(%rbp), %esi
callq 0x69b50
movq %rax, -0x38(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x25e18
movq -0x38(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x25e08
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x25dfb
movq -0x40(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x40(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x25dac
jmp 0x25dfd
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x25d9d
jmp 0x25e0a
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x25d7a
movq -0x38(%rbp), %rdi
movl -0x4(%rbp), %esi
callq 0x692a0
jmp 0x25faa
leaq 0x57655(%rip), %rdi     # 0x7d485
xorl %eax, %eax
callq 0x10d0
movl -0x4(%rbp), %esi
movl %esi, %edi
callq 0x69360
movq %rax, -0x48(%rbp)
movl -0x4(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x50(%rbp)
leaq 0xf(,%rax,4), %rcx
andq $-0x10, %rcx
movq %rsp, %rdx
subq %rcx, %rdx
movq %rdx, -0x78(%rbp)
movq %rdx, %rsp
movq %rax, -0x58(%rbp)
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x48(%rbp), %rcx
movl $0x1, %r8d
callq 0x6ac30
movl $0x0, -0x5c(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x25f80
movq -0x78(%rbp), %rax
movslq -0x1c(%rbp), %rcx
xorps %xmm0, %xmm0
ucomiss (%rax,%rcx,4), %xmm0
jb 0x25ebb
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x25f72
movq -0x78(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x50174(%rip), %xmm0    # 0x76048
divsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x25f70
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x25f63
movsd -0x68(%rbp), %xmm0
movq -0x70(%rbp), %rax
movslq -0x14(%rbp), %rcx
movss (%rax,%rcx,4), %xmm1
cvtss2sd %xmm1, %xmm1
mulsd %xmm1, %xmm0
movq -0x70(%rbp), %rax
movslq -0x18(%rbp), %rcx
movss (%rax,%rcx,4), %xmm1
cvtss2sd %xmm1, %xmm2
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x25f03
jmp 0x25f65
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x25ef4
jmp 0x25f72
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x25e90
cmpl $0x0, -0x5c(%rbp)
je 0x25f97
movl -0x5c(%rbp), %esi
leaq 0x57524(%rip), %rdi     # 0x7d4b4
movb $0x0, %al
callq 0x10d0
movq -0x48(%rbp), %rdi
movl -0x4(%rbp), %esi
callq 0x69240
movq -0x50(%rbp), %rax
movq %rax, %rsp
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x2600a
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x25ffd
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x25fc0
jmp 0x25fff
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x25fb1
movq -0x10(%rbp), %rdi
movl -0x4(%rbp), %esi
callq 0x692a0
movq -0x30(%rbp), %rax
movq %rbp, %rsp
popq %rbp
retq
nop