// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../source/transfer.c
// Function: transfer_get_l_list
int transfer_get_l_list(
                        struct precision * ppr,
                        struct perturbations * ppt,
                        struct transfer * ptr
                        ) {

  int index_l;
  int l_max=0;
  int index_md;
  int index_tt;
  int increment,current_l;
  /** Summary: */
  /*
    fprintf(stderr,"rescaling %e logstep %e linstep %e\n",
    ptr->angular_rescaling,
    pow(ppr->l_logstep,ptr->angular_rescaling),
    ppr->l_linstep*ptr->angular_rescaling);
  */

  /* check that largests need value of l_max */

  if (ppt->has_cls == _TRUE_) {

    if (ppt->has_scalars == _TRUE_) {

      if ((ppt->has_cl_cmb_temperature == _TRUE_) ||
          (ppt->has_cl_cmb_polarization == _TRUE_) ||
          (ppt->has_cl_cmb_lensing_potential == _TRUE_))
        l_max=MAX(ppt->l_scalar_max,l_max);

      if ((ppt->has_cl_lensing_potential == _TRUE_) ||
          (ppt->has_cl_number_count == _TRUE_))
        l_max=MAX(ppt->l_lss_max,l_max);
    }

    if (ppt->has_tensors == _TRUE_)
      l_max=MAX(ppt->l_tensor_max,l_max);

  }

  /** - allocate and fill l array */

  /** - start from l = 2 and increase with logarithmic step */

  index_l = 0;
  current_l = 2;
  increment = MAX((int)(current_l * (pow(ppr->l_logstep,ptr->angular_rescaling)-1.)),1);

  while (((current_l+increment) < l_max) &&
         (increment < ppr->l_linstep*ptr->angular_rescaling)) {

    index_l ++;
    current_l += increment;
    increment = MAX((int)(current_l * (pow(ppr->l_logstep,ptr->angular_rescaling)-1.)),1);

  }

  /** - when the logarithmic step becomes larger than some linear step,
      stick to this linear step till l_max */

  increment = ppr->l_linstep*ptr->angular_rescaling;

  while ((current_l+increment) <= l_max) {

    index_l ++;
    current_l += increment;

  }

  /** - last value set to exactly l_max */

  if (current_l != l_max) {

    index_l ++;
    current_l = l_max;

  }

  ptr->l_size_max = index_l+1;

  /** - so far we just counted the number of values. Now repeat the
      whole thing but fill array with values. */

  class_alloc(ptr->l,ptr->l_size_max*sizeof(int),ptr->error_message);

  index_l = 0;
  ptr->l[0] = 2;
  increment = MAX((int)(ptr->l[0] * (pow(ppr->l_logstep,ptr->angular_rescaling)-1.)),1);

  while (((ptr->l[index_l]+increment) < l_max) &&
         (increment < ppr->l_linstep*ptr->angular_rescaling)) {

    index_l ++;
    ptr->l[index_l]=ptr->l[index_l-1]+increment;
    increment = MAX((int)(ptr->l[index_l] * (pow(ppr->l_logstep,ptr->angular_rescaling)-1.)),1);

  }

  increment = ppr->l_linstep*ptr->angular_rescaling;

  while ((ptr->l[index_l]+increment) <= l_max) {

    index_l ++;
    ptr->l[index_l]=ptr->l[index_l-1]+increment;

  }

  if (ptr->l[index_l] != l_max) {

    index_l ++;
    ptr->l[index_l]= l_max;

  }

  /* for each mode and type, find relevant size of l array,
     l_size_tt[index_md][index_tt] (since for some modes and types
     l_max can be smaller). Also, maximize this size for each mode to
     find l_size[index_md]. */

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

    ptr->l_size[index_md] = 0;

    for (index_tt=0;index_tt<ptr->tt_size[index_md];index_tt++) {

      if (_scalars_) {

        if ((ppt->has_cl_cmb_temperature == _TRUE_) &&
            ((index_tt == ptr->index_tt_t0) || (index_tt == ptr->index_tt_t1) || (index_tt == ptr->index_tt_t2)))
          l_max=ppt->l_scalar_max;

        if ((ppt->has_cl_cmb_polarization == _TRUE_) && (index_tt == ptr->index_tt_e))
          l_max=ppt->l_scalar_max;

        if ((ppt->has_cl_cmb_lensing_potential == _TRUE_) && (index_tt == ptr->index_tt_lcmb))
          l_max=ppt->l_scalar_max;

        if ((_index_tt_in_range_(ptr->index_tt_density, ppt->selection_num, ppt->has_nc_density)) ||
            (_index_tt_in_range_(ptr->index_tt_rsd,     ppt->selection_num, ppt->has_nc_rsd)) ||
            (_index_tt_in_range_(ptr->index_tt_d0,      ppt->selection_num, ppt->has_nc_rsd)) ||
            (_index_tt_in_range_(ptr->index_tt_d1,      ppt->selection_num, ppt->has_nc_rsd)) ||
            (_index_tt_in_range_(ptr->index_tt_nc_lens, ppt->selection_num, ppt->has_nc_lens))||
            (_index_tt_in_range_(ptr->index_tt_nc_g1,   ppt->selection_num, ppt->has_nc_gr))  ||
            (_index_tt_in_range_(ptr->index_tt_nc_g2,   ppt->selection_num, ppt->has_nc_gr))  ||
            (_index_tt_in_range_(ptr->index_tt_nc_g3,   ppt->selection_num, ppt->has_nc_gr))  ||
            (_index_tt_in_range_(ptr->index_tt_nc_g4,   ppt->selection_num, ppt->has_nc_gr))  ||
            (_index_tt_in_range_(ptr->index_tt_nc_g5,   ppt->selection_num, ppt->has_nc_gr))
            )
          l_max=ppt->l_lss_max;

        if ((ppt->has_cl_lensing_potential == _TRUE_) && (index_tt >= ptr->index_tt_lensing) && (index_tt < ptr->index_tt_lensing+ppt->selection_num))
          l_max=ppt->l_lss_max;

      }

      if (_tensors_) {
        l_max = ppt->l_tensor_max;
      }

      class_test(l_max > ptr->l[ptr->l_size_max-1],
                 ptr->error_message,
                 "For mode %d, type %d, asked for l_max=%d greater than in Bessel table where l_max=%d",
                 index_md,
                 index_tt,
                 l_max,
                 ptr->l[ptr->l_size_max-1]);

      index_l=0;
      while (ptr->l[index_l] < l_max) index_l++;
      ptr->l_size_tt[index_md][index_tt]=index_l+1;

      if (ptr->l_size_tt[index_md][index_tt] < ptr->l_size_max)
        ptr->l_size_tt[index_md][index_tt]++;
      if (ptr->l_size_tt[index_md][index_tt] < ptr->l_size_max)
        ptr->l_size_tt[index_md][index_tt]++;

      ptr->l_size[index_md] = MAX(ptr->l_size[index_md],ptr->l_size_tt[index_md][index_tt]);

    }
  }

  return _SUCCESS_;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1018, %rsp           # imm = 0x1018
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
xorl %r15d, %r15d
cmpw $0x1, 0xc(%rsi)
jne 0xa9ba4
xorl %r15d, %r15d
cmpw $0x1, 0xe(%r14)
jne 0xa9b91
cmpw $0x1, 0x28(%r14)
je 0xa9b69
cmpw $0x1, 0x2a(%r14)
je 0xa9b69
xorl %r15d, %r15d
cmpw $0x1, 0x2c(%r14)
jne 0xa9b76
movl 0x48(%r14), %eax
xorl %r15d, %r15d
testl %eax, %eax
cmovgl %eax, %r15d
cmpw $0x1, 0x2e(%r14)
je 0xa9b86
cmpw $0x1, 0x30(%r14)
jne 0xa9b91
movl 0x54(%r14), %eax
cmpl %r15d, %eax
cmovgl %eax, %r15d
cmpw $0x1, 0x12(%r14)
jne 0xa9ba4
movl 0x50(%r14), %eax
cmpl %r15d, %eax
cmovgl %eax, %r15d
movsd 0x710(%r12), %xmm0
movsd 0x918(%rbx), %xmm1
callq 0x8620
addsd 0x44c25(%rip), %xmm0    # 0xee7e8
addsd %xmm0, %xmm0
cvttsd2si %xmm0, %eax
testl %eax, %eax
jle 0xa9bf8
movsd 0x710(%r12), %xmm0
movsd 0x918(%rbx), %xmm1
callq 0x8620
addsd 0x44bfa(%rip), %xmm0    # 0xee7e8
addsd %xmm0, %xmm0
cvttsd2si %xmm0, %ecx
jmp 0xa9bfd
movl $0x1, %ecx
leal 0x2(%rcx), %eax
movl $0x2, %ebp
xorl %r13d, %r13d
cmpl %r15d, %eax
jge 0xa9ce0
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
cvtsi2sdl 0x708(%r12), %xmm2
movsd 0x918(%rbx), %xmm1
mulsd %xmm1, %xmm2
ucomisd %xmm0, %xmm2
jbe 0xa9ce0
movl $0x1, %ecx
movl %eax, %ebp
movl %ecx, %r13d
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x710(%r12), %xmm0
callq 0x8620
movsd 0x44b82(%rip), %xmm1    # 0xee7e8
addsd %xmm1, %xmm0
mulsd 0x8(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl $0x1, %ecx
testl %eax, %eax
jle 0xa9caa
movsd 0x710(%r12), %xmm0
movsd 0x918(%rbx), %xmm1
callq 0x8620
movsd 0x44b4c(%rip), %xmm1    # 0xee7e8
addsd %xmm1, %xmm0
mulsd 0x8(%rsp), %xmm0
cvttsd2si %xmm0, %ecx
leal (%rcx,%rbp), %eax
cmpl %r15d, %eax
jge 0xa9ce0
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
xorps %xmm2, %xmm2
cvtsi2sdl 0x708(%r12), %xmm2
movsd 0x918(%rbx), %xmm1
mulsd %xmm1, %xmm2
leal 0x1(%r13), %ecx
ucomisd %xmm0, %xmm2
ja 0xa9c3d
xorps %xmm0, %xmm0
cvtsi2sdl 0x708(%r12), %xmm0
movsd 0x918(%rbx), %xmm1
movsd %xmm1, 0x8(%rsp)
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
leal (%rcx,%rbp), %edx
leal 0x1(%r15), %eax
xorl %esi, %esi
cmpl %eax, %edx
cmovgl %edx, %eax
setl %sil
addl %esi, %edx
subl %edx, %eax
cmpl $0x1, %ecx
movl %ecx, %edi
adcl $0x0, %edi
xorl %edx, %edx
divl %edi
leal (%rax,%rsi), %edx
imull %ecx, %edx
addl %esi, %r13d
addl %eax, %r13d
addl %ebp, %edx
xorl %eax, %eax
cmpl %r15d, %edx
setne %al
movl %r13d, %ecx
addl %eax, %ecx
leal (%rax,%r13), %ebp
incl %ebp
movl %ebp, 0x908(%rbx)
leaq 0x4(,%rcx,4), %rdi
callq 0x8460
movq %rax, 0x910(%rbx)
testq %rax, %rax
je 0xa9dd7
movl $0x2, (%rax)
movsd 0x710(%r12), %xmm0
movsd 0x8(%rsp), %xmm1
callq 0x8620
addsd 0x44a60(%rip), %xmm0    # 0xee7e8
addsd %xmm0, %xmm0
cvttsd2si %xmm0, %eax
testl %eax, %eax
jle 0xa9e1e
movq 0x910(%rbx), %rax
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x710(%r12), %xmm0
movsd 0x918(%rbx), %xmm1
callq 0x8620
addsd 0x44a1d(%rip), %xmm0    # 0xee7e8
mulsd 0x8(%rsp), %xmm0
cvttsd2si %xmm0, %edx
jmp 0xa9e23
shll $0x2, %ebp
leaq 0x44223(%rip), %rsi     # 0xee004
leaq 0x74fb6(%rip), %rdx     # 0x11ed9e
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4422d(%rip), %rsi     # 0xee034
leaq 0x74f97(%rip), %rdx     # 0x11eda5
movq %rbx, %rdi
movl $0x395, %ecx            # imm = 0x395
movq %r14, %r8
jmp 0xaa246
movl $0x1, %edx
movq 0x910(%rbx), %rax
movl (%rax), %ecx
leal (%rcx,%rdx), %esi
cmpl %r15d, %esi
jge 0xa9f0d
xorl %r13d, %r13d
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
xorps %xmm2, %xmm2
cvtsi2sdl 0x708(%r12), %xmm2
movsd 0x918(%rbx), %xmm1
mulsd %xmm1, %xmm2
ucomisd %xmm0, %xmm2
jbe 0xa9f05
movl %esi, 0x4(%rax,%r13,4)
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x710(%r12), %xmm0
callq 0x8620
movsd 0x4495a(%rip), %xmm1    # 0xee7e8
addsd %xmm1, %xmm0
mulsd 0x8(%rsp), %xmm0
cvttsd2si %xmm0, %eax
testl %eax, %eax
jle 0xa9ee6
movq 0x910(%rbx), %rax
xorps %xmm0, %xmm0
cvtsi2sdl 0x4(%rax,%r13,4), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x710(%r12), %xmm0
movsd 0x918(%rbx), %xmm1
callq 0x8620
movsd 0x44912(%rip), %xmm1    # 0xee7e8
addsd %xmm1, %xmm0
mulsd 0x8(%rsp), %xmm0
cvttsd2si %xmm0, %edx
jmp 0xa9eeb
movl $0x1, %edx
movq 0x910(%rbx), %rax
movl 0x4(%rax,%r13,4), %esi
addl %edx, %esi
incq %r13
cmpl %r15d, %esi
jl 0xa9e3b
movl %r13d, %edx
movl (%rax,%rdx,4), %ecx
jmp 0xa9f0f
xorl %edx, %edx
xorps %xmm0, %xmm0
cvtsi2sdl 0x708(%r12), %xmm0
mulsd 0x918(%rbx), %xmm0
cvttsd2si %xmm0, %esi
leal (%rcx,%rsi), %edi
cmpl %r15d, %edi
jg 0xa9f3e
addl %esi, %ecx
movl %ecx, 0x4(%rax,%rdx,4)
incq %rdx
leal (%rsi,%rcx), %edi
jmp 0xa9f2b
cmpl %r15d, %ecx
je 0xa9f48
movl %r15d, 0x4(%rax,%rdx,4)
cmpl $0x0, 0x854(%r14)
jle 0xaa1e6
movq 0x8f0(%rbx), %rsi
movq 0x900(%rbx), %rdi
xorl %edx, %edx
movl $0x0, (%rdi,%rdx,4)
cmpl $0x0, (%rsi,%rdx,4)
jle 0xaa1d3
movzwl 0xe(%r14), %r8d
movzwl 0x12(%r14), %r10d
xorl %ecx, %ecx
cmpw $0x1, %r8w
jne 0xaa14a
movl 0x848(%r14), %r9d
cmpq %r9, %rdx
jne 0xaa14a
cmpw $0x1, 0x28(%r14)
jne 0xa9fce
movl 0x8a8(%rbx), %r9d
cmpq %r9, %rcx
je 0xa9fca
movl 0x8ac(%rbx), %r9d
cmpq %r9, %rcx
je 0xa9fca
movl 0x8b0(%rbx), %r9d
cmpq %r9, %rcx
jne 0xa9fce
movl 0x48(%r14), %r15d
cmpw $0x1, 0x2a(%r14)
jne 0xa9fe6
movl 0x8b4(%rbx), %r9d
cmpq %r9, %rcx
jne 0xa9fe6
movl 0x48(%r14), %r15d
cmpw $0x1, 0x2c(%r14)
jne 0xa9ffe
movl 0x8bc(%rbx), %r9d
cmpq %r9, %rcx
jne 0xa9ffe
movl 0x48(%r14), %r15d
cmpw $0x1, 0x3e(%r14)
jne 0xaa022
movslq 0x8c0(%rbx), %r9
cmpq %r9, %rcx
jl 0xaa022
movslq 0x64(%r14), %r11
addq %r9, %r11
cmpq %r11, %rcx
jl 0xaa122
cmpw $0x1, 0x40(%r14)
jne 0xaa07e
movslq 0x8c8(%rbx), %r9
cmpq %r9, %rcx
jl 0xaa046
movslq 0x64(%r14), %r11
addq %r9, %r11
cmpq %r11, %rcx
jl 0xaa122
movslq 0x8cc(%rbx), %r9
cmpq %r9, %rcx
jl 0xaa062
movslq 0x64(%r14), %r11
addq %r9, %r11
cmpq %r11, %rcx
jl 0xaa122
movslq 0x8d0(%rbx), %r9
cmpq %r9, %rcx
jl 0xaa07e
movslq 0x64(%r14), %r11
addq %r9, %r11
cmpq %r11, %rcx
jl 0xaa122
cmpw $0x1, 0x42(%r14)
jne 0xaa0a2
movslq 0x8d4(%rbx), %r9
cmpq %r9, %rcx
jl 0xaa0a2
movslq 0x64(%r14), %r11
addq %r9, %r11
cmpq %r11, %rcx
jl 0xaa122
cmpw $0x1, 0x44(%r14)
jne 0xaa126
movslq 0x8d8(%rbx), %r9
cmpq %r9, %rcx
jl 0xaa0c2
movslq 0x64(%r14), %r11
addq %r9, %r11
cmpq %r11, %rcx
jl 0xaa122
movslq 0x8dc(%rbx), %r9
cmpq %r9, %rcx
jl 0xaa0da
movslq 0x64(%r14), %r11
addq %r9, %r11
cmpq %r11, %rcx
jl 0xaa122
movslq 0x8e0(%rbx), %r9
cmpq %r9, %rcx
jl 0xaa0f2
movslq 0x64(%r14), %r11
addq %r9, %r11
cmpq %r11, %rcx
jl 0xaa122
movslq 0x8e4(%rbx), %r9
cmpq %r9, %rcx
jl 0xaa10a
movslq 0x64(%r14), %r11
addq %r9, %r11
cmpq %r11, %rcx
jl 0xaa122
movslq 0x8e8(%rbx), %r9
cmpq %r9, %rcx
jl 0xaa126
movslq 0x64(%r14), %r11
addq %r9, %r11
cmpq %r11, %rcx
jge 0xaa126
movl 0x54(%r14), %r15d
cmpw $0x1, 0x2e(%r14)
jne 0xaa14a
movslq 0x8c4(%rbx), %r9
cmpq %r9, %rcx
jl 0xaa14a
movslq 0x64(%r14), %r11
addq %r9, %r11
cmpq %r11, %rcx
jge 0xaa14a
movl 0x54(%r14), %r15d
cmpw $0x1, %r10w
jne 0xaa161
movl 0x84c(%r14), %r9d
cmpq %r9, %rdx
jne 0xaa161
movl 0x50(%r14), %r15d
movslq 0x908(%rbx), %r9
movl -0x4(%rax,%r9,4), %r9d
cmpl %r9d, %r15d
jg 0xaa1ea
xorl %r9d, %r9d
movq %r9, %r11
incq %r9
cmpl %r15d, (%rax,%r11,4)
jl 0xaa175
movq 0x8f8(%rbx), %r11
movq (%r11,%rdx,8), %r11
movl %r9d, (%r11,%rcx,4)
movl 0x908(%rbx), %ebp
cmpl %ebp, %r9d
jge 0xaa1a8
incl %r9d
movl %r9d, (%r11,%rcx,4)
movl 0x908(%rbx), %ebp
cmpl %ebp, %r9d
jge 0xaa1b4
incl %r9d
movl %r9d, (%r11,%rcx,4)
movl (%rdi,%rdx,4), %r11d
cmpl %r9d, %r11d
cmovgl %r11d, %r9d
movl %r9d, (%rdi,%rdx,4)
incq %rcx
movslq (%rsi,%rdx,4), %r9
cmpq %r9, %rcx
jl 0xa9f83
incq %rdx
movslq 0x854(%r14), %rcx
cmpq %rcx, %rdx
jl 0xa9f66
xorl %eax, %eax
jmp 0xaa252
leaq 0x74bc8(%rip), %rsi     # 0x11edb9
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %r15d, %r8d
xorl %eax, %eax
callq 0x30af0
leaq 0x43e78(%rip), %rsi     # 0xee082
leaq 0x74bfd(%rip), %rdx     # 0x11ee0e
leaq 0x810(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x43e00(%rip), %rsi     # 0xee034
leaq 0x74b6a(%rip), %rdx     # 0x11eda5
movq %rbx, %rdi
movl $0x3e7, %ecx            # imm = 0x3E7
movq %r15, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq