// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../source/harmonic.c
// Function: harmonic_cls
int harmonic_cls(
                 struct precision * ppr,
                 struct background * pba,
                 struct perturbations * ppt,
                 struct transfer * ptr,
                 struct primordial * ppm,
                 struct harmonic * phr
                 ) {

  /** Summary: */

  /** - define local variables */

  int index_md;
  int index_ic1,index_ic2,index_ic1_ic2;
  int index_l;
  int index_ct;
  int cl_integrand_num_columns;

  /** - allocate pointers to arrays where results will be stored */

  class_alloc(phr->l_size,sizeof(int)*phr->md_size,phr->error_message);
  class_alloc(phr->cl,sizeof(double *)*phr->md_size,phr->error_message);
  class_alloc(phr->ddcl,sizeof(double *)*phr->md_size,phr->error_message);

  phr->l_size_max = ptr->l_size_max;
  class_alloc(phr->l,sizeof(double)*phr->l_size_max,phr->error_message);

  /** - store values of l */
  for (index_l=0; index_l < phr->l_size_max; index_l++) {
    phr->l[index_l] = (double)ptr->l[index_l];
  }

  /** - loop over modes (scalar, tensors, etc). For each mode: */

  for (index_md = 0; index_md < phr->md_size; index_md++) {

    /** - --> (a) store number of l values for this mode */

    phr->l_size[index_md] = ptr->l_size[index_md];

    /** - --> (b) allocate arrays where results will be stored */

    class_alloc(phr->cl[index_md],sizeof(double)*phr->l_size[index_md]*phr->ct_size*phr->ic_ic_size[index_md],phr->error_message);
    class_alloc(phr->ddcl[index_md],sizeof(double)*phr->l_size[index_md]*phr->ct_size*phr->ic_ic_size[index_md],phr->error_message);
    cl_integrand_num_columns = 1+phr->ct_size*2; /* one for k, ct_size for each type, ct_size for each second derivative of each type */

    /** - --> (c) loop over initial conditions */

    class_setup_parallel();

    for (index_ic1 = 0; index_ic1 < phr->ic_size[index_md]; index_ic1++) {
      for (index_ic2 = index_ic1; index_ic2 < phr->ic_size[index_md]; index_ic2++) {
        index_ic1_ic2 = index_symmetric_matrix(index_ic1,index_ic2,phr->ic_size[index_md]);

        /* non-diagonal coefficients should be computed only if non-zero correlation */
        if (phr->is_non_zero[index_md][index_ic1_ic2] == _TRUE_) {

          /** - ---> loop over l values defined in the transfer module.
              For each l, compute the \f$ C_l\f$'s for all types (TT, TE, ...)
              by convolving primordial spectra with transfer  functions.
              This elementary task is assigned to harmonic_compute_cl() */

          for (index_l=0; index_l < ptr->l_size[index_md]; index_l++) {

            class_run_parallel(=,

              double * cl_integrand; /* array with argument cl_integrand[index_k*cl_integrand_num_columns+1+phr->index_ct] */
              double * cl_integrand_limber; /* similar array with same columns but different number of lines (less k values) */
              double * transfer_ic1; /* array with argument transfer_ic1[index_tt] */
              double * transfer_ic2; /* idem */
              double * primordial_pk;  /* array with argument primordial_pk[index_ic_ic]*/


              class_alloc(cl_integrand,
                          ptr->q_size*cl_integrand_num_columns*sizeof(double),
                          phr->error_message);

              cl_integrand_limber = NULL;
              if (ptr->do_lcmb_full_limber == _TRUE_) {
                class_alloc(cl_integrand_limber,
                            ptr->q_size_limber*cl_integrand_num_columns*sizeof(double),
                            phr->error_message);
              }

              class_alloc(primordial_pk,
                          phr->ic_ic_size[index_md]*sizeof(double),
                          phr->error_message);

              class_alloc(transfer_ic1,
                          ptr->tt_size[index_md]*sizeof(double),
                          phr->error_message);

              class_alloc(transfer_ic2,
                          ptr->tt_size[index_md]*sizeof(double),
                          phr->error_message);

              class_call(harmonic_compute_cl(ppr,
                                             pba,
                                             ppt,
                                             ptr,
                                             ppm,
                                             phr,
                                             index_md,
                                             index_ic1,
                                             index_ic2,
                                             index_l,
                                             cl_integrand_num_columns,
                                             cl_integrand,
                                             cl_integrand_limber,
                                             primordial_pk,
                                             transfer_ic1,
                                             transfer_ic2),
                         phr->error_message,
                         phr->error_message);

              free(cl_integrand);
              if (ptr->do_lcmb_full_limber == _TRUE_) {
                free(cl_integrand_limber);
              }
              free(primordial_pk);
              free(transfer_ic1);
              free(transfer_ic2);

              return _SUCCESS_;
            );
          } /* end of loop over l */

        }
        else {

          /* set non-diagonal coefficients to zero if pair of ic's uncorrelated */

          for (index_l=0; index_l < ptr->l_size[index_md]; index_l++) {
            for (index_ct=0; index_ct<phr->ct_size; index_ct++) {
              phr->cl[index_md]
                [(index_l * phr->ic_ic_size[index_md] + index_ic1_ic2) * phr->ct_size + index_ct]
                = 0.;
            }
          }
        }
      }
    }

    class_finish_parallel();

    /** - --> (d) now that for a given mode, all possible \f$ C_l\f$'s have been computed,
        compute second derivative of the array in which they are stored,
        in view of spline interpolation. */

    class_call(array_spline_table_lines(phr->l,
                                        phr->l_size[index_md],
                                        phr->cl[index_md],
                                        phr->ic_ic_size[index_md]*phr->ct_size,
                                        phr->ddcl[index_md],
                                        _SPLINE_EST_DERIV_,
                                        phr->error_message),
               phr->error_message,
               phr->error_message);
  }

  return _SUCCESS_;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x8f8, %rsp            # imm = 0x8F8
movq %r9, %r12
movq %r8, 0xa8(%rsp)
movq %rcx, 0x8(%rsp)
movq %rdx, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
movq %rdi, 0x90(%rsp)
movslq 0x10(%r9), %r15
leaq (,%r15,4), %rdi
callq 0x8460
movq %rax, 0xa0(%r12)
testq %rax, %rax
je 0xb4525
leaq (,%r15,8), %r14
movq %r14, %rdi
callq 0x8460
movq %rax, 0xd0(%r12)
testq %rax, %rax
je 0xb456e
movq %r14, %rdi
callq 0x8460
movq %rax, 0xd8(%r12)
testq %rax, %rax
je 0xb45b4
movq 0x8(%rsp), %rax
movslq 0x908(%rax), %r14
movl %r14d, 0xa8(%r12)
leaq (,%r14,8), %rdi
callq 0x8460
movq %rax, 0xb0(%r12)
testq %rax, %rax
je 0xb4619
testl %r14d, %r14d
jle 0xb3f84
movq 0x8(%rsp), %rcx
movq 0x910(%rcx), %rcx
xorl %edx, %edx
xorps %xmm0, %xmm0
cvtsi2sdl (%rcx,%rdx,4), %xmm0
movsd %xmm0, (%rax,%rdx,8)
incq %rdx
cmpq %rdx, %r14
jne 0xb3f6f
testl %r15d, %r15d
jle 0xb4662
leaq 0xea(%r12), %rbx
xorl %r14d, %r14d
leaq 0x932a1(%rip), %rax     # 0x147240
addq $0x10, %rax
movq %rax, 0x88(%rsp)
movq %r12, 0x28(%rsp)
movq %rbx, 0x70(%rsp)
movq 0x8(%rsp), %rax
movq 0x900(%rax), %rax
movslq (%rax,%r14,4), %rax
movq 0xa0(%r12), %rcx
movl %eax, (%rcx,%r14,4)
movslq 0x9c(%r12), %rbp
imulq %rbp, %rax
movq 0x20(%r12), %rcx
movslq (%rcx,%r14,4), %rdi
imulq %rax, %rdi
shlq $0x3, %rdi
callq 0x8460
movq 0xd0(%r12), %rcx
movq %rax, (%rcx,%r14,8)
movq 0xa0(%r12), %rax
movq 0xd0(%r12), %rcx
cmpq $0x0, (%rcx,%r14,8)
movslq (%rax,%r14,4), %rcx
je 0xb4666
movq 0x20(%r12), %rax
movslq (%rax,%r14,4), %rax
imulq %rbp, %rcx
imulq %rax, %rcx
shlq $0x3, %rcx
movq %rcx, %rdi
callq 0x8460
movq 0xd8(%r12), %rcx
movq %rax, (%rcx,%r14,8)
movq 0xd8(%r12), %rax
cmpq $0x0, (%rax,%r14,8)
je 0xb46b1
callq 0x1c686
leaq 0xb0(%rsp), %rdi
movl %eax, %esi
callq 0x1c736
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
movq 0x18(%r12), %r8
movl (%r8,%r14,4), %eax
testl %eax, %eax
jle 0xb449b
leal 0x1(,%rbp,2), %ecx
movl %ecx, 0x3c(%rsp)
xorl %esi, %esi
movq %r14, 0x10(%rsp)
leal 0x1(%rsi), %edx
cmpl %eax, %esi
jge 0xb4436
movl %edx, %ecx
imull %esi, %ecx
shrl %ecx
movl %ecx, 0x38(%rsp)
movl %esi, %edi
movl %edx, 0x1c(%rsp)
movq %rsi, 0x30(%rsp)
cmpl %edi, %esi
jbe 0xb40dc
imull %edi, %eax
addl %esi, %eax
leal 0x1(%rdi), %ecx
imull %edi, %ecx
shrl %ecx
subl %ecx, %eax
movl %eax, %ebp
jmp 0xb40e7
imull %esi, %eax
movl %edi, %ebp
subl 0x38(%rsp), %ebp
addl %eax, %ebp
movq 0x28(%r12), %rax
movq (%rax,%r14,8), %rax
movslq %ebp, %rcx
cmpw $0x1, (%rax,%rcx,2)
movq 0x8(%rsp), %rax
movq 0x900(%rax), %rax
movl (%rax,%r14,4), %r13d
jne 0xb43a9
testl %r13d, %r13d
movabsq $0x100000001, %r15      # imm = 0x100000001
jle 0xb4424
movq %rdi, 0x20(%rsp)
xorl %ebx, %ebx
movl $0x20, %edi
callq 0x83b0
movq %rax, %rbp
movq %r15, 0x8(%rax)
movq 0x88(%rsp), %rax
movq %rax, (%rbp)
movl $0x88, %edi
callq 0x83b0
movq %rax, %r14
movq %r15, 0x8(%rax)
leaq 0x93b53(%rip), %rax     # 0x147cb0
movq %rax, (%r14)
movq %r14, %r13
addq $0x10, %r13
movq %r13, %rdi
leaq 0xf0(%rsp), %rsi
callq 0x1d4aa
movq %r13, 0x10(%rbp)
leaq 0x93b7e(%rip), %rax     # 0x147d00
movq %rax, 0x10(%r14)
movq 0x8(%rsp), %rax
movq %rax, 0x38(%r14)
movl 0x3c(%rsp), %eax
movl %eax, 0x40(%r14)
movq %r12, 0x48(%r14)
movq 0x10(%rsp), %rax
movl %eax, 0x50(%r14)
movq 0x90(%rsp), %rax
movq %rax, 0x58(%r14)
movq 0x98(%rsp), %rax
movq %rax, 0x60(%r14)
movq 0xa0(%rsp), %rax
movq %rax, 0x68(%r14)
movq 0xa8(%rsp), %rax
movq %rax, 0x70(%r14)
movq 0x30(%rsp), %rax
movl %eax, 0x78(%r14)
movq 0x20(%rsp), %rax
movl %eax, 0x7c(%r14)
movl %ebx, 0x80(%r14)
movq %r14, 0x18(%rbp)
movq %rbp, %r14
addq $0x10, %r14
leaq 0x78(%rsp), %rdi
movq %r14, %rsi
callq 0x1d3e8
movq %r14, 0x60(%rsp)
movq %rbp, 0x68(%rsp)
movq 0x94d9a(%rip), %rax     # 0x148fb0
cmpb $0x0, (%rax)
je 0xb4220
incl 0x8(%rbp)
jmp 0xb4224
lock
incl 0x8(%rbp)
movl $0x1, %r14d
lock
xaddl %r14d, 0xd0(%rsp)
movl 0xb0(%rsp), %ecx
testl %ecx, %ecx
je 0xb429c
xorl %r12d, %r12d
leal (%r14,%r12), %eax
xorl %edx, %edx
divl %ecx
movq 0xd8(%rsp), %r13
imulq $0xb0, %rdx, %r15
leaq (%r15,%r13), %rdi
addq $0x58, %rdi
movq %rdi, 0xf0(%rsp)
callq 0x8080
testl %eax, %eax
sete 0xf8(%rsp)
je 0xb4307
leaq 0xf0(%rsp), %rdi
callq 0x1d204
incl %r12d
movl 0xb0(%rsp), %ecx
cmpl %ecx, %r12d
jb 0xb4242
jmp 0xb429e
xorl %ecx, %ecx
movl %r14d, %eax
xorl %edx, %edx
divl %ecx
movq 0xd8(%rsp), %r14
imulq $0xb0, %rdx, %r15
leaq (%r14,%r15), %rax
addq $0x58, %rax
movq %rax, 0xf0(%rsp)
movb $0x0, 0xf8(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x1d294
addq %r15, %r14
movb $0x1, 0xf8(%rsp)
movq %r14, %rdi
leaq 0x60(%rsp), %rsi
callq 0xb6616
leaq 0xf0(%rsp), %rdi
callq 0x1d204
subq $-0x80, %r14
movq %r14, %rdi
jmp 0xb432b
addq %r15, %r13
movq %r13, %rdi
leaq 0x60(%rsp), %rsi
callq 0xb6616
leaq 0xf0(%rsp), %rdi
callq 0x1d204
subq $-0x80, %r13
movq %r13, %rdi
callq 0x81c0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0xb433f
callq 0x1d330
movq 0x28(%rsp), %r12
movq 0x10(%rsp), %r14
movabsq $0x100000001, %r15      # imm = 0x100000001
movq %rbp, %rdi
callq 0x1d330
leaq 0x40(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x1dd2e
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xb437c
callq 0x1d330
incl %ebx
movq 0x8(%rsp), %rax
movq 0x900(%rax), %rax
cmpl (%rax,%r14,4), %ebx
jl 0xb4128
movq 0x18(%r12), %r8
movl 0x1c(%rsp), %edx
movq 0x30(%rsp), %rsi
movq 0x20(%rsp), %rdi
jmp 0xb4424
testl %r13d, %r13d
jle 0xb4424
movq %r8, 0x20(%rsp)
movq %rdi, %r15
movl 0x9c(%r12), %r12d
movq %r12, %r14
shlq $0x3, %r14
xorl %ebx, %ebx
testl %r12d, %r12d
jle 0xb4402
movq 0x28(%rsp), %rcx
movq 0x20(%rcx), %rax
movq 0xd0(%rcx), %rcx
movq 0x10(%rsp), %rdx
movl (%rax,%rdx,4), %eax
imull %ebx, %eax
addl %ebp, %eax
imull %r12d, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
addq (%rcx,%rdx,8), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x8200
incl %ebx
cmpl %ebx, %r13d
jne 0xb43c7
movq 0x28(%rsp), %r12
movq 0x10(%rsp), %r14
movl 0x1c(%rsp), %edx
movq 0x30(%rsp), %rsi
movq %r15, %rdi
movq 0x20(%rsp), %r8
incl %edi
movl (%r8,%r14,4), %eax
cmpl %eax, %edi
jl 0xb40c5
movl (%r8,%r14,4), %eax
movl %edx, %esi
cmpl %eax, %edx
jl 0xb40a4
movq 0x40(%rsp), %rbp
movq 0x48(%rsp), %rbx
cmpq %rbx, %rbp
je 0xb4472
movq %rbp, %rdi
callq 0x1c7ba
testl %eax, %eax
jne 0xb4752
addq $0x10, %rbp
cmpq %rbx, %rbp
jne 0xb444f
movq 0x40(%rsp), %rbp
movq 0x48(%rsp), %rbx
cmpq %rbp, %rbx
je 0xb449b
movq %rbp, %r14
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0xb4488
callq 0x1d330
addq $0x10, %r14
cmpq %rbx, %r14
jne 0xb447a
movq %rbp, 0x48(%rsp)
movq 0x10(%rsp), %r14
movq 0xb0(%r12), %rdi
movq 0xa0(%r12), %rax
movl (%rax,%r14,4), %esi
movq 0xd0(%r12), %rax
movq (%rax,%r14,8), %rdx
movq 0x20(%r12), %rax
movl 0x9c(%r12), %ecx
imull (%rax,%r14,4), %ecx
movq 0xd8(%r12), %rax
movq (%rax,%r14,8), %r8
movq 0x70(%rsp), %rbx
movq %rbx, (%rsp)
movl $0x1, %r9d
callq 0x142a8
cmpl $0x1, %eax
je 0xb470d
leaq 0x40(%rsp), %rdi
callq 0x1c806
leaq 0xb0(%rsp), %rdi
callq 0x1c84c
incq %r14
movslq 0x10(%r12), %rcx
xorl %eax, %eax
cmpq %rcx, %r14
jl 0xb3fb5
jmp 0xb4607
shll $0x2, %r15d
leaq 0x39ad4(%rip), %rsi     # 0xee004
leaq 0x6d4f6(%rip), %rdx     # 0x121a2d
leaq 0xf0(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0xea, %r12
leaq 0x39ada(%rip), %rsi     # 0xee034
leaq 0x6d4d8(%rip), %rdx     # 0x121a39
movq %r12, %rdi
movl $0x2ae, %ecx            # imm = 0x2AE
jmp 0xb45f8
shll $0x3, %r15d
leaq 0x39a8b(%rip), %rsi     # 0xee004
leaq 0x6d4c6(%rip), %rdx     # 0x121a46
leaq 0xf0(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0xea, %r12
leaq 0x39a91(%rip), %rsi     # 0xee034
leaq 0x6d48f(%rip), %rdx     # 0x121a39
movq %r12, %rdi
movl $0x2af, %ecx            # imm = 0x2AF
jmp 0xb45f8
shll $0x3, %r15d
leaq 0x39a45(%rip), %rsi     # 0xee004
leaq 0x6d488(%rip), %rdx     # 0x121a4e
leaq 0xf0(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0xea, %r12
leaq 0x39a4b(%rip), %rsi     # 0xee034
leaq 0x6d449(%rip), %rdx     # 0x121a39
movq %r12, %rdi
movl $0x2b0, %ecx            # imm = 0x2B0
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
addq $0x8f8, %rsp            # imm = 0x8F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
shll $0x3, %r14d
leaq 0x399e0(%rip), %rsi     # 0xee004
leaq 0x6d42d(%rip), %rdx     # 0x121a58
leaq 0xf0(%rsp), %r15
movq %r15, %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0xea, %r12
leaq 0x399e6(%rip), %rsi     # 0xee034
leaq 0x6d3e4(%rip), %rdx     # 0x121a39
movq %r12, %rdi
movl $0x2b3, %ecx            # imm = 0x2B3
movq %r15, %r8
jmp 0xb45fb
xorl %eax, %eax
jmp 0xb4607
movq 0x20(%r12), %rax
imull %ebp, %ecx
imull (%rax,%r14,4), %ecx
shll $0x3, %ecx
leaq 0x39987(%rip), %rsi     # 0xee004
leaq 0x6d3db(%rip), %rdx     # 0x121a5f
movq %rbx, %r14
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30af0
leaq 0x39994(%rip), %rsi     # 0xee034
leaq 0x6d392(%rip), %rdx     # 0x121a39
movq %r14, %rdi
movl $0x2c4, %ecx            # imm = 0x2C4
jmp 0xb4705
movq 0xa0(%r12), %rax
imull (%rax,%r14,4), %ebp
movq 0x20(%r12), %rax
imull (%rax,%r14,4), %ebp
shll $0x3, %ebp
leaq 0x39932(%rip), %rsi     # 0xee004
leaq 0x6d398(%rip), %rdx     # 0x121a71
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30af0
leaq 0x39940(%rip), %rsi     # 0xee034
leaq 0x6d33e(%rip), %rdx     # 0x121a39
movq 0x70(%rsp), %rdi
movl $0x2c5, %ecx            # imm = 0x2C5
movq %rbx, %r8
jmp 0xb45fb
leaq 0x39cdc(%rip), %rsi     # 0xee3f0
leaq 0x6d36a(%rip), %rdx     # 0x121a85
leaq 0xf0(%rsp), %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x39900(%rip), %rsi     # 0xee034
leaq 0x6d2fe(%rip), %rdx     # 0x121a39
leaq 0xf0(%rsp), %r8
movq %rbx, %rdi
movl $0x337, %ecx            # imm = 0x337
xorl %eax, %eax
callq 0x30af0
leaq 0x40(%rsp), %rdi
callq 0x1c806
leaq 0xb0(%rsp), %rdi
callq 0x1c84c
jmp 0xb4602
jmp 0xb47c0
jmp 0xb47c0
jmp 0xb47c0
jmp 0xb4776
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x1d204
jmp 0xb478b
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0xb479a
callq 0x1d330
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xb47c8
callq 0x1d330
jmp 0xb47c8
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
jne 0xb47cb
jmp 0xb47ea
movq %rax, %rbx
jmp 0xb47ea
movq %rax, %rbx
movq %rbp, %rdi
callq 0x1d330
jmp 0xb47ea
movq %rax, %rbx
movq %r14, %rdi
callq 0x8380
jmp 0xb47e2
movq %rax, %rbx
movq %rbp, %rdi
callq 0x8380
leaq 0x40(%rsp), %rdi
callq 0x1c806
leaq 0xb0(%rsp), %rdi
callq 0x1c84c
movq %rbx, %rdi
callq 0x8650