// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../source/transfer.c
// Function: transfer_limber2
int transfer_limber2(
                     int tau_size,
                     struct transfer * ptr,
                     int index_md,
                     int index_k,
                     double l,
                     double k,
                     double * tau0_minus_tau,
                     double * sources,
                     radial_function_type radial_type,
                     double * trsf
                     ){

  /** Summary: */

  /** - define local variables */

  /* conformal time at which source must be computed */
  double tau0_minus_tau_limber;
  int index_tau;

  /* interpolated source and its derivatives */
  double S, dS, ddS;

  /** - get k, l and infer tau such that k(tau0-tau)=l+1/2;
      check that tau is in appropriate range */

  tau0_minus_tau_limber = (l+0.5)/k;  //TBC: to be updated to include curvature effects

  if ((tau0_minus_tau_limber > tau0_minus_tau[0]) ||
      (tau0_minus_tau_limber < tau0_minus_tau[tau_size-1])) {
    *trsf = 0.;
    return _SUCCESS_;
  }

  /** - find  bracketing indices */
  index_tau=0;
  while ((tau0_minus_tau[index_tau] > tau0_minus_tau_limber) && (index_tau<tau_size-2))
    index_tau++;

  /** - interpolate by fitting a polynomial of order two; get source
      and its first two derivatives */
  class_call(array_interpolate_parabola(tau0_minus_tau[index_tau-1],
                                        tau0_minus_tau[index_tau],
                                        tau0_minus_tau[index_tau+1],
                                        tau0_minus_tau_limber,
                                        sources[index_tau-1],
                                        sources[index_tau],
                                        sources[index_tau+1],
                                        &S,
                                        &dS,
                                        &ddS,
                                        ptr->error_message),
             ptr->error_message,
             ptr->error_message);


  /** - get transfer from 2nd order Limber approx (inferred from 0809.5112 [astro-ph]) */

  *trsf = sqrt(_PI_/(2.*l+1.))/k*((1.-3./2./(2.*l+1.)/(2.*l+1.))*S+dS/k/(2.*l+1.)-0.5*ddS/k/k);

  return _SUCCESS_;

}

// Assembly:
subq $0x878, %rsp            # imm = 0x878
movq 0x888(%rsp), %rax
movl 0x880(%rsp), %eax
movl %edi, 0x870(%rsp)
movq %rsi, 0x868(%rsp)
movl %edx, 0x864(%rsp)
movl %ecx, 0x860(%rsp)
movsd %xmm0, 0x858(%rsp)
movsd %xmm1, 0x850(%rsp)
movq %r8, 0x848(%rsp)
movq %r9, 0x840(%rsp)
movsd 0x8b92b(%rip), %xmm0    # 0x1d2c88
addsd 0x858(%rsp), %xmm0
divsd 0x850(%rsp), %xmm0
movsd %xmm0, 0x838(%rsp)
movsd 0x838(%rsp), %xmm0
movq 0x848(%rsp), %rax
ucomisd (%rax), %xmm0
ja 0x1473b8
movsd 0x838(%rsp), %xmm1
movq 0x848(%rsp), %rax
movl 0x870(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1473d7
movq 0x888(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movl $0x0, 0x874(%rsp)
jmp 0x147675
movl $0x0, 0x834(%rsp)
movq 0x848(%rsp), %rax
movslq 0x834(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorl %eax, %eax
ucomisd 0x838(%rsp), %xmm0
movb %al, 0xf(%rsp)
jbe 0x147422
movl 0x834(%rsp), %eax
movl 0x870(%rsp), %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
setl %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x14742c
jmp 0x14743f
movl 0x834(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x834(%rsp)
jmp 0x1473e2
movq 0x848(%rsp), %rax
movl 0x834(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x848(%rsp), %rax
movslq 0x834(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x848(%rsp), %rax
movl 0x834(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x838(%rsp), %xmm3
movq 0x840(%rsp), %rax
movl 0x834(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm4
movq 0x840(%rsp), %rax
movslq 0x834(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm5
movq 0x840(%rsp), %rax
movl 0x834(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm6
movq 0x868(%rsp), %rcx
addq $0x96a, %rcx            # imm = 0x96A
leaq 0x828(%rsp), %rdi
leaq 0x820(%rsp), %rsi
leaq 0x818(%rsp), %rdx
callq 0x29a40
cmpl $0x1, %eax
jne 0x147572
leaq 0x10(%rsp), %rdi
movq 0x868(%rsp), %rcx
addq $0x96a, %rcx            # imm = 0x96A
leaq 0x8aeb2(%rip), %rsi     # 0x1d23d8
leaq 0xbd443(%rip), %rdx     # 0x204970
movb $0x0, %al
callq 0x5b9c0
movq 0x868(%rsp), %rdi
addq $0x96a, %rdi            # imm = 0x96A
leaq 0x10(%rsp), %r8
leaq 0x8aae5(%rip), %rsi     # 0x1d2034
leaq 0xbd504(%rip), %rdx     # 0x204a5a
movl $0xf40, %ecx            # imm = 0xF40
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x874(%rsp)
jmp 0x147675
movsd 0x858(%rsp), %xmm1
addsd %xmm1, %xmm1
movsd 0x8acc1(%rip), %xmm0    # 0x1d2248
addsd %xmm0, %xmm1
movsd 0x8da4d(%rip), %xmm0    # 0x1d4fe0
divsd %xmm1, %xmm0
callq 0x82e0
divsd 0x850(%rsp), %xmm0
movsd 0x858(%rsp), %xmm1
addsd %xmm1, %xmm1
movsd 0x8ac8e(%rip), %xmm2    # 0x1d2248
addsd %xmm2, %xmm1
movsd 0x8b68a(%rip), %xmm2    # 0x1d2c50
divsd %xmm1, %xmm2
movsd 0x858(%rsp), %xmm1
addsd %xmm1, %xmm1
movsd 0x8ac69(%rip), %xmm3    # 0x1d2248
addsd %xmm3, %xmm1
divsd %xmm1, %xmm2
movsd 0x8ac59(%rip), %xmm1    # 0x1d2248
subsd %xmm2, %xmm1
movsd 0x828(%rsp), %xmm3
movsd 0x820(%rsp), %xmm2
divsd 0x850(%rsp), %xmm2
movsd 0x858(%rsp), %xmm4
addsd %xmm4, %xmm4
movsd 0x8ac25(%rip), %xmm5    # 0x1d2248
addsd %xmm5, %xmm4
divsd %xmm4, %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movsd 0x8b64d(%rip), %xmm2    # 0x1d2c88
mulsd 0x818(%rsp), %xmm2
divsd 0x850(%rsp), %xmm2
divsd 0x850(%rsp), %xmm2
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movq 0x888(%rsp), %rax
movsd %xmm0, (%rax)
movl $0x0, 0x874(%rsp)
movl 0x874(%rsp), %eax
addq $0x878, %rsp            # imm = 0x878
retq
nopw %cs:(%rax,%rax)