// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../source/transfer.c
// Function: transfer_compute_for_each_l
int transfer_compute_for_each_l(
                                struct transfer_workspace * ptw,
                                struct precision * ppr,
                                struct perturbations * ppt,
                                struct transfer * ptr,
                                int index_q,
                                int index_md,
                                int index_ic,
                                int index_tt,
                                int index_l,
                                double l,
                                double q_max_bessel,
                                radial_function_type radial_type,
                                short use_full_limber
                                ){

  /** Summary: */

  /** - define local variables */

  /* current wavenumber value */
  double q,k;

  /* value of transfer function */
  double transfer_function;

  /* whether to use the Limber approximation */
  short use_limber;

  /** - return zero transfer function if l is above l_max */
  if (index_l >= ptr->l_size_tt[index_md][index_tt]) {
     transfer_function = 0.;
  }
  else {

    if (ptr->transfer_verbose > 3)
      printf("Compute transfer for l=%d type=%d\n",(int)l,index_tt);

    if (use_full_limber == _FALSE_) {

      q = ptr->q[index_q];
      k = ptr->k[index_md][index_q];

      class_call(transfer_use_limber(ppr,
                                     ppt,
                                     ptr,
                                     q_max_bessel,
                                     index_md,
                                     index_tt,
                                     q,
                                     l,
                                     &use_limber),
                 ptr->error_message,
                 ptr->error_message);
    }
    else {
      q = ptr->q_limber[index_q];
      k = ptr->k_limber[index_md][index_q];
      use_limber = _TRUE_;
    }

    if (use_limber == _TRUE_) {

      class_call(transfer_limber(ptr,
                                 ptw,
                                 index_md,
                                 index_q,
                                 l,
                                 q,
                                 radial_type,
                                 &transfer_function),
                 ptr->error_message,
                 ptr->error_message);

    }
    else {
      class_call(transfer_integrate(
                                    ppt,
                                    ptr,
                                    ptw,
                                    index_q,
                                    index_md,
                                    index_tt,
                                    l,
                                    index_l,
                                    k,
                                    radial_type,
                                    &transfer_function
                                    ),
                 ptr->error_message,
                 ptr->error_message);
    }
  }

  /** - store transfer function in transfer structure */
  if (use_full_limber == _FALSE_) {
    ptr->transfer[index_md][((index_ic * ptr->tt_size[index_md] + index_tt)
                             * ptr->l_size[index_md] + index_l)
                            * ptr->q_size + index_q]
      = transfer_function;
  }
  else {
    ptr->transfer_limber[index_md][((index_ic * ptr->tt_size[index_md] + index_tt)
                                   * ptr->l_size[index_md] + index_l)
                                  * ptr->q_size_limber + index_q]
      = transfer_function;
  }

  return _SUCCESS_;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x838, %rsp            # imm = 0x838
movq %rcx, %rbx
movq %rsi, %r13
movq %rdi, %r10
movslq 0x878(%rsp), %r15
movzwl 0x890(%rsp), %edi
movl 0x880(%rsp), %esi
movq 0x8f8(%rcx), %rax
movslq %r9d, %r14
movq (%rax,%r14,8), %rax
movslq %r8d, %r12
cmpl %esi, (%rax,%r15,4)
jle 0xafb58
movapd %xmm0, %xmm2
movl %r8d, %ebp
movq %rdx, 0x28(%rsp)
cmpw $0x4, 0x968(%rbx)
jl 0xafb25
cvttsd2si %xmm2, %esi
leaq 0x73107(%rip), %rdi     # 0x122bf2
movl %r15d, %edx
xorl %eax, %eax
movsd %xmm2, 0x8(%rsp)
movq %r12, 0x10(%rsp)
movq %r10, %r12
movsd %xmm1, 0x18(%rsp)
callq 0x8030
movsd 0x18(%rsp), %xmm1
movq %r12, %r10
movq 0x10(%rsp), %r12
movsd 0x8(%rsp), %xmm2
movzwl 0x890(%rsp), %edi
testw %di, %di
je 0xafbc7
movq 0x948(%rbx), %rax
movq 0x950(%rbx), %rcx
movsd (%rax,%r12,8), %xmm1
movq (%rcx,%r14,8), %rax
movsd (%rax,%r12,8), %xmm3
movw $0x1, 0x6(%rsp)
jmp 0xafc3d
movq $0x0, 0x20(%rsp)
movl 0x870(%rsp), %eax
movq 0x8f0(%rbx), %rcx
imull (%rcx,%r14,4), %eax
movq 0x900(%rbx), %rcx
addl %r15d, %eax
imull (%rcx,%r14,4), %eax
addl %esi, %eax
movsd 0x20(%rsp), %xmm0
cltq
testw %di, %di
je 0xafba3
movq 0x960(%rbx), %rcx
imulq 0x940(%rbx), %rax
jmp 0xafbb2
movq 0x958(%rbx), %rcx
imulq 0x920(%rbx), %rax
shlq $0x3, %rax
addq (%rcx,%r14,8), %rax
movsd %xmm0, (%rax,%r12,8)
xorl %eax, %eax
jmp 0xafd4d
movq 0x928(%rbx), %rax
movq 0x930(%rbx), %rcx
movsd (%rax,%r12,8), %xmm3
movsd %xmm3, 0x10(%rsp)
movq (%rcx,%r14,8), %rax
movsd (%rax,%r12,8), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x6(%rsp), %r9
movq %r13, %rdi
movq 0x28(%rsp), %rsi
movq %rbx, %rdx
movapd %xmm1, %xmm0
movl %r14d, %ecx
movl %r15d, %r8d
movaps %xmm3, %xmm1
movsd %xmm2, 0x8(%rsp)
movsd 0x8(%rsp), %xmm2
movq %r12, %r13
movq %r10, %r12
callq 0xb08ae
movsd 0x18(%rsp), %xmm3
movsd 0x10(%rsp), %xmm1
movq %r12, %r10
movq %r13, %r12
movsd 0x8(%rsp), %xmm2
movl 0x888(%rsp), %r8d
cmpw $0x1, 0x6(%rsp)
jne 0xafcba
leaq 0x20(%rsp), %r9
movq %rbx, %rdi
movq %r10, %rsi
movapd %xmm2, %xmm0
callq 0xb0ba1
testl %eax, %eax
movzwl 0x890(%rsp), %edi
movl 0x880(%rsp), %esi
je 0xafb61
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4176a(%rip), %rsi     # 0xf13f0
leaq 0x72fa4(%rip), %rdx     # 0x122c31
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x4138e(%rip), %rsi     # 0xf1034
leaq 0x72f68(%rip), %rdx     # 0x122c15
movq %rbx, %rdi
movl $0xce0, %ecx            # imm = 0xCE0
jmp 0xafd3e
subq $0x8, %rsp
leaq 0x28(%rsp), %rax
movq 0x30(%rsp), %rdi
movq %rbx, %rsi
movq %r10, %rdx
movl %ebp, %ecx
movapd %xmm2, %xmm0
movaps %xmm3, %xmm1
pushq %rax
pushq %r8
movl 0x898(%rsp), %eax
movq %rax, %r13
pushq %rax
callq 0xb1554
movq %r13, %rsi
addq $0x20, %rsp
testl %eax, %eax
movzwl 0x890(%rsp), %edi
je 0xafb61
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x416e1(%rip), %rsi     # 0xf13f0
leaq 0x72f6f(%rip), %rdx     # 0x122c85
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x41305(%rip), %rsi     # 0xf1034
leaq 0x72edf(%rip), %rdx     # 0x122c15
movq %rbx, %rdi
movl $0xcf2, %ecx            # imm = 0xCF2
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
addq $0x838, %rsp            # imm = 0x838
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq