// File: /workspace/github_c_makefile_star2_O1/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, 0x10(%rsp)
movq %rdx, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
movq %rdi, 0x90(%rsp)
movslq 0x10(%r9), %r14
leaq (,%r14,4), %rdi
callq 0x8460
movq %rax, 0xa0(%r12)
testq %rax, %rax
je 0xb7687
leaq (,%r14,8), %rbx
movq %rbx, %rdi
callq 0x8460
movq %rax, 0xd0(%r12)
testq %rax, %rax
je 0xb76d0
movq %rbx, %rdi
callq 0x8460
movq %rax, 0xd8(%r12)
testq %rax, %rax
je 0xb7719
movq 0x10(%rsp), %rax
movslq 0x908(%rax), %r14
movl %r14d, 0xa8(%r12)
leaq (,%r14,8), %rdi
callq 0x8460
movq %rax, 0xb0(%r12)
testq %rax, %rax
je 0xb775f
testl %r14d, %r14d
jle 0xb70d6
movq 0x10(%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 0xb70c1
cmpl $0x0, 0x10(%r12)
jle 0xb77c4
leaq 0xea(%r12), %rbx
xorl %r13d, %r13d
leaq 0x930fc(%rip), %rax     # 0x14a1f0
addq $0x10, %rax
movq %rax, 0x88(%rsp)
movq %r12, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movq 0x10(%rsp), %rax
movq 0x900(%rax), %rax
movslq (%rax,%r13,4), %rax
movq 0xa0(%r12), %rcx
movl %eax, (%rcx,%r13,4)
movslq 0x9c(%r12), %r14
imulq %r14, %rax
movq 0x20(%r12), %rcx
movslq (%rcx,%r13,4), %rdi
imulq %rax, %rdi
shlq $0x3, %rdi
callq 0x8460
movq 0xd0(%r12), %rcx
movq %rax, (%rcx,%r13,8)
movq 0xa0(%r12), %rax
movq 0xd0(%r12), %rcx
cmpq $0x0, (%rcx,%r13,8)
movslq (%rax,%r13,4), %rcx
je 0xb77c8
movq 0x20(%r12), %rax
movslq (%rax,%r13,4), %rax
imulq %r14, %rcx
imulq %rax, %rcx
shlq $0x3, %rcx
movq %rcx, %rdi
callq 0x8460
movq 0xd8(%r12), %rcx
movq %rax, (%rcx,%r13,8)
movq 0xd8(%r12), %rax
cmpq $0x0, (%rax,%r13,8)
je 0xb7813
callq 0x1c5f0
leaq 0xb0(%rsp), %rdi
movl %eax, %esi
callq 0x1c6a0
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
movq 0x18(%r12), %rax
cmpl $0x0, (%rax,%r13,4)
jle 0xb75aa
leal 0x1(,%r14,2), %eax
movl %eax, 0x3c(%rsp)
xorl %ecx, %ecx
movq %r13, 0x30(%rsp)
movq 0x18(%r12), %rax
movl (%rax,%r13,4), %eax
cmpl %eax, %ecx
jge 0xb7599
leal 0x1(%rcx), %edx
imull %ecx, %edx
shrl %edx
movl %edx, 0x38(%rsp)
movl %ecx, %edx
movq %rcx, 0x68(%rsp)
cmpl %edx, %ecx
jbe 0xb7234
imull %edx, %eax
addl %ecx, %eax
leal 0x1(%rdx), %ecx
imull %edx, %ecx
shrl %ecx
subl %ecx, %eax
movl %eax, %ebx
jmp 0xb723f
imull %ecx, %eax
movl %edx, %ebx
subl 0x38(%rsp), %ebx
addl %eax, %ebx
movq %rdx, 0x70(%rsp)
movq 0x28(%r12), %rax
movq (%rax,%r13,8), %rax
movslq %ebx, %rcx
cmpw $0x1, (%rax,%rcx,2)
movq 0x10(%rsp), %rax
movq 0x900(%rax), %rax
movl (%rax,%r13,4), %ebp
jne 0xb751d
testl %ebp, %ebp
jle 0xb7577
xorl %ebp, %ebp
movl $0x20, %edi
callq 0x83b0
movq %rax, %r14
movabsq $0x100000001, %rbx      # imm = 0x100000001
movq %rbx, 0x8(%rax)
movq 0x88(%rsp), %rax
movq %rax, (%r14)
movl $0x88, %edi
callq 0x83b0
movq %rax, %r13
movq %rbx, 0x8(%rax)
leaq 0x939dd(%rip), %rax     # 0x14ac90
movq %rax, (%r13)
movq %r13, %rbx
addq $0x10, %rbx
movq %rbx, %rdi
leaq 0xf0(%rsp), %rsi
callq 0x1d42e
movq %rbx, 0x10(%r14)
leaq 0x93a07(%rip), %rax     # 0x14ace0
movq %rax, 0x10(%r13)
movq 0x10(%rsp), %rax
movq %rax, 0x38(%r13)
movl 0x3c(%rsp), %eax
movl %eax, 0x40(%r13)
movq 0x20(%rsp), %rax
movq %rax, 0x48(%r13)
movq 0x30(%rsp), %rax
movl %eax, 0x50(%r13)
movq 0x90(%rsp), %rax
movq %rax, 0x58(%r13)
movq 0x98(%rsp), %rax
movq %rax, 0x60(%r13)
movq 0xa0(%rsp), %rax
movq %rax, 0x68(%r13)
movq 0xa8(%rsp), %rax
movq %rax, 0x70(%r13)
movq 0x68(%rsp), %rax
movl %eax, 0x78(%r13)
movq 0x70(%rsp), %rax
movl %eax, 0x7c(%r13)
movl %ebp, 0x80(%r13)
movq %r13, 0x18(%r14)
movq %r14, %rbx
addq $0x10, %rbx
leaq 0x78(%rsp), %rdi
movq %rbx, %rsi
callq 0x1d35e
movq %rbx, 0x58(%rsp)
movq %r14, 0x60(%rsp)
movq 0x94c3e(%rip), %rax     # 0x14bfb0
cmpb $0x0, (%rax)
movl %ebp, 0x1c(%rsp)
je 0xb7381
incl 0x8(%r14)
jmp 0xb7386
lock
incl 0x8(%r14)
movl $0x1, %r13d
lock
xaddl %r13d, 0xd0(%rsp)
movl 0xb0(%rsp), %ecx
testl %ecx, %ecx
je 0xb7437
xorl %r15d, %r15d
leal (%r15,%r13), %eax
xorl %edx, %edx
divl %ecx
movq 0xd8(%rsp), %rbx
imulq $0xb0, %rdx, %rbp
leaq (%rbx,%rbp), %rdi
addq $0x58, %rdi
movq %rdi, 0xf0(%rsp)
callq 0x8080
movl %eax, %r12d
testl %eax, %eax
sete 0xf8(%rsp)
je 0xb73f2
leaq 0xf0(%rsp), %rdi
callq 0x1d17a
jmp 0xb741b
addq %rbp, %rbx
movq %rbx, %rdi
leaq 0x58(%rsp), %rsi
callq 0xb99a6
leaq 0xf0(%rsp), %rdi
callq 0x1d17a
subq $-0x80, %rbx
movq %rbx, %rdi
callq 0x81c0
testl %r12d, %r12d
je 0xb74c2
incl %r15d
movl 0xb0(%rsp), %ecx
cmpl %ecx, %r15d
jb 0xb73a8
movl %r13d, %eax
xorl %edx, %edx
divl 0xb0(%rsp)
movq 0xd8(%rsp), %r12
imulq $0xb0, %rdx, %rbx
leaq (%r12,%rbx), %rax
addq $0x58, %rax
movq %rax, 0xf0(%rsp)
movb $0x0, 0xf8(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x1d20a
addq %rbx, %r12
movb $0x1, 0xf8(%rsp)
movq %r12, %rdi
leaq 0x58(%rsp), %rsi
callq 0xb99a6
leaq 0xf0(%rsp), %rdi
callq 0x1d17a
subq $-0x80, %r12
movq %r12, %rdi
callq 0x81c0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0xb74b7
callq 0x1d2a6
movq 0x30(%rsp), %r13
movl 0x1c(%rsp), %ebp
jmp 0xb74da
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
movl 0x1c(%rsp), %ebp
je 0xb74d5
callq 0x1d2a6
movq 0x30(%rsp), %r13
movq %r14, %rdi
callq 0x1d2a6
leaq 0x40(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x1dcb8
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xb7503
callq 0x1d2a6
incl %ebp
movq 0x10(%rsp), %rax
movq 0x900(%rax), %rax
cmpl (%rax,%r13,4), %ebp
jl 0xb7275
jmp 0xb7577
testl %ebp, %ebp
jle 0xb7577
movq 0x20(%rsp), %rax
movl 0x9c(%rax), %r15d
movq %r15, %r14
shlq $0x3, %r14
xorl %r12d, %r12d
testl %r15d, %r15d
jle 0xb756f
movq 0x20(%rsp), %rcx
movq 0x20(%rcx), %rax
movq 0xd0(%rcx), %rcx
movl (%rax,%r13,4), %eax
imull %r12d, %eax
addl %ebx, %eax
imull %r15d, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
addq (%rcx,%r13,8), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x8200
incl %r12d
cmpl %r12d, %ebp
jne 0xb7537
movq 0x70(%rsp), %rdx
incl %edx
movq 0x20(%rsp), %r12
movq 0x18(%r12), %rax
movl (%rax,%r13,4), %eax
cmpl %eax, %edx
movq 0x68(%rsp), %rcx
jl 0xb721d
incl %ecx
movq 0x18(%r12), %rax
cmpl (%rax,%r13,4), %ecx
jl 0xb71f9
movq 0x40(%rsp), %rbx
movq 0x48(%rsp), %r14
cmpq %r14, %rbx
je 0xb75cf
movq %rbx, %rdi
callq 0x1c724
testl %eax, %eax
jne 0xb78b3
addq $0x10, %rbx
jmp 0xb75b4
movq 0x40(%rsp), %rbx
movq 0x48(%rsp), %r14
cmpq %rbx, %r14
je 0xb75fd
movq %rbx, %r15
movq 0x8(%r15), %rdi
testq %rdi, %rdi
je 0xb75ef
callq 0x1d2a6
addq $0x10, %r15
cmpq %r14, %r15
jne 0xb75e1
movq %rbx, 0x48(%rsp)
movq 0xb0(%r12), %rdi
movq 0xa0(%r12), %rax
movl (%rax,%r13,4), %esi
movq 0xd0(%r12), %rax
movq (%rax,%r13,8), %rdx
movq 0x20(%r12), %rax
movl 0x9c(%r12), %ecx
imull (%rax,%r13,4), %ecx
movq 0xd8(%r12), %rax
movq (%rax,%r13,8), %r8
movq 0x28(%rsp), %rbx
movq %rbx, (%rsp)
movl $0x1, %r9d
callq 0x14191
cmpl $0x1, %eax
je 0xb786e
leaq 0x40(%rsp), %rdi
callq 0x1c770
leaq 0xb0(%rsp), %rdi
callq 0x1c7b0
incq %r13
movslq 0x10(%r12), %rcx
xorl %eax, %eax
cmpq %rcx, %r13
jl 0xb710a
jmp 0xb77b2
shll $0x2, %r14d
leaq 0x39972(%rip), %rsi     # 0xf1004
leaq 0x6d36c(%rip), %rdx     # 0x124a05
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0xea, %r12
leaq 0x39978(%rip), %rsi     # 0xf1034
leaq 0x6d34e(%rip), %rdx     # 0x124a11
movq %r12, %rdi
movl $0x2ae, %ecx            # imm = 0x2AE
jmp 0xb77a3
shll $0x3, %r14d
leaq 0x39929(%rip), %rsi     # 0xf1004
leaq 0x6d33c(%rip), %rdx     # 0x124a1e
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0xea, %r12
leaq 0x3992f(%rip), %rsi     # 0xf1034
leaq 0x6d305(%rip), %rdx     # 0x124a11
movq %r12, %rdi
movl $0x2af, %ecx            # imm = 0x2AF
jmp 0xb77a3
shll $0x3, %r14d
leaq 0x398e0(%rip), %rsi     # 0xf1004
leaq 0x6d2fb(%rip), %rdx     # 0x124a26
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0xea, %r12
leaq 0x398e6(%rip), %rsi     # 0xf1034
leaq 0x6d2bc(%rip), %rdx     # 0x124a11
movq %r12, %rdi
movl $0x2b0, %ecx            # imm = 0x2B0
jmp 0xb77a3
shll $0x3, %r14d
leaq 0x3989a(%rip), %rsi     # 0xf1004
leaq 0x6d2bf(%rip), %rdx     # 0x124a30
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0xea, %r12
leaq 0x398a0(%rip), %rsi     # 0xf1034
leaq 0x6d276(%rip), %rdx     # 0x124a11
movq %r12, %rdi
movl $0x2b3, %ecx            # imm = 0x2B3
movq %rbx, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
addq $0x8f8, %rsp            # imm = 0x8F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0xb77b2
movq 0x20(%r12), %rax
imull %r14d, %ecx
imull (%rax,%r13,4), %ecx
shll $0x3, %ecx
leaq 0x39824(%rip), %rsi     # 0xf1004
leaq 0x6d250(%rip), %rdx     # 0x124a37
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0x39834(%rip), %rsi     # 0xf1034
leaq 0x6d20a(%rip), %rdx     # 0x124a11
movq 0x28(%rsp), %rdi
movl $0x2c4, %ecx            # imm = 0x2C4
jmp 0xb77a3
movq 0xa0(%r12), %rax
imull (%rax,%r13,4), %r14d
movq 0x20(%r12), %rax
imull (%rax,%r13,4), %r14d
shll $0x3, %r14d
leaq 0x397cf(%rip), %rsi     # 0xf1004
leaq 0x6d20d(%rip), %rdx     # 0x124a49
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x30c2c
leaq 0x397dc(%rip), %rsi     # 0xf1034
leaq 0x6d1b2(%rip), %rdx     # 0x124a11
movq 0x28(%rsp), %rdi
movl $0x2c5, %ecx            # imm = 0x2C5
jmp 0xb77a3
leaq 0x39b7b(%rip), %rsi     # 0xf13f0
leaq 0x6d1e1(%rip), %rdx     # 0x124a5d
leaq 0xf0(%rsp), %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x3979f(%rip), %rsi     # 0xf1034
leaq 0x6d175(%rip), %rdx     # 0x124a11
leaq 0xf0(%rsp), %r8
movq %rbx, %rdi
movl $0x337, %ecx            # imm = 0x337
xorl %eax, %eax
callq 0x30c2c
leaq 0x40(%rsp), %rdi
callq 0x1c770
leaq 0xb0(%rsp), %rdi
callq 0x1c7b0
jmp 0xb77ad
jmp 0xb78ee
jmp 0xb78ee
jmp 0xb78ee
movq %rax, %rbx
jmp 0xb7922
jmp 0xb7912
movq %rax, %rbx
jmp 0xb7943
movq %rax, %rbx
movq %r13, %rdi
callq 0x8380
jmp 0xb78f6
movq %rax, %rbx
jmp 0xb794b
movq %rax, %rbx
movq %r14, %rdi
callq 0x8380
jmp 0xb794b
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
jne 0xb7946
jmp 0xb794b
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x1d17a
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0xb7931
callq 0x1d2a6
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xb7943
callq 0x1d2a6
movq %r14, %rdi
callq 0x1d2a6
leaq 0x40(%rsp), %rdi
callq 0x1c770
leaq 0xb0(%rsp), %rdi
callq 0x1c7b0
movq %rbx, %rdi
callq 0x8650