// File: /workspace/github_c_makefile_star2_O3/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
xorl %eax, %eax
cmpl $0x1, 0x30(%rsi)
movl $0x0, %ecx
jne 0xb8f44
movl 0x64(%r14), %ecx
movl %ecx, 0x2c(%rbx)
movl $0x1, %ecx
movl %ecx, 0x4(%rbx)
cmpl $0x1, 0x34(%r14)
jne 0xb8f5a
movl 0x68(%r14), %eax
movl %eax, 0x30(%rbx)
movl $0x1, %eax
movl %eax, 0x8(%rbx)
xorl %eax, %eax
cmpl $0x1, 0x38(%r14)
movl $0x0, %ecx
jne 0xb8f77
movl 0x6c(%r14), %ecx
movl %ecx, 0x34(%rbx)
movl $0x1, %ecx
movl %ecx, 0xc(%rbx)
cmpl $0x1, 0x3c(%r14)
jne 0xb8f8d
movl 0x70(%r14), %eax
movl %eax, 0x38(%rbx)
movl $0x1, %eax
movl %eax, 0x10(%rbx)
xorl %eax, %eax
cmpl $0x1, 0x40(%r14)
movl $0x0, %ecx
jne 0xb8faa
movl 0x74(%r14), %ecx
movl %ecx, 0x3c(%rbx)
movl $0x1, %ecx
movl %ecx, 0x14(%rbx)
cmpl $0x1, 0x44(%r14)
jne 0xb8fc0
movl 0x78(%r14), %eax
movl %eax, 0x40(%rbx)
movl $0x1, %eax
movl %eax, 0x18(%rbx)
xorl %eax, %eax
cmpl $0x1, 0x4c(%r14)
movl $0x0, %ecx
jne 0xb8fe0
movl 0x80(%r14), %ecx
movl %ecx, 0x44(%rbx)
movl $0x1, %ecx
movl %ecx, 0x1c(%rbx)
cmpl $0x1, 0x50(%r14)
jne 0xb8ff9
movl 0x84(%r14), %eax
movl %eax, 0x48(%rbx)
movl $0x1, %eax
movl %eax, 0x20(%rbx)
xorl %eax, %eax
cmpl $0x1, 0x58(%r14)
movl $0x0, %ecx
jne 0xb9019
movl 0x8c(%r14), %ecx
movl %ecx, 0x4c(%rbx)
movl $0x1, %ecx
movl %ecx, 0x24(%rbx)
cmpl $0x1, 0x5c(%r14)
jne 0xb9032
movl 0x90(%r14), %eax
movl %eax, 0x50(%rbx)
movl $0x1, %eax
movl %eax, 0x28(%rbx)
movslq 0x9c(%r14), %r15
movl %r15d, 0x54(%rbx)
movl 0xc8(%r14), %ecx
movl %ecx, 0x58(%rbx)
subl 0x8e0(%rdi), %ecx
movl %ecx, 0x5c(%rbx)
movl 0xa8(%r14), %eax
testl %eax, %eax
jle 0xb9075
cvtsi2sd %ecx, %xmm0
movq 0xb0(%r14), %rdx
ucomisd (%rdx), %xmm0
jae 0xb907c
movb $0x1, %dl
xorl %ecx, %ecx
jmp 0xb90ab
movl $0x1, %eax
jmp 0xb90b2
movq %rax, %rdi
decq %rdi
xorl %esi, %esi
cmpq %rsi, %rdi
je 0xb90a0
leaq 0x1(%rsi), %rcx
ucomisd 0x8(%rdx,%rsi,8), %xmm0
movq %rcx, %rsi
jae 0xb9084
cmpq %rax, %rcx
setb %dl
jmp 0xb90ab
incq %rsi
cmpq %rax, %rsi
setb %dl
movl %eax, %ecx
movzbl %dl, %eax
addl %ecx, %eax
incl %eax
movl %eax, 0x60(%rbx)
movl %eax, %ebp
leaq (,%rbp,8), %rdi
callq 0x8460
movq %rax, 0x70(%rbx)
testq %rax, %rax
je 0xb9317
movq 0xb0(%r14), %rcx
xorl %edx, %edx
movsd (%rcx,%rdx,8), %xmm0
movsd %xmm0, (%rax,%rdx,8)
incq %rdx
cmpq %rdx, %rbp
jne 0xb90da
movl %r15d, %r12d
imull %ebp, %r12d
movslq %r12d, %r13
shlq $0x3, %r13
movq %r13, %rdi
callq 0x8460
movq %rax, 0x78(%rbx)
testq %rax, %rax
je 0xb935b
movq %r13, %rdi
callq 0x8460
movq %rax, 0x80(%rbx)
testq %rax, %rax
je 0xb93a1
movslq 0x10(%r14), %r12
leaq (,%r12,8), %r13
movq %r13, %rdi
callq 0x8460
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0xb93e7
movq %r13, %rdi
callq 0x8460
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0xb942e
movq %r15, (%rsp)
testl %r12d, %r12d
jle 0xb91dd
movq (%rsp), %rax
leaq (,%rax,8), %rax
movq %rax, 0x18(%rsp)
xorl %r15d, %r15d
cmpl $0x1, %r12d
je 0xb919e
movq 0x18(%rsp), %rdi
callq 0x8460
movq 0x8(%rsp), %rcx
movq %rax, (%rcx,%r15,8)
testq %rax, %rax
je 0xb9507
movq 0x18(%r14), %rax
cmpl $0x2, (%rax,%r15,4)
jl 0xb91d5
movq 0x20(%r14), %rax
movslq (%rax,%r15,4), %r13
imulq (%rsp), %r13
leaq (,%r13,8), %rdi
callq 0x8460
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%r15,8)
testq %rax, %rax
je 0xb954a
incq %r15
cmpq %r15, %r12
jne 0xb917c
testl %ebp, %ebp
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %rbp
jle 0xb9232
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 %rbp, %rdx
movq %r13, %rcx
callq 0xb2958
cmpl $0x1, %eax
je 0xb9475
incq %r15
movslq 0x60(%rbx), %rax
cmpq %rax, %r15
jl 0xb91ee
movl 0x10(%r14), %r12d
testl %r12d, %r12d
jle 0xb926b
xorl %r15d, %r15d
cmpl $0x2, %r12d
jl 0xb924a
movq (%rbp,%r15,8), %rdi
callq 0x8410
movq 0x18(%r14), %rax
cmpl $0x2, (%rax,%r15,4)
jl 0xb925f
movq (%r13,%r15,8), %rdi
callq 0x8410
incq %r15
movslq 0x10(%r14), %r12
cmpq %r12, %r15
jl 0xb923a
movq %r13, %rdi
callq 0x8410
movq %rbp, %rdi
callq 0x8410
movslq 0x54(%rbx), %r15
leaq (,%r15,8), %rdi
callq 0x8460
movq %rax, 0x68(%rbx)
testq %rax, %rax
je 0xb94c1
testl %r15d, %r15d
jle 0xb95ae
movl %r12d, %edx
xorl %esi, %esi
movl $0x0, (%rax,%rsi,4)
testl %r12d, %r12d
jle 0xb9308
movq 0xb8(%r14), %rcx
movl 0x10(%rbx), %edi
xorl %r8d, %r8d
xorl %r9d, %r9d
movl %r9d, %r11d
movq (%rcx,%r8,8), %r10
movl (%r10,%rsi,4), %r9d
cmpl %r9d, %r11d
cmovgl %r11d, %r9d
movl %r9d, (%rax,%rsi,4)
cmpl $0x1, %edi
jne 0xb9300
cmpl $0x1, 0x8(%rbx)
jne 0xb9300
movl 0x38(%rbx), %r11d
cmpq %r11, %rsi
jne 0xb9300
movslq 0x30(%rbx), %r11
movl (%r10,%r11,4), %r10d
cmpl %r10d, %r9d
cmovlel %r10d, %r9d
movl %r9d, (%rax,%rsi,4)
incq %r8
cmpq %r8, %rdx
jne 0xb92c3
incq %rsi
xorl %ecx, %ecx
cmpq %r15, %rsi
jne 0xb92a7
jmp 0xb959a
shll $0x3, %ebp
leaq 0x34ce3(%rip), %rsi     # 0xee004
leaq 0x6c6c0(%rip), %rdx     # 0x1259e8
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x92, %rbx
leaq 0x34ced(%rip), %rsi     # 0xee034
leaq 0x6c6a1(%rip), %rdx     # 0x1259ef
movq %rbx, %rdi
movl $0x3b8, %ecx            # imm = 0x3B8
jmp 0xb958b
shll $0x3, %r12d
leaq 0x34c9e(%rip), %rsi     # 0xee004
leaq 0x6c692(%rip), %rdx     # 0x1259ff
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x92, %rbx
leaq 0x34ca7(%rip), %rsi     # 0xee034
leaq 0x6c65b(%rip), %rdx     # 0x1259ef
movq %rbx, %rdi
movl $0x3c4, %ecx            # imm = 0x3C4
jmp 0xb958b
shll $0x3, %r12d
leaq 0x34c58(%rip), %rsi     # 0xee004
leaq 0x6c659(%rip), %rdx     # 0x125a0c
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x92, %rbx
leaq 0x34c61(%rip), %rsi     # 0xee034
leaq 0x6c615(%rip), %rdx     # 0x1259ef
movq %rbx, %rdi
movl $0x3c8, %ecx            # imm = 0x3C8
jmp 0xb958b
leal (,%r12,8), %ecx
leaq 0x34c0e(%rip), %rsi     # 0xee004
leaq 0x6c469(%rip), %rdx     # 0x125866
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x92, %rbx
leaq 0x34c1a(%rip), %rsi     # 0xee034
leaq 0x6c5ce(%rip), %rdx     # 0x1259ef
movq %rbx, %rdi
movl $0x3ce, %ecx            # imm = 0x3CE
jmp 0xb958b
leal (,%r12,8), %ecx
leaq 0x34bc7(%rip), %rsi     # 0xee004
leaq 0x6c42b(%rip), %rdx     # 0x12586f
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x92, %rbx
leaq 0x34bd3(%rip), %rsi     # 0xee034
leaq 0x6c587(%rip), %rdx     # 0x1259ef
movq %rbx, %rdi
movl $0x3d2, %ecx            # imm = 0x3D2
jmp 0xb958b
addq $0xea, %r14
leaq 0x34f6d(%rip), %rsi     # 0xee3f0
leaq 0x6c591(%rip), %rdx     # 0x125a1b
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x92, %rbx
leaq 0x34b8a(%rip), %rsi     # 0xee034
leaq 0x6c53e(%rip), %rdx     # 0x1259ef
movq %rbx, %rdi
movl $0x3e7, %ecx            # imm = 0x3E7
movq %r15, %r8
jmp 0xb958e
shll $0x3, %r15d
leaq 0x34b38(%rip), %rsi     # 0xee004
leaq 0x6c5a3(%rip), %rdx     # 0x125a76
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x92, %rbx
leaq 0x34b41(%rip), %rsi     # 0xee034
leaq 0x6c4f5(%rip), %rdx     # 0x1259ef
movq %rbx, %rdi
movl $0x3ff, %ecx            # imm = 0x3FF
jmp 0xb958b
movq (%rsp), %rcx
shll $0x3, %ecx
leaq 0x34aef(%rip), %rsi     # 0xee004
leaq 0x6c359(%rip), %rdx     # 0x125875
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x92, %rbx
leaq 0x34afb(%rip), %rsi     # 0xee034
leaq 0x6c4af(%rip), %rdx     # 0x1259ef
movq %rbx, %rdi
movl $0x3da, %ecx            # imm = 0x3DA
jmp 0xb958b
shll $0x3, %r13d
leaq 0x34aaf(%rip), %rsi     # 0xee004
leaq 0x6c329(%rip), %rdx     # 0x125885
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x92, %rbx
leaq 0x34ab8(%rip), %rsi     # 0xee034
leaq 0x6c46c(%rip), %rdx     # 0x1259ef
movq %rbx, %rdi
movl $0x3e0, %ecx            # imm = 0x3E0
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
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 0xb959a