// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../source/lensing.c
// Function: lensing_indices
int lensing_indices(
                    struct precision * ppr,
                    struct harmonic * phr,
                    struct lensing * ple
                    ){

  int index_l;

  double ** cl_md_ic; /* array with argument
                         cl_md_ic[index_md][index_ic1_ic2*phr->ct_size+index_ct] */

  double ** cl_md;    /* array with argument
                         cl_md[index_md][index_ct] */

  int index_md;
  int index_lt;

  /* indices of all Cl types (lensed and unlensed) */

  if (phr->has_tt == _TRUE_) {
    ple->has_tt = _TRUE_;
    ple->index_lt_tt=phr->index_ct_tt;
  }
  else {
    ple->has_tt = _FALSE_;
  }

  if (phr->has_ee == _TRUE_) {
    ple->has_ee = _TRUE_;
    ple->index_lt_ee=phr->index_ct_ee;
  }
  else {
    ple->has_ee = _FALSE_;
  }

  if (phr->has_te == _TRUE_) {
    ple->has_te = _TRUE_;
    ple->index_lt_te=phr->index_ct_te;
  }
  else {
    ple->has_te = _FALSE_;
  }

  if (phr->has_bb == _TRUE_) {
    ple->has_bb = _TRUE_;
    ple->index_lt_bb=phr->index_ct_bb;
  }
  else {
    ple->has_bb = _FALSE_;
  }

  if (phr->has_pp == _TRUE_) {
    ple->has_pp = _TRUE_;
    ple->index_lt_pp=phr->index_ct_pp;
  }
  else {
    ple->has_pp = _FALSE_;
  }

  if (phr->has_tp == _TRUE_) {
    ple->has_tp = _TRUE_;
    ple->index_lt_tp=phr->index_ct_tp;
  }
  else {
    ple->has_tp = _FALSE_;
  }

  if (phr->has_dd == _TRUE_) {
    ple->has_dd = _TRUE_;
    ple->index_lt_dd=phr->index_ct_dd;
  }
  else {
    ple->has_dd = _FALSE_;
  }

  if (phr->has_td == _TRUE_) {
    ple->has_td = _TRUE_;
    ple->index_lt_td=phr->index_ct_td;
  }
  else {
    ple->has_td = _FALSE_;
  }

  if (phr->has_ll == _TRUE_) {
    ple->has_ll = _TRUE_;
    ple->index_lt_ll=phr->index_ct_ll;
  }
  else {
    ple->has_ll = _FALSE_;
  }

  if (phr->has_tl == _TRUE_) {
    ple->has_tl = _TRUE_;
    ple->index_lt_tl=phr->index_ct_tl;
  }
  else {
    ple->has_tl = _FALSE_;
  }

  ple->lt_size = phr->ct_size;

  /* number of multipoles */

  ple->l_unlensed_max = phr->l_max_tot;

  ple->l_lensed_max = ple->l_unlensed_max - ppr->delta_l_max;

  for (index_l=0; (index_l < phr->l_size_max) && (phr->l[index_l] <= ple->l_lensed_max); index_l++);

  if (index_l < phr->l_size_max) index_l++; /* one more point in order to be able to interpolate till ple->l_lensed_max */

  ple->l_size = index_l+1;

  class_alloc(ple->l,ple->l_size*sizeof(double),ple->error_message);

  for (index_l=0; index_l < ple->l_size; index_l++) {

    ple->l[index_l] = phr->l[index_l];

  }

  /* allocate table where results will be stored */

  class_alloc(ple->cl_lens,
              ple->l_size*ple->lt_size*sizeof(double),
              ple->error_message);

  class_alloc(ple->ddcl_lens,
              ple->l_size*ple->lt_size*sizeof(double),
              ple->error_message);

  /* fill with unlensed cls */

  class_alloc(cl_md_ic,
              phr->md_size*sizeof(double *),
              ple->error_message);

  class_alloc(cl_md,
              phr->md_size*sizeof(double *),
              ple->error_message);

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

    if (phr->md_size > 1)

      class_alloc(cl_md[index_md],
                  phr->ct_size*sizeof(double),
                  ple->error_message);

    if (phr->ic_size[index_md] > 1)

      class_alloc(cl_md_ic[index_md],
                  phr->ic_ic_size[index_md]*phr->ct_size*sizeof(double),
                  ple->error_message);
  }

  for (index_l=0; index_l<ple->l_size; index_l++) {

    class_call(harmonic_cl_at_l(phr,ple->l[index_l],&(ple->cl_lens[index_l*ple->lt_size]),cl_md,cl_md_ic),
               phr->error_message,
               ple->error_message);

  }

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

    if (phr->md_size > 1)
      free(cl_md[index_md]);

    if (phr->ic_size[index_md] > 1)
      free(cl_md_ic[index_md]);

  }

  free(cl_md_ic);
  free(cl_md);

  /* we want to output Cl_lensed up to the same l_max as Cl_unlensed
     (even if a number delta_l_max of extra values of l have been used
     internally for more accurate results). Notable exception to the
     above rule: ClBB_lensed(scalars) must be outputed at least up to the same l_max as
     ClEE_unlensed(scalars) (since ClBB_unlensed is null for scalars)
  */

  class_alloc(ple->l_max_lt,ple->lt_size*sizeof(double),ple->error_message);
  for (index_lt = 0; index_lt < ple->lt_size; index_lt++) {
    ple->l_max_lt[index_lt]=0.;
    for (index_md = 0; index_md < phr->md_size; index_md++) {
      ple->l_max_lt[index_lt]=MAX(ple->l_max_lt[index_lt],phr->l_max_ct[index_md][index_lt]);

      if ((ple->has_bb == _TRUE_) && (ple->has_ee == _TRUE_) && (index_lt == ple->index_lt_bb)) {
        ple->l_max_lt[index_lt]=MAX(ple->l_max_lt[index_lt],phr->l_max_ct[index_md][ple->index_lt_ee]);
      }

    }
  }

  return _SUCCESS_;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x828, %rsp            # imm = 0x828
