// File: /workspace/github_c_makefile_star2_O2/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, %r15
xorl %eax, %eax
cmpl $0x1, 0x30(%rsi)
movl $0x0, %ecx
jne 0xb3428
movl 0x64(%r15), %ecx
movl %ecx, 0x2c(%rbx)
pushq $0x1
popq %rcx
movl %ecx, 0x4(%rbx)
cmpl $0x1, 0x34(%r15)
jne 0xb343c
movl 0x68(%r15), %eax
movl %eax, 0x30(%rbx)
pushq $0x1
popq %rax
movl %eax, 0x8(%rbx)
xorl %eax, %eax
cmpl $0x1, 0x38(%r15)
movl $0x0, %ecx
jne 0xb3457
movl 0x6c(%r15), %ecx
movl %ecx, 0x34(%rbx)
pushq $0x1
popq %rcx
movl %ecx, 0xc(%rbx)
cmpl $0x1, 0x3c(%r15)
jne 0xb346b
movl 0x70(%r15), %eax
movl %eax, 0x38(%rbx)
pushq $0x1
popq %rax
movl %eax, 0x10(%rbx)
xorl %eax, %eax
cmpl $0x1, 0x40(%r15)
movl $0x0, %ecx
jne 0xb3486
movl 0x74(%r15), %ecx
movl %ecx, 0x3c(%rbx)
pushq $0x1
popq %rcx
movl %ecx, 0x14(%rbx)
cmpl $0x1, 0x44(%r15)
jne 0xb349a
movl 0x78(%r15), %eax
movl %eax, 0x40(%rbx)
pushq $0x1
popq %rax
movl %eax, 0x18(%rbx)
xorl %eax, %eax
cmpl $0x1, 0x4c(%r15)
movl $0x0, %ecx
jne 0xb34b8
movl 0x80(%r15), %ecx
movl %ecx, 0x44(%rbx)
pushq $0x1
popq %rcx
movl %ecx, 0x1c(%rbx)
cmpl $0x1, 0x50(%r15)
jne 0xb34cf
movl 0x84(%r15), %eax
movl %eax, 0x48(%rbx)
pushq $0x1
popq %rax
movl %eax, 0x20(%rbx)
xorl %eax, %eax
cmpl $0x1, 0x58(%r15)
movl $0x0, %ecx
jne 0xb34ed
movl 0x8c(%r15), %ecx
movl %ecx, 0x4c(%rbx)
pushq $0x1
popq %rcx
movl %ecx, 0x24(%rbx)
cmpl $0x1, 0x5c(%r15)
jne 0xb3504
movl 0x90(%r15), %eax
movl %eax, 0x50(%rbx)
pushq $0x1
popq %rax
pushq $0x1
popq %r13
movl %eax, 0x28(%rbx)
movslq 0x9c(%r15), %rcx
movq %rcx, 0x8(%rsp)
movl %ecx, 0x54(%rbx)
movl 0xc8(%r15), %ecx
movl %ecx, 0x58(%rbx)
subl 0x8e0(%rdi), %ecx
movl %ecx, 0x5c(%rbx)
movslq 0xa8(%r15), %rax
cvtsi2sd %ecx, %xmm0
xorl %ecx, %ecx
testl %eax, %eax
movl $0x0, %r14d
cmovgl %eax, %r14d
cmpq %rcx, %r14
je 0xb3561
movq 0xb0(%r15), %rdx
ucomisd (%rdx,%rcx,8), %xmm0
jb 0xb355e
incq %rcx
jmp 0xb3546
movl %ecx, %r14d
xorl %r12d, %r12d
cmpq %rax, %rcx
setl %r12b
leal (%r14,%r12), %eax
leal (%r14,%r12), %ebp
incl %ebp
movl %ebp, 0x60(%rbx)
leaq 0x8(,%rax,8), %rdi
callq 0x8490
movq %rax, 0x70(%rbx)
testq %rax, %rax
je 0xb36ab
movq 0xb0(%r15), %rcx
leal (%r14,%r12), %edx
incl %edx
xorl %esi, %esi
cmpq %rsi, %rdx
je 0xb35b5
movsd (%rcx,%rsi,8), %xmm0
movsd %xmm0, (%rax,%rsi,8)
incq %rsi
jmp 0xb35a1
imull 0x8(%rsp), %ebp
movslq %ebp, %r14
shlq $0x3, %r14
movq %r14, %rdi
callq 0x8490
movq %rax, 0x78(%rbx)
testq %rax, %rax
je 0xb36ef
movq %r14, %rdi
callq 0x8490
movq %rax, 0x80(%rbx)
testq %rax, %rax
je 0xb3733
movslq 0x10(%r15), %rbp
movq %rbp, %r14
shlq $0x3, %r14
movq %r14, %rdi
callq 0x8490
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0xb3777
movq %r14, %rdi
callq 0x8490
movq %rax, (%rsp)
testq %rax, %rax
je 0xb37bd
movq 0x8(%rsp), %rax
leaq (,%rax,8), %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
testl %ebp, %ebp
movl $0x0, %r12d
cmovgl %ebp, %r12d
cmpq %r13, %r12
je 0xb3803
cmpl $0x2, %ebp
jl 0xb366e
movq 0x18(%rsp), %rdi
callq 0x8490
movq (%rsp), %rcx
movq %rax, (%rcx,%r13,8)
testq %rax, %rax
je 0xb397f
movq 0x18(%r15), %rax
cmpl $0x2, (%rax,%r13,4)
jl 0xb36a6
movq 0x20(%r15), %rax
movslq (%rax,%r13,4), %r14
imulq 0x8(%rsp), %r14
leaq (,%r14,8), %rdi
callq 0x8490
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%r13,8)
testq %rax, %rax
je 0xb39c6
incq %r13
jmp 0xb3645
shll $0x3, %ebp
leaq 0x3194f(%rip), %rsi     # 0xe5004
leaq 0x691cc(%rip), %rdx     # 0x11c888
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x92, %rbx
leaq 0x31959(%rip), %rsi     # 0xe5034
leaq 0x691ad(%rip), %rdx     # 0x11c88f
movq %rbx, %rdi
movl $0x3b8, %ecx            # imm = 0x3B8
jmp 0xb3a59
shll $0x3, %ebp
leaq 0x3190b(%rip), %rsi     # 0xe5004
leaq 0x6919f(%rip), %rdx     # 0x11c89f
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x92, %rbx
leaq 0x31915(%rip), %rsi     # 0xe5034
leaq 0x69169(%rip), %rdx     # 0x11c88f
movq %rbx, %rdi
movl $0x3c4, %ecx            # imm = 0x3C4
jmp 0xb3a59
shll $0x3, %ebp
leaq 0x318c7(%rip), %rsi     # 0xe5004
leaq 0x69168(%rip), %rdx     # 0x11c8ac
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x92, %rbx
leaq 0x318d1(%rip), %rsi     # 0xe5034
leaq 0x69125(%rip), %rdx     # 0x11c88f
movq %rbx, %rdi
movl $0x3c8, %ecx            # imm = 0x3C8
jmp 0xb3a59
leal (,%rbp,8), %ecx
leaq 0x3187f(%rip), %rsi     # 0xe5004
leaq 0x68f7a(%rip), %rdx     # 0x11c706
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x92, %rbx
leaq 0x3188b(%rip), %rsi     # 0xe5034
leaq 0x690df(%rip), %rdx     # 0x11c88f
movq %rbx, %rdi
movl $0x3ce, %ecx            # imm = 0x3CE
jmp 0xb3a59
leal (,%rbp,8), %ecx
leaq 0x31839(%rip), %rsi     # 0xe5004
leaq 0x68f3d(%rip), %rdx     # 0x11c70f
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x92, %rbx
leaq 0x31845(%rip), %rsi     # 0xe5034
leaq 0x69099(%rip), %rdx     # 0x11c88f
movq %rbx, %rdi
movl $0x3d2, %ecx            # imm = 0x3D2
jmp 0xb3a59
xorl %r14d, %r14d
pushq $0x1
popq %r13
movq 0x10(%rsp), %rbp
movslq 0x60(%rbx), %rax
cmpq %rax, %r14
jge 0xb3895
movq 0x70(%rbx), %rax
movsd (%rax,%r14,8), %xmm0
movslq 0x54(%rbx), %rax
movslq %r14d, %rsi
imulq %rax, %rsi
shlq $0x3, %rsi
addq 0x78(%rbx), %rsi
movq %r15, %rdi
movq (%rsp), %rdx
movq %rbp, %rcx
callq 0xac730
incq %r14
cmpl $0x1, %eax
jne 0xb380f
addq $0xea, %r15
leaq 0x31b96(%rip), %rsi     # 0xe53f0
leaq 0x6905a(%rip), %rdx     # 0x11c8bb
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x92, %rbx
leaq 0x317b3(%rip), %rsi     # 0xe5034
leaq 0x69007(%rip), %rdx     # 0x11c88f
movq %rbx, %rdi
movl $0x3e7, %ecx            # imm = 0x3E7
jmp 0xb3a59
xorl %r12d, %r12d
movslq 0x10(%r15), %r14
cmpq %r14, %r12
jge 0xb38ce
cmpl $0x2, %r14d
jl 0xb38b4
movq (%rsp), %rax
movq (%rax,%r12,8), %rdi
callq 0x8430
movq 0x18(%r15), %rax
cmpl $0x2, (%rax,%r12,4)
jl 0xb38c9
movq (%rbp,%r12,8), %rdi
callq 0x8430
incq %r12
jmp 0xb3898
movq %rbp, %rdi
callq 0x8430
movq (%rsp), %rdi
callq 0x8430
movslq 0x54(%rbx), %r12
movq %r12, %rdi
shlq $0x3, %rdi
callq 0x8490
movq %rax, 0x68(%rbx)
testq %rax, %rax
je 0xb3a17
xorl %r13d, %r13d
testl %r12d, %r12d
movl $0x0, %ecx
cmovgl %r12d, %ecx
testl %r14d, %r14d
movl $0x0, %edx
cmovgl %r14d, %edx
xorl %esi, %esi
cmpq %rcx, %rsi
je 0xb3a63
andl $0x0, (%rax,%rsi,4)
xorl %r9d, %r9d
xorl %edi, %edi
cmpq %rdi, %rdx
je 0xb397a
movq 0xb8(%r15), %r8
movq (%r8,%rdi,8), %r10
movl (%r10,%rsi,4), %r8d
cmpl %r8d, %r9d
cmovgl %r9d, %r8d
movl %r8d, (%rax,%rsi,4)
cmpl $0x1, 0x10(%rbx)
jne 0xb3972
cmpl $0x1, 0x8(%rbx)
jne 0xb3972
movl 0x38(%rbx), %r9d
cmpq %r9, %rsi
jne 0xb3972
movslq 0x30(%rbx), %r9
movl (%r10,%r9,4), %r9d
cmpl %r9d, %r8d
cmovlel %r9d, %r8d
movl %r8d, (%rax,%rsi,4)
incq %rdi
movl %r8d, %r9d
jmp 0xb392b
incq %rsi
jmp 0xb3919
movq 0x8(%rsp), %rcx
shll $0x3, %ecx
leaq 0x31676(%rip), %rsi     # 0xe5004
leaq 0x68d80(%rip), %rdx     # 0x11c715
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x92, %rbx
leaq 0x31682(%rip), %rsi     # 0xe5034
leaq 0x68ed6(%rip), %rdx     # 0x11c88f
movq %rbx, %rdi
movl $0x3da, %ecx            # imm = 0x3DA
movq %r14, %r8
jmp 0xb3a0a
shll $0x3, %r14d
leaq 0x31633(%rip), %rsi     # 0xe5004
leaq 0x68d4d(%rip), %rdx     # 0x11c725
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x92, %rbx
leaq 0x3163c(%rip), %rsi     # 0xe5034
leaq 0x68e90(%rip), %rdx     # 0x11c88f
movq %rbx, %rdi
movl $0x3e0, %ecx            # imm = 0x3E0
movq %r15, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %r13
jmp 0xb3a63
leal (,%r12,8), %ecx
leaq 0x315de(%rip), %rsi     # 0xe5004
leaq 0x68ee9(%rip), %rdx     # 0x11c916
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x92, %rbx
leaq 0x315ea(%rip), %rsi     # 0xe5034
leaq 0x68e3e(%rip), %rdx     # 0x11c88f
movq %rbx, %rdi
movl $0x3ff, %ecx            # imm = 0x3FF
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
movl %r13d, %eax
addq $0x828, %rsp            # imm = 0x828
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq