// File: /workspace/github_c_makefile_star2_O2/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 $0x918, %rsp            # imm = 0x918
movq %r9, %r14
movq %r8, 0xc8(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, 0xc0(%rsp)
movq %rsi, 0xb8(%rsp)
movq %rdi, 0xb0(%rsp)
movl 0x10(%r9), %ebp
movslq %ebp, %rbx
leaq (,%rbx,4), %rdi
callq 0x8490
movq %rax, 0xa0(%r14)
pushq $0x1
popq %rcx
movl %ecx, 0x20(%rsp)
testq %rax, %rax
je 0xadc74
shlq $0x3, %rbx
movq %rbx, %rdi
callq 0x8490
movq %rax, 0xd0(%r14)
testq %rax, %rax
je 0xadcbb
movq %rbx, %rdi
callq 0x8490
movq %rax, 0xd8(%r14)
testq %rax, %rax
je 0xae261
movq 0x18(%rsp), %rax
movslq 0x908(%rax), %rbx
movl %ebx, 0xa8(%r14)
movq %rbx, %rdi
shlq $0x3, %rdi
callq 0x8490
movq %rax, 0xb0(%r14)
testq %rax, %rax
je 0xae2a5
xorl %ecx, %ecx
testl %ebx, %ebx
movl $0x0, %edx
cmovgl %ebx, %edx
cmpq %rcx, %rdx
je 0xadd02
movq 0x18(%rsp), %rsi
movq 0x910(%rsi), %rsi
cvtsi2sdl (%rsi,%rcx,4), %xmm0
movsd %xmm0, (%rax,%rcx,8)
incq %rcx
jmp 0xadc50
shll $0x2, %ebp
leaq 0x37386(%rip), %rsi     # 0xe5004
leaq 0x6ac38(%rip), %rdx     # 0x1188bd
leaq 0x110(%rsp), %rbx
movq %rbx, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0xea, %r14
leaq 0x3738d(%rip), %rsi     # 0xe5034
leaq 0x6ac1b(%rip), %rdx     # 0x1188c9
movq %r14, %rdi
movl $0x2ae, %ecx            # imm = 0x2AE
jmp 0xae2e9
shll $0x3, %ebp
leaq 0x3733f(%rip), %rsi     # 0xe5004
leaq 0x6ac0a(%rip), %rdx     # 0x1188d6
leaq 0x110(%rsp), %rbx
movq %rbx, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0xea, %r14
leaq 0x37346(%rip), %rsi     # 0xe5034
leaq 0x6abd4(%rip), %rdx     # 0x1188c9
movq %r14, %rdi
movl $0x2af, %ecx            # imm = 0x2AF
jmp 0xae2e9
leaq 0xea(%r14), %rax
movq %rax, 0x28(%rsp)
xorl %r13d, %r13d
leaq 0x15(%rsp), %r12
leaq 0x93503(%rip), %rax     # 0x141220
addq $0x10, %rax
movq %rax, 0xa8(%rsp)
movslq %ebp, %rax
cmpq %rax, %r13
jge 0xae309
movq 0x18(%rsp), %rax
movq 0x900(%rax), %rax
movslq (%rax,%r13,4), %rax
movq 0xa0(%r14), %rcx
movl %eax, (%rcx,%r13,4)
movslq 0x9c(%r14), %r15
imulq %r15, %rax
movq 0x20(%r14), %rcx
movslq (%rcx,%r13,4), %rdi
imulq %rax, %rdi
shlq $0x3, %rdi
callq 0x8490
movq 0xd0(%r14), %rcx
movq %rax, (%rcx,%r13,8)
movq 0xa0(%r14), %rax
movq 0xd0(%r14), %rcx
cmpq $0x0, (%rcx,%r13,8)
movslq (%rax,%r13,4), %rcx
je 0xae313
movq 0x20(%r14), %rax
movslq (%rax,%r13,4), %rax
imulq %r15, %rcx
imulq %rax, %rcx
shlq $0x3, %rcx
movq %rcx, %rdi
callq 0x8490
movq 0xd8(%r14), %rcx
movq %rax, (%rcx,%r13,8)
movq 0xd8(%r14), %rax
cmpq $0x0, (%rax,%r13,8)
je 0xae35d
leal 0x1(,%r15,2), %eax
movl %eax, 0x4c(%rsp)
callq 0x1a2a0
leaq 0xd0(%rsp), %rdi
movl %eax, %esi
callq 0x1a33e
andq $0x0, 0x60(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
movq 0x18(%r14), %rax
movl (%rax,%r13,4), %edx
xorl %ecx, %ecx
cmpl %edx, %ecx
jge 0xae1bd
leal 0x1(%rcx), %esi
movl %esi, 0x44(%rsp)
imull %ecx, %esi
shrl %esi
movl %esi, 0x48(%rsp)
movl %ecx, %esi
movq %rcx, 0x68(%rsp)
cmpl %edx, %esi
jge 0xae1b4
cmpl %esi, %ecx
movq %rsi, 0x70(%rsp)
jbe 0xade4e
imull %esi, %edx
addl %ecx, %edx
leal 0x1(%rsi), %ecx
imull %esi, %ecx
shrl %ecx
subl %ecx, %edx
movl %edx, %ecx
jmp 0xade59
imull %ecx, %edx
movl %esi, %ecx
subl 0x48(%rsp), %ecx
addl %edx, %ecx
movq 0x28(%r14), %rdx
movq (%rdx,%r13,8), %rdx
movslq %ecx, %rsi
cmpw $0x1, (%rdx,%rsi,2)
jne 0xae133
xorl %ebx, %ebx
movq 0x18(%rsp), %rax
movq 0x900(%rax), %rax
cmpl (%rax,%r13,4), %ebx
jge 0xae19b
andq $0x0, 0x78(%rsp)
movq %r12, %rdi
pushq $0x1
popq %rsi
callq 0x1b0f6
movq %rax, %r15
movl %ebx, 0x24(%rsp)
movq %r12, 0x98(%rsp)
movq %rax, 0xa0(%rsp)
movabsq $0x100000001, %rbx      # imm = 0x100000001
movq %rbx, 0x8(%rax)
movq 0xa8(%rsp), %rax
movq %rax, (%r15)
movl $0x88, %edi
callq 0x83d0
movq %rax, %rbp
leaq 0x17(%rsp), %rax
movq %rax, 0x110(%rsp)
movq %rbp, 0x118(%rsp)
movq %rbx, 0x8(%rbp)
leaq 0x93dab(%rip), %rax     # 0x141ca0
movq %rax, (%rbp)
movq %rbp, %r12
addq $0x10, %r12
movq %r12, %rdi
leaq 0x16(%rsp), %rsi
callq 0x1b18a
movq %r15, %rbx
addq $0x10, %rbx
leaq 0x93dd5(%rip), %rax     # 0x141cf0
movq %rax, 0x10(%rbp)
movq 0x18(%rsp), %rax
movq %rax, 0x38(%rbp)
movl 0x4c(%rsp), %eax
movl %eax, 0x40(%rbp)
movq %r14, 0x48(%rbp)
movl %r13d, 0x50(%rbp)
movq 0xb0(%rsp), %rax
movq %rax, 0x58(%rbp)
movq 0xb8(%rsp), %rax
movq %rax, 0x60(%rbp)
movq 0xc0(%rsp), %rax
movq %rax, 0x68(%rbp)
movq 0xc8(%rsp), %rax
movq %rax, 0x70(%rbp)
movq 0x68(%rsp), %rax
movl %eax, 0x78(%rbp)
movq 0x70(%rsp), %rax
movl %eax, 0x7c(%rbp)
movl 0x24(%rsp), %eax
movl %eax, 0x80(%rbp)
andq $0x0, 0x118(%rsp)
leaq 0x110(%rsp), %rdi
callq 0xb009e
movq %r12, 0x10(%r15)
andq $0x0, 0x38(%rsp)
movq %rbp, 0x18(%r15)
andq $0x0, 0x30(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x1afb0
andq $0x0, 0xa0(%rsp)
movq %r15, 0x80(%rsp)
movq %rbx, 0x78(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x1b0e8
leaq 0x88(%rsp), %rdi
movq %rbx, %rsi
callq 0x1b09c
leaq 0x30(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x1b986
pushq $0x1
popq %rax
movl %eax, %r15d
lock
xaddl %r15d, 0xf0(%rsp)
xorl %r12d, %r12d
movl 0xd0(%rsp), %ecx
cmpl %ecx, %r12d
jae 0xae05f
leal (%r15,%r12), %eax
xorl %edx, %edx
divl %ecx
movq 0xf8(%rsp), %rbx
imulq $0xb0, %rdx, %rbp
leaq (%rbx,%rbp), %rdi
addq $0x58, %rdi
movq %rdi, 0x110(%rsp)
callq 0x1add8
movb %al, 0x118(%rsp)
testb %al, %al
jne 0xae0c4
leaq 0x110(%rsp), %rdi
callq 0x1adc2
incl %r12d
jmp 0xae00a
movl %r15d, %eax
xorl %edx, %edx
divl %ecx
movq 0xf8(%rsp), %rbx
imulq $0xb0, %rdx, %r15
leaq (%rbx,%r15), %rsi
addq $0x58, %rsi
leaq 0x110(%rsp), %rdi
callq 0x1ae48
leaq 0x15(%rsp), %r12
addq %r15, %rbx
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
callq 0xb07d4
leaq 0x110(%rsp), %rdi
callq 0x1adc2
subq $-0x80, %rbx
movq %rbx, %rdi
callq 0x81e0
leaq 0x38(%rsp), %rdi
callq 0x1afb0
jmp 0xae0fc
addq %rbp, %rbx
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
callq 0xb07d4
leaq 0x110(%rsp), %rdi
callq 0x1adc2
subq $-0x80, %rbx
movq %rbx, %rdi
callq 0x81e0
leaq 0x38(%rsp), %rdi
callq 0x1afb0
leaq 0x15(%rsp), %r12
leaq 0x80(%rsp), %rdi
callq 0x1afb0
leaq 0x50(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x1bb4a
movl 0x24(%rsp), %ebx
leaq 0x90(%rsp), %rdi
callq 0x1afb0
incl %ebx
jmp 0xade71
movq 0x18(%rsp), %rdx
movq 0x900(%rdx), %rdx
movl (%rdx,%r13,4), %edx
xorl %esi, %esi
testl %edx, %edx
cmovlel %esi, %edx
cmpl %edx, %esi
je 0xae19f
movl 0x9c(%r14), %edi
testl %edi, %edi
movl $0x0, %r8d
cmovgl %edi, %r8d
xorl %r9d, %r9d
cmpl %r9d, %r8d
je 0xae197
movq 0x20(%r14), %r10
movq 0xd0(%r14), %r11
movq (%r11,%r13,8), %r11
movl (%r10,%r13,4), %r10d
imull %esi, %r10d
addl %ecx, %r10d
imull %edi, %r10d
movslq %r10d, %r10
addq %r9, %r10
andq $0x0, (%r11,%r10,8)
incq %r9
jmp 0xae164
incl %esi
jmp 0xae14a
movq 0x18(%r14), %rax
movq 0x70(%rsp), %rsi
incl %esi
movl (%rax,%r13,4), %edx
movq 0x68(%rsp), %rcx
jmp 0xade2a
movl 0x44(%rsp), %ecx
jmp 0xade0b
movq 0x50(%rsp), %rbx
movq 0x58(%rsp), %r15
cmpq %r15, %rbx
je 0xae1e1
movq %rbx, %rdi
callq 0x1a3be
addq $0x10, %rbx
testl %eax, %eax
je 0xae1c7
jmp 0xae400
leaq 0x50(%rsp), %rdi
callq 0x1a3f0
movq 0xb0(%r14), %rdi
movq 0xa0(%r14), %rax
movl (%rax,%r13,4), %esi
movq 0xd0(%r14), %rax
movq (%rax,%r13,8), %rdx
movq 0x20(%r14), %rax
movl 0x9c(%r14), %ecx
imull (%rax,%r13,4), %ecx
movq 0xd8(%r14), %rax
movq (%rax,%r13,8), %r8
movq 0x28(%rsp), %rax
movq %rax, (%rsp)
pushq $0x1
popq %r9
callq 0x125a5
cmpl $0x1, %eax
je 0xae3b6
leaq 0x50(%rsp), %rdi
callq 0x1a3f8
leaq 0xd0(%rsp), %rdi
callq 0x1a41a
incq %r13
movl 0x10(%r14), %ebp
jmp 0xadd29
shll $0x3, %ebp
leaq 0x36d99(%rip), %rsi     # 0xe5004
leaq 0x6a66c(%rip), %rdx     # 0x1188de
leaq 0x110(%rsp), %rbx
movq %rbx, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0xea, %r14
leaq 0x36da0(%rip), %rsi     # 0xe5034
leaq 0x6a62e(%rip), %rdx     # 0x1188c9
movq %r14, %rdi
movl $0x2b0, %ecx            # imm = 0x2B0
jmp 0xae2e9
leal (,%rbx,8), %ecx
leaq 0x36d51(%rip), %rsi     # 0xe5004
leaq 0x6a62e(%rip), %rdx     # 0x1188e8
leaq 0x110(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0xea, %r14
leaq 0x36d5a(%rip), %rsi     # 0xe5034
leaq 0x6a5e8(%rip), %rdx     # 0x1188c9
movq %r14, %rdi
movl $0x2b3, %ecx            # imm = 0x2B3
movq %rbx, %r8
xorl %eax, %eax
callq 0x2e014
movl 0x20(%rsp), %eax
addq $0x918, %rsp            # imm = 0x918
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x0, 0x20(%rsp)
jmp 0xae2f3
movq 0x20(%r14), %rax
imull %r15d, %ecx
imull (%rax,%r13,4), %ecx
shll $0x3, %ecx
leaq 0x36cda(%rip), %rsi     # 0xe5004
leaq 0x6a5be(%rip), %rdx     # 0x1188ef
leaq 0x110(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x36cea(%rip), %rsi     # 0xe5034
leaq 0x6a578(%rip), %rdx     # 0x1188c9
movq 0x28(%rsp), %rdi
movl $0x2c4, %ecx            # imm = 0x2C4
jmp 0xae2e9
movq 0xa0(%r14), %rax
imull (%rax,%r13,4), %r15d
movq 0x20(%r14), %rax
imull (%rax,%r13,4), %r15d
shll $0x3, %r15d
leaq 0x36c87(%rip), %rsi     # 0xe5004
leaq 0x6a57d(%rip), %rdx     # 0x118901
leaq 0x110(%rsp), %rbx
movq %rbx, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2e014
leaq 0x36c94(%rip), %rsi     # 0xe5034
leaq 0x6a522(%rip), %rdx     # 0x1188c9
movq 0x28(%rsp), %rdi
movl $0x2c5, %ecx            # imm = 0x2C5
jmp 0xae2e9
leaq 0x37033(%rip), %rsi     # 0xe53f0
leaq 0x6a551(%rip), %rdx     # 0x118915
leaq 0x110(%rsp), %rdi
movq 0x28(%rsp), %rbx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x36c52(%rip), %rsi     # 0xe5034
leaq 0x6a4e0(%rip), %rdx     # 0x1188c9
leaq 0x110(%rsp), %r8
movq %rbx, %rdi
movl $0x337, %ecx            # imm = 0x337
xorl %eax, %eax
callq 0x2e014
leaq 0x50(%rsp), %rdi
callq 0x1a3f8
leaq 0xd0(%rsp), %rdi
callq 0x1a41a
jmp 0xae2f3
jmp 0xae457
jmp 0xae457
jmp 0xae457
jmp 0xae429
movq %rax, %rbx
jmp 0xae439
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x1adc2
leaq 0x38(%rsp), %rdi
callq 0x1afb0
leaq 0x90(%rsp), %rdi
callq 0x1afb0
jmp 0xae46c
movq %rax, %rbx
jmp 0xae48b
movq %rax, %rbx
jmp 0xae498
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
jmp 0xae474
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x1afb0
jmp 0xae498
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0xb009e
leaq 0x98(%rsp), %rdi
callq 0x1b0e8
leaq 0x50(%rsp), %rdi
callq 0x1a3f8
leaq 0xd0(%rsp), %rdi
callq 0x1a41a
movq %rbx, %rdi
callq 0x8680