movq %rdx, %rbx
movq %rsi, %r14
cmpl $0x1, 0x30(%rsi)
jne 0xbc296
movl $0x1, 0x4(%rbx)
movl 0x64(%r14), %eax
movl %eax, 0x2c(%rbx)
jmp 0xbc29d
movl $0x0, 0x4(%rbx)
cmpl $0x1, 0x34(%r14)
jne 0xbc2b4
movl $0x1, 0x8(%rbx)
movl 0x68(%r14), %eax
movl %eax, 0x30(%rbx)
jmp 0xbc2bb
movl $0x0, 0x8(%rbx)
cmpl $0x1, 0x38(%r14)
jne 0xbc2d2
movl $0x1, 0xc(%rbx)
movl 0x6c(%r14), %eax
movl %eax, 0x34(%rbx)
jmp 0xbc2d9
movl $0x0, 0xc(%rbx)
cmpl $0x1, 0x3c(%r14)
jne 0xbc2f0
movl $0x1, 0x10(%rbx)
movl 0x70(%r14), %eax
movl %eax, 0x38(%rbx)
jmp 0xbc2f7
movl $0x0, 0x10(%rbx)
cmpl $0x1, 0x40(%r14)
jne 0xbc30e
movl $0x1, 0x14(%rbx)
movl 0x74(%r14), %eax
movl %eax, 0x3c(%rbx)
jmp 0xbc315
movl $0x0, 0x14(%rbx)
cmpl $0x1, 0x44(%r14)
jne 0xbc32c
movl $0x1, 0x18(%rbx)
movl 0x78(%r14), %eax
movl %eax, 0x40(%rbx)
jmp 0xbc333
movl $0x0, 0x18(%rbx)
cmpl $0x1, 0x4c(%r14)
jne 0xbc34d
movl $0x1, 0x1c(%rbx)
movl 0x80(%r14), %eax
movl %eax, 0x44(%rbx)
jmp 0xbc354
movl $0x0, 0x1c(%rbx)
cmpl $0x1, 0x50(%r14)
jne 0xbc36e
movl $0x1, 0x20(%rbx)
movl 0x84(%r14), %eax
movl %eax, 0x48(%rbx)
jmp 0xbc375
movl $0x0, 0x20(%rbx)
cmpl $0x1, 0x58(%r14)
jne 0xbc38f
movl $0x1, 0x24(%rbx)
movl 0x8c(%r14), %eax
movl %eax, 0x4c(%rbx)
jmp 0xbc396
movl $0x0, 0x24(%rbx)
cmpl $0x1, 0x5c(%r14)
jne 0xbc3b0
movl $0x1, 0x28(%rbx)
movl 0x90(%r14), %eax
movl %eax, 0x50(%rbx)
jmp 0xbc3b7
movl $0x0, 0x28(%rbx)
movslq 0x9c(%r14), %r15
movl %r15d, 0x54(%rbx)
movl 0xc8(%r14), %edx
movl %edx, 0x58(%rbx)
subl 0x8e0(%rdi), %edx
movl %edx, 0x5c(%rbx)
movl 0xa8(%r14), %eax
xorl %r12d, %r12d
testl %eax, %eax
setg %cl
jle 0xbc427
cvtsi2sd %edx, %xmm0
movq 0xb0(%r14), %rdx
ucomisd (%rdx), %xmm0
jb 0xbc427
movq %rax, %rsi
decq %rsi
xorl %ecx, %ecx
cmpq %rcx, %rsi
je 0xbc41b
leaq 0x1(%rcx), %r12
ucomisd 0x8(%rdx,%rcx,8), %xmm0
movq %r12, %rcx
jae 0xbc3ff
cmpq %rax, %r12
setb %cl
jmp 0xbc427
incq %rcx
cmpq %rax, %rcx
setb %cl
movl %eax, %r12d
movzbl %cl, %r13d
leal (%r12,%r13), %eax
leal (%r12,%r13), %ebp
incl %ebp
movl %ebp, 0x60(%rbx)
leaq 0x8(,%rax,8), %rdi
callq 0x8460
movq %rax, 0x70(%rbx)
testq %rax, %rax
je 0xbc699
movq 0xb0(%r14), %rcx
leal (%r12,%r13), %edx
incl %edx
xorl %esi, %esi
movsd (%rcx,%rsi,8), %xmm0
movsd %xmm0, (%rax,%rsi,8)
incq %rsi
cmpq %rsi, %rdx
jne 0xbc461
imull %r15d, %ebp
movslq %ebp, %r12
shlq $0x3, %r12
movq %r12, %rdi
callq 0x8460
movq %rax, 0x78(%rbx)
testq %rax, %rax
je 0xbc6dd
movq %r12, %rdi
callq 0x8460
movq %rax, 0x80(%rbx)
testq %rax, %rax
je 0xbc721
movslq 0x10(%r14), %rbp
leaq (,%rbp,8), %r13
movq %r13, %rdi
callq 0x8460
testq %rax, %rax
je 0xbc765
movq %rax, %r12
movq %r13, %rdi
callq 0x8460
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0xbc7a9
movq %r12, 0x8(%rsp)
testl %ebp, %ebp
jle 0xbc559
leaq (,%r15,8), %rax
movq %rax, 0x18(%rsp)
xorl %r12d, %r12d
cmpl $0x1, %ebp
je 0xbc51b
movq 0x18(%rsp), %rdi
callq 0x8460
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%r12,8)
testq %rax, %rax
je 0xbc87f
movq 0x18(%r14), %rax
cmpl $0x2, (%rax,%r12,4)
jl 0xbc551
movq 0x20(%r14), %rax
movslq (%rax,%r12,4), %r13
imulq %r15, %r13
leaq (,%r13,8), %rdi
callq 0x8460
movq 0x8(%rsp), %rcx
movq %rax, (%rcx,%r12,8)
testq %rax, %rax
je 0xbc8c2
incq %r12
cmpq %r12, %rbp
jne 0xbc4fa
cmpl $0x0, 0x60(%rbx)
movq 0x8(%rsp), %r12
movq 0x10(%rsp), %r13
jle 0xbc5ac
xorl %r15d, %r15d
movq 0x70(%rbx), %rax
movsd (%rax,%r15,8), %xmm0
movslq 0x54(%rbx), %rax
movslq %r15d, %rsi
imulq %rax, %rsi
shlq $0x3, %rsi
addq 0x78(%rbx), %rsi
movq %r14, %rdi
movq %r13, %rdx
movq %r12, %rcx
callq 0xb5afc
cmpl $0x1, %eax
je 0xbc7ed
incq %r15
movslq 0x60(%rbx), %rax
cmpq %rax, %r15
jl 0xbc56c
movl 0x10(%r14), %eax
testl %eax, %eax
jle 0xbc5e6
xorl %r15d, %r15d
cmpl $0x2, %eax
jl 0xbc5c6
movq (%r13,%r15,8), %rdi
callq 0x8410
movq 0x18(%r14), %rax
cmpl $0x2, (%rax,%r15,4)
jl 0xbc5da
movq (%r12,%r15,8), %rdi
callq 0x8410
incq %r15
movslq 0x10(%r14), %rax
cmpq %rax, %r15
jl 0xbc5b7
movq %r12, %rdi
callq 0x8410
movq %r13, %rdi
callq 0x8410
movslq 0x54(%rbx), %r15
leaq (,%r15,8), %rdi
callq 0x8460
movq %rax, 0x68(%rbx)
testq %rax, %rax
je 0xbc839
movslq 0x54(%rbx), %rdx
testq %rdx, %rdx
jle 0xbc926
movl 0x10(%r14), %esi
xorl %edi, %edi
movl $0x0, (%rax,%rdi,4)
testl %esi, %esi
jle 0xbc68a
movq 0xb8(%r14), %rcx
movl 0x10(%rbx), %r8d
movl (%rax,%rdi,4), %r10d
xorl %r9d, %r9d
movl %r10d, %ebp
movq (%rcx,%r9,8), %r11
movl (%r11,%rdi,4), %r10d
cmpl %r10d, %ebp
cmovgl %ebp, %r10d
movl %r10d, (%rax,%rdi,4)
cmpl $0x1, %r8d
jne 0xbc682
cmpl $0x1, 0x8(%rbx)
jne 0xbc682
movl 0x38(%rbx), %r15d
cmpq %r15, %rdi
jne 0xbc682
movslq 0x30(%rbx), %r15
movl (%r11,%r15,4), %r11d
cmpl %r11d, %r10d
cmovlel %r11d, %r10d
movl %r10d, (%rax,%rdi,4)
incq %r9
cmpq %r9, %rsi
jne 0xbc644
incq %rdi
xorl %ecx, %ecx
cmpq %rdx, %rdi
jne 0xbc627
jmp 0xbc912
shll $0x3, %ebp
leaq 0x34961(%rip), %rsi     # 0xf1004
leaq 0x6c30e(%rip), %rdx     # 0x1289b8
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x92, %rbx
leaq 0x3496b(%rip), %rsi     # 0xf1034
leaq 0x6c2ef(%rip), %rdx     # 0x1289bf
movq %rbx, %rdi
movl $0x3b8, %ecx            # imm = 0x3B8
jmp 0xbc903
shll $0x3, %ebp
leaq 0x3491d(%rip), %rsi     # 0xf1004
leaq 0x6c2e1(%rip), %rdx     # 0x1289cf
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x92, %rbx
leaq 0x34927(%rip), %rsi     # 0xf1034
leaq 0x6c2ab(%rip), %rdx     # 0x1289bf
movq %rbx, %rdi
movl $0x3c4, %ecx            # imm = 0x3C4
jmp 0xbc903
shll $0x3, %ebp
leaq 0x348d9(%rip), %rsi     # 0xf1004
leaq 0x6c2aa(%rip), %rdx     # 0x1289dc
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x92, %rbx
leaq 0x348e3(%rip), %rsi     # 0xf1034
leaq 0x6c267(%rip), %rdx     # 0x1289bf
movq %rbx, %rdi
movl $0x3c8, %ecx            # imm = 0x3C8
jmp 0xbc903
shll $0x3, %ebp
leaq 0x34895(%rip), %rsi     # 0xf1004
leaq 0x6c0c0(%rip), %rdx     # 0x128836
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x92, %rbx
leaq 0x3489f(%rip), %rsi     # 0xf1034
leaq 0x6c223(%rip), %rdx     # 0x1289bf
movq %rbx, %rdi
movl $0x3ce, %ecx            # imm = 0x3CE
jmp 0xbc903
shll $0x3, %ebp
leaq 0x34851(%rip), %rsi     # 0xf1004
leaq 0x6c085(%rip), %rdx     # 0x12883f
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x92, %rbx
leaq 0x3485b(%rip), %rsi     # 0xf1034
leaq 0x6c1df(%rip), %rdx     # 0x1289bf
movq %rbx, %rdi
movl $0x3d2, %ecx            # imm = 0x3D2
jmp 0xbc903
addq $0xea, %r14
leaq 0x34bf5(%rip), %rsi     # 0xf13f0
leaq 0x6c1e9(%rip), %rdx     # 0x1289eb
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x92, %rbx
leaq 0x34812(%rip), %rsi     # 0xf1034
leaq 0x6c196(%rip), %rdx     # 0x1289bf
movq %rbx, %rdi
movl $0x3e7, %ecx            # imm = 0x3E7
movq %r15, %r8
jmp 0xbc906
shll $0x3, %r15d
leaq 0x347c0(%rip), %rsi     # 0xf1004
leaq 0x6c1fb(%rip), %rdx     # 0x128a46
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x92, %rbx
leaq 0x347c9(%rip), %rsi     # 0xf1034
leaq 0x6c14d(%rip), %rdx     # 0x1289bf
movq %rbx, %rdi
movl $0x3ff, %ecx            # imm = 0x3FF
jmp 0xbc903
shll $0x3, %r15d
leaq 0x3477a(%rip), %rsi     # 0xf1004
leaq 0x6bfb4(%rip), %rdx     # 0x128845
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x92, %rbx
leaq 0x34783(%rip), %rsi     # 0xf1034
leaq 0x6c107(%rip), %rdx     # 0x1289bf
movq %rbx, %rdi
movl $0x3da, %ecx            # imm = 0x3DA
jmp 0xbc903
shll $0x3, %r13d
leaq 0x34737(%rip), %rsi     # 0xf1004
leaq 0x6bf81(%rip), %rdx     # 0x128855
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x92, %rbx
leaq 0x34740(%rip), %rsi     # 0xf1034
leaq 0x6c0c4(%rip), %rdx     # 0x1289bf
movq %rbx, %rdi
movl $0x3e0, %ecx            # imm = 0x3E0
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %ecx
movl %ecx, %eax
addq $0x828, %rsp            # imm = 0x828
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ecx, %ecx
jmp 0xbc912