// File: /workspace/github_c_makefile_star2_O2/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 $0x848, %rsp            # imm = 0x848
movapd %xmm0, %xmm2
movl %r8d, %ebp
movq %rcx, %rbx
movq %rsi, %r11
movslq 0x888(%rsp), %r15
movzwl 0x8a0(%rsp), %ecx
movl 0x890(%rsp), %esi
movl 0x880(%rsp), %r12d
movq 0x8f8(%rbx), %rax
movslq %r9d, %r14
movq (%rax,%r14,8), %rax
xorpd %xmm0, %xmm0
cmpl %esi, (%rax,%r15,4)
jle 0xa755a
movq %rdx, %r10
movq %rdi, %rdx
cmpw $0x4, 0x968(%rbx)
jl 0xa7434
cvttsd2si %xmm2, %esi
leaq 0x6f6d6(%rip), %rdi     # 0x116ac2
movq %rdx, 0x28(%rsp)
movl %r15d, %edx
xorl %eax, %eax
movsd %xmm2, 0x10(%rsp)
movq %r10, %r13
movsd %xmm1, 0x20(%rsp)
movl %ebp, 0x18(%rsp)
movq %r11, %rbp
callq 0x8030
movq %rbp, %r11
movl 0x18(%rsp), %ebp
movsd 0x20(%rsp), %xmm1
movq %r13, %r10
movq 0x28(%rsp), %rdx
movsd 0x10(%rsp), %xmm2
movzwl 0x8a0(%rsp), %ecx
movl 0x898(%rsp), %r8d
movslq %ebp, %r13
testw %cx, %cx
je 0xa7456
movq 0x948(%rbx), %rax
movsd (%rax,%r13,8), %xmm1
jmp 0xa74de
movq 0x928(%rbx), %rax
movq 0x930(%rbx), %rcx
movsd (%rax,%r13,8), %xmm3
movsd %xmm3, 0x20(%rsp)
movq (%rcx,%r14,8), %rax
movsd (%rax,%r13,8), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0xe(%rsp), %r9
movq %r11, %rdi
movq %r10, %rsi
movq %rdx, 0x28(%rsp)
movq %rbx, %rdx
movapd %xmm1, %xmm0
movl %r14d, %ecx
movq %r10, 0x38(%rsp)
movl %r15d, %r8d
movaps %xmm3, %xmm1
movsd %xmm2, 0x10(%rsp)
movsd 0x10(%rsp), %xmm2
callq 0xa8062
movsd 0x20(%rsp), %xmm1
movl 0x898(%rsp), %r8d
movq 0x28(%rsp), %rdx
movsd 0x10(%rsp), %xmm2
leaq 0xe(%rsp), %rax
cmpw $0x1, (%rax)
jne 0xa759b
leaq 0x30(%rsp), %r9
movq %rbx, %rdi
movq %rdx, %rsi
movapd %xmm2, %xmm0
callq 0xa8364
testl %eax, %eax
je 0xa7545
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x3deec(%rip), %rsi     # 0xe53f0
leaq 0x6f5f6(%rip), %rdx     # 0x116b01
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x3db10(%rip), %rsi     # 0xe5034
leaq 0x6f5ba(%rip), %rdx     # 0x116ae5
movq %rbx, %rdi
movl $0xce0, %ecx            # imm = 0xCE0
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
jmp 0xa765b
movsd 0x30(%rsp), %xmm0
movl 0x890(%rsp), %esi
movzwl 0x8a0(%rsp), %ecx
movslq %ebp, %r13
testw %cx, %cx
je 0xa761b
movq 0x960(%rbx), %rax
movq 0x8f0(%rbx), %rcx
movq 0x900(%rbx), %rdx
imull (%rcx,%r14,4), %r12d
addl %r15d, %r12d
imull (%rdx,%r14,4), %r12d
addl %esi, %r12d
movslq %r12d, %rcx
imulq 0x940(%rbx), %rcx
jmp 0xa764b
subq $0x8, %rsp
leaq 0x38(%rsp), %rax
movq 0x40(%rsp), %rdi
movq %rbx, %rsi
movl %ebp, %ecx
movapd %xmm2, %xmm0
movsd 0x20(%rsp), %xmm1
pushq %rax
pushq %r8
movl 0x8a8(%rsp), %ebp
pushq %rbp
callq 0xa8d06
addq $0x20, %rsp
testl %eax, %eax
je 0xa7612
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x3de12(%rip), %rsi     # 0xe53f0
leaq 0x6f570(%rip), %rdx     # 0x116b55
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x3da36(%rip), %rsi     # 0xe5034
leaq 0x6f4e0(%rip), %rdx     # 0x116ae5
movq %rbx, %rdi
movl $0xcf2, %ecx            # imm = 0xCF2
jmp 0xa7533
movsd 0x30(%rsp), %xmm0
movq %rbp, %rsi
movq 0x958(%rbx), %rax
movq 0x8f0(%rbx), %rcx
movq 0x900(%rbx), %rdx
imull (%rcx,%r14,4), %r12d
addl %r15d, %r12d
imull (%rdx,%r14,4), %r12d
addl %esi, %r12d
movslq %r12d, %rcx
imulq 0x920(%rbx), %rcx
shlq $0x3, %rcx
addq (%rax,%r14,8), %rcx
movsd %xmm0, (%rcx,%r13,8)
xorl %eax, %eax
addq $0x848, %rsp            # imm = 0x848
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq