// File: /workspace/github_c_makefile_star2_O2/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 0xa4822
xorl %r15d, %r15d
cmpw $0x1, 0xe(%r14)
jne 0xa480f
cmpw $0x1, 0x28(%r14)
je 0xa47e7
cmpw $0x1, 0x2a(%r14)
je 0xa47e7
xorl %r15d, %r15d
cmpw $0x1, 0x2c(%r14)
jne 0xa47f4
movl 0x48(%r14), %eax
xorl %r15d, %r15d
testl %eax, %eax
cmovgl %eax, %r15d
cmpw $0x1, 0x2e(%r14)
je 0xa4804
cmpw $0x1, 0x30(%r14)
jne 0xa480f
movl 0x54(%r14), %eax
cmpl %r15d, %eax
cmovgl %eax, %r15d
cmpw $0x1, 0x12(%r14)
jne 0xa4822
movl 0x50(%r14), %eax
cmpl %r15d, %eax
cmovgl %eax, %r15d
movsd 0x710(%r12), %xmm0
movsd 0x918(%rbx), %xmm1
callq 0x8650
addsd 0x40fa7(%rip), %xmm0    # 0xe57e8
addsd %xmm0, %xmm0
cvttsd2si %xmm0, %ecx
pushq $0x1
popq %rax
testl %ecx, %ecx
jle 0xa4877
movsd 0x710(%r12), %xmm0
movsd 0x918(%rbx), %xmm1
callq 0x8650
addsd 0x40f79(%rip), %xmm0    # 0xe57e8
addsd %xmm0, %xmm0
cvttsd2si %xmm0, %eax
pushq $0x2
popq %rcx
pushq $0x1
popq %rbp
leal (%rcx,%rax), %r13d
movsd 0x918(%rbx), %xmm1
cvtsi2sdl 0x708(%r12), %xmm0
cmpl %r15d, %r13d
jge 0xa490c
cvtsi2sd %eax, %xmm2
mulsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jbe 0xa4910
cvtsi2sd %r13d, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x710(%r12), %xmm0
callq 0x8650
addsd 0x40f20(%rip), %xmm0    # 0xe57e8
mulsd 0x8(%rsp), %xmm0
cvttsd2si %xmm0, %ecx
pushq $0x1
popq %rax
testl %ecx, %ecx
jle 0xa4902
movsd 0x710(%r12), %xmm0
movsd 0x918(%rbx), %xmm1
callq 0x8650
addsd 0x40ef0(%rip), %xmm0    # 0xe57e8
mulsd 0x8(%rsp), %xmm0
cvttsd2si %xmm0, %eax
incl %ebp
movl %r13d, %ecx
jmp 0xa487d
mulsd %xmm1, %xmm0
movsd %xmm1, 0x8(%rsp)
cvttsd2si %xmm0, %esi
leal (%rcx,%rsi), %edx
leal 0x1(%r15), %eax
xorl %edi, %edi
cmpl %eax, %edx
cmovgl %edx, %eax
setl %dil
addl %edi, %edx
subl %edx, %eax
cmpl $0x1, %esi
movl %esi, %r8d
adcl $0x0, %r8d
xorl %edx, %edx
divl %r8d
movl %eax, %r13d
addl %edi, %r13d
imull %r13d, %esi
addl %ecx, %esi
xorl %eax, %eax
cmpl %r15d, %esi
setne %al
addl %ebp, %r13d
addl %eax, %r13d
movl %r13d, 0x908(%rbx)
leaq (,%r13,4), %rdi
callq 0x8490
movq %rax, 0x910(%rbx)
testq %rax, %rax
je 0xa49b7
movl $0x2, (%rax)
movsd 0x710(%r12), %xmm0
movsd 0x8(%rsp), %xmm1
callq 0x8650
addsd 0x40e4c(%rip), %xmm0    # 0xe57e8
addsd %xmm0, %xmm0
cvttsd2si %xmm0, %eax
pushq $0x1
popq %rcx
testl %eax, %eax
jle 0xa49fd
movq 0x910(%rbx), %rax
xorl %r13d, %r13d
jmp 0xa4a1e
shll $0x2, %r13d
leaq 0x40642(%rip), %rsi     # 0xe5004
leaq 0x71265(%rip), %rdx     # 0x115c2e
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4064b(%rip), %rsi     # 0xe5034
leaq 0x71245(%rip), %rdx     # 0x115c35
movq %rbx, %rdi
movl $0x395, %ecx            # imm = 0x395
movq %r14, %r8
jmp 0xa4a02
xorl %r13d, %r13d
jmp 0xa4a51
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x710(%r12), %xmm0
movsd 0x918(%rbx), %xmm1
callq 0x8650
addsd 0x40da1(%rip), %xmm0    # 0xe57e8
mulsd 0x8(%rsp), %xmm0
cvttsd2si %xmm0, %ecx
leaq 0x4(,%r13,4), %rbp
movq 0x910(%rbx), %rsi
movl -0x4(%rsi,%rbp), %eax
leal (%rax,%rcx), %edx
movsd 0x918(%rbx), %xmm1
cvtsi2sdl 0x708(%r12), %xmm0
cmpl %r15d, %edx
jge 0xa4adb
cvtsi2sd %ecx, %xmm2
mulsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jbe 0xa4adf
incq %r13
movl %edx, (%rsi,%rbp)
cvtsi2sd %edx, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x710(%r12), %xmm0
callq 0x8650
addsd 0x40d35(%rip), %xmm0    # 0xe57e8
mulsd 0x8(%rsp), %xmm0
cvttsd2si %xmm0, %eax
addq $0x4, %rbp
pushq $0x1
popq %rcx
testl %eax, %eax
jle 0xa4a59
movq 0x910(%rbx), %rax
addq %rbp, %rax
addq $-0x4, %rax
jmp 0xa4a1e
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
addq %rsi, %rbp
leal (%rax,%rcx), %edx
cmpl %r15d, %edx
jg 0xa4af9
movl %edx, (%rbp)
addq $0x4, %rbp
movl %edx, %eax
jmp 0xa4ae6
cmpl %eax, %r15d
je 0xa4b02
movl %r15d, (%rbp)
xorl %eax, %eax
xorl %edx, %edx
movslq 0x854(%r14), %rcx
cmpq %rcx, %rdx
jge 0xa4a0c
movq 0x900(%rbx), %rdi
andl $0x0, (%rdi,%rdx,4)
movq 0x8f0(%rbx), %r8
xorl %ecx, %ecx
movslq (%r8,%rdx,4), %r9
cmpq %r9, %rcx
jge 0xa4d83
cmpw $0x1, 0xe(%r14)
jne 0xa4cff
movl 0x848(%r14), %r9d
cmpq %r9, %rdx
jne 0xa4cff
cmpw $0x1, 0x28(%r14)
jne 0xa4b83
movl 0x8a8(%rbx), %r9d
cmpq %r9, %rcx
je 0xa4b7f
movl 0x8ac(%rbx), %r9d
cmpq %r9, %rcx
je 0xa4b7f
movl 0x8b0(%rbx), %r9d
cmpq %r9, %rcx
jne 0xa4b83
movl 0x48(%r14), %r15d
cmpw $0x1, 0x2a(%r14)
jne 0xa4b9b
movl 0x8b4(%rbx), %r9d
cmpq %r9, %rcx
jne 0xa4b9b
movl 0x48(%r14), %r15d
cmpw $0x1, 0x2c(%r14)
jne 0xa4bb3
movl 0x8bc(%rbx), %r9d
cmpq %r9, %rcx
jne 0xa4bb3
movl 0x48(%r14), %r15d
cmpw $0x1, 0x3e(%r14)
jne 0xa4bd7
movslq 0x8c0(%rbx), %r9
cmpq %r9, %rcx
jl 0xa4bd7
movslq 0x64(%r14), %r10
addq %r9, %r10
cmpq %r10, %rcx
jl 0xa4cd7
cmpw $0x1, 0x40(%r14)
jne 0xa4c33
movslq 0x8c8(%rbx), %r9
cmpq %r9, %rcx
jl 0xa4bfb
movslq 0x64(%r14), %r10
addq %r9, %r10
cmpq %r10, %rcx
jl 0xa4cd7
movslq 0x8cc(%rbx), %r9
cmpq %r9, %rcx
jl 0xa4c17
movslq 0x64(%r14), %r10
addq %r9, %r10
cmpq %r10, %rcx
jl 0xa4cd7
movslq 0x8d0(%rbx), %r9
cmpq %r9, %rcx
jl 0xa4c33
movslq 0x64(%r14), %r10
addq %r9, %r10
cmpq %r10, %rcx
jl 0xa4cd7
cmpw $0x1, 0x42(%r14)
jne 0xa4c57
movslq 0x8d4(%rbx), %r9
cmpq %r9, %rcx
jl 0xa4c57
movslq 0x64(%r14), %r10
addq %r9, %r10
cmpq %r10, %rcx
jl 0xa4cd7
cmpw $0x1, 0x44(%r14)
jne 0xa4cdb
movslq 0x8d8(%rbx), %r9
cmpq %r9, %rcx
jl 0xa4c77
movslq 0x64(%r14), %r10
addq %r9, %r10
cmpq %r10, %rcx
jl 0xa4cd7
movslq 0x8dc(%rbx), %r9
cmpq %r9, %rcx
jl 0xa4c8f
movslq 0x64(%r14), %r10
addq %r9, %r10
cmpq %r10, %rcx
jl 0xa4cd7
movslq 0x8e0(%rbx), %r9
cmpq %r9, %rcx
jl 0xa4ca7
movslq 0x64(%r14), %r10
addq %r9, %r10
cmpq %r10, %rcx
jl 0xa4cd7
movslq 0x8e4(%rbx), %r9
cmpq %r9, %rcx
jl 0xa4cbf
movslq 0x64(%r14), %r10
addq %r9, %r10
cmpq %r10, %rcx
jl 0xa4cd7
movslq 0x8e8(%rbx), %r9
cmpq %r9, %rcx
jl 0xa4cdb
movslq 0x64(%r14), %r10
addq %r9, %r10
cmpq %r10, %rcx
jge 0xa4cdb
movl 0x54(%r14), %r15d
cmpw $0x1, 0x2e(%r14)
jne 0xa4cff
movslq 0x8c4(%rbx), %r9
cmpq %r9, %rcx
jl 0xa4cff
movslq 0x64(%r14), %r10
addq %r9, %r10
cmpq %r10, %rcx
jge 0xa4cff
movl 0x54(%r14), %r15d
cmpw $0x1, 0x12(%r14)
jne 0xa4d17
movl 0x84c(%r14), %r9d
cmpq %r9, %rdx
jne 0xa4d17
movl 0x50(%r14), %r15d
movslq 0x908(%rbx), %r9
movl -0x4(%rsi,%r9,4), %r9d
cmpl %r9d, %r15d
jg 0xa4d8b
xorl %r9d, %r9d
movq %r9, %r10
incq %r9
cmpl %r15d, (%rsi,%r10,4)
jl 0xa4d2b
movq 0x8f8(%rbx), %r10
movq (%r10,%rdx,8), %r10
movl %r9d, (%r10,%rcx,4)
movl 0x908(%rbx), %r11d
cmpl %r11d, %r9d
jge 0xa4d60
incl %r9d
movl %r9d, (%r10,%rcx,4)
movl 0x908(%rbx), %r11d
cmpl %r11d, %r9d
jge 0xa4d6c
incl %r9d
movl %r9d, (%r10,%rcx,4)
movl (%rdi,%rdx,4), %r10d
cmpl %r9d, %r10d
cmovgl %r10d, %r9d
movl %r9d, (%rdi,%rdx,4)
incq %rcx
jmp 0xa4b2a
incq %rdx
jmp 0xa4b06
leaq 0x70eb7(%rip), %rsi     # 0x115c49
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %r15d, %r8d
xorl %eax, %eax
callq 0x2e014
leaq 0x402d7(%rip), %rsi     # 0xe5082
leaq 0x70eec(%rip), %rdx     # 0x115c9e
leaq 0x810(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4025f(%rip), %rsi     # 0xe5034
leaq 0x70e59(%rip), %rdx     # 0x115c35
movq %rbx, %rdi
movl $0x3e7, %ecx            # imm = 0x3E7
movq %r15, %r8
jmp 0xa4a